#!/usr/bin/env bash
set -e

source ./config.rc

if [[ -n "${systemPath:-}" ]]
then
    export PATH="$builddir/bin:$systemPath"
else
    export PATH="$builddir/bin:/usr/bin:/bin"
fi

# Remove build directory
rm -rf $EUPS_PATH/EupsBuildDir

#
# make the package portable
#
bash $scriptdir/make-distributable/build-patchelf
export PATH="$builddir/patchelf/bin:$PATH"

bash $scriptdir/make-distributable/unlock-dir
bash $scriptdir/make-distributable/recreate-link
bash $scriptdir/make-distributable/recreate-elf
bash $scriptdir/make-distributable/lock-dir

#
# Save names of system libraries that this package
# depends on
#
bash $scriptdir/bin/find-dependence.sh $EUPS_PATH
