diff --git a/bits_helpers/build.py b/bits_helpers/build.py index 4ce5072..8df5ee7 100644 --- a/bits_helpers/build.py +++ b/bits_helpers/build.py @@ -1349,6 +1349,7 @@ def performPreferCheckWithTempDir(pkg, cmd): ("FULL_BUILD_REQUIRES", " ".join(spec["full_build_requires"])), ("FULL_REQUIRES", " ".join(spec["full_requires"])), ("BITS_PREFER_SYSTEM_KEY", spec.get("key", "")), + ("BITS_SCRIPT_DIR", dirname(realpath(__file__))), ] if "sources" in spec: for idx, src in enumerate(spec["sources"]): diff --git a/bits_helpers/build_template.sh b/bits_helpers/build_template.sh index ce29286..fc1a9b9 100644 --- a/bits_helpers/build_template.sh +++ b/bits_helpers/build_template.sh @@ -37,6 +37,7 @@ export PATH=$WORK_DIR/wrapper-scripts:$PATH # the bits script itself # # - ARCHITECTURE +# - BITS_SCRIPT_DIR # - BUILD_REQUIRES # - CACHED_TARBALL # - CAN_DELETE @@ -212,27 +213,21 @@ EOF cd "$WORK_DIR/INSTALLROOT/$PKGHASH/$PKGPATH" # Find which files need relocation. -{ grep -I -H -l -R "\(INSTALLROOT/$PKGHASH\|[@][@]PKGREVISION[@]$PKGHASH[@][@]\)" . || true; } | sed -e 's|^\./||' > "$INSTALLROOT/.original-unrelocated" +{ grep -I -H -l -R "\($WORK_DIR\|[@][@]PKGREVISION[@]$PKGHASH[@][@]\)" . || true; } | sed -e 's|^\./||' > "$INSTALLROOT/etc/profile.d/.bits-relocate" # Relocate script for // structure -cat > "$INSTALLROOT/relocate-me.sh" < "$INSTALLROOT/etc/profile.d/.bits-pkginfo" < \$PP/$unrelocated" -done < "$INSTALLROOT/.original-unrelocated" >> "$INSTALLROOT/relocate-me.sh" +cp "${BITS_SCRIPT_DIR}/relocate-me.sh" "$INSTALLROOT/" # Always relocate the modulefile (if present) so that it works also in devel mode. -if [[ ! -s "$INSTALLROOT/.original-unrelocated" && -f "$INSTALLROOT/etc/modulefiles/$PKGNAME" ]]; then +if [[ ! -s "$INSTALLROOT/etc/profile.d/.bits-relocate" && -f "$INSTALLROOT/etc/modulefiles/$PKGNAME" ]]; then echo "mv -f \$PP/etc/modulefiles/$PKGNAME \$PP/etc/modulefiles/${PKGNAME}.forced-relocation && sed -e \"s|[@][@]PKGREVISION[@]\$PH[@][@]|$PKGREVISION|g\" \$PP/etc/modulefiles/${PKGNAME}.forced-relocation > \$PP/etc/modulefiles/$PKGNAME" >> "$INSTALLROOT/relocate-me.sh" fi @@ -289,7 +284,6 @@ EOF fi cat "$INSTALLROOT/relocate-me.sh" -cat "$INSTALLROOT/.original-unrelocated" | xargs -n1 -I{} cp '{}' '{}'.unrelocated fi cd "$WORK_DIR/INSTALLROOT/$PKGHASH" diff --git a/bits_helpers/relocate-me.sh b/bits_helpers/relocate-me.sh new file mode 100644 index 0000000..fbb0e3d --- /dev/null +++ b/bits_helpers/relocate-me.sh @@ -0,0 +1,11 @@ +#!/bin/bash -e +THISDIR="$(cd -P "$(dirname "$0")" && pwd)" +source ${THISDIR}/etc/profile.d/.bits-pkginfo +INSTALL_BASE=$(echo $THISDIR | sed "s|/$PP$||") +if [[ -s ${THISDIR}/etc/profile.d/.bits-relocate ]] ; then + for f in $(cat ${THISDIR}/etc/profile.d/.bits-relocate) ; do + sed -i -e "s|${PKG_DIR}/INSTALLROOT/$PH|$INSTALL_BASE|g;s|${PKG_DIR}|$INSTALL_BASE|g" "${THISDIR}/$f" + done +fi +sed -i -e "s|^PKG_DIR=.*|PKG_DIR="${INSTALL_BASE}"|" $THISDIR/etc/profile.d/.bits-pkginfo +