diff --git a/bits_helpers/build.py b/bits_helpers/build.py index 8df5ee7..d56a7b0 100644 --- a/bits_helpers/build.py +++ b/bits_helpers/build.py @@ -343,7 +343,7 @@ def better_tarball(spec, old, new): return old if hashes.index(old_hash) < hashes.index(new_hash) else new -def generate_initdotsh(package, specs, architecture, post_build=False): +def generate_initdotsh(package, specs, architecture, workDir="sw", post_build=False): """Return the contents of the given package's etc/profile/init.sh as a string. If post_build is true, also generate variables pointing to the package @@ -354,7 +354,11 @@ def generate_initdotsh(package, specs, architecture, post_build=False): # init.sh. This is useful for development off CVMFS, since we have a # slightly different directory hierarchy there. lines = [': "${BITS_ARCH_PREFIX:=%s}"' % architecture] - + lines.extend([ + 'if [ -z "${WORK_DIR}" ]; then', + ' WORK_DIR=%s' % abspath(workDir), + 'fi', + ]) # Generate the part which sources the environment for all the dependencies. # We guarantee that a dependency is always sourced before the parts # depending on it, but we do not guarantee anything for the order in which @@ -1310,8 +1314,8 @@ def performPreferCheckWithTempDir(pkg, cmd): writeAll("{}/{}.sh".format(scriptDir, spec["package"]), spec["recipe"]) writeAll("%s/build.sh" % scriptDir, cmd_raw % { "provenance": create_provenance_info(spec["package"], specs, args), - "initdotsh_deps": generate_initdotsh(p, specs, args.architecture, post_build=False), - "initdotsh_full": generate_initdotsh(p, specs, args.architecture, post_build=True), + "initdotsh_deps": generate_initdotsh(p, specs, args.architecture, workDir=args.workDir, post_build=False), + "initdotsh_full": generate_initdotsh(p, specs, args.architecture, workDir=args.workDir, post_build=True), "develPrefix": develPrefix, "workDir": workDir, "configDir": abspath(args.configDir), diff --git a/bits_helpers/build_template.sh b/bits_helpers/build_template.sh index fc1a9b9..a9e7a4c 100644 --- a/bits_helpers/build_template.sh +++ b/bits_helpers/build_template.sh @@ -320,6 +320,10 @@ cd "$WORK_DIR" if [ -w "$WORK_DIR/$ARCHITECTURE/$PKGNAME/$PKGVERSION-$PKGREVISION" ]; then bash -ex "$ARCHITECTURE/$PKGNAME/$PKGVERSION-$PKGREVISION/relocate-me.sh" fi +# Run the post-relocate script if it was created. +if [ "$PKGNAME" != defaults-* ] && [ -f "$WORK_DIR/$ARCHITECTURE/$PKGNAME/$PKGVERSION-$PKGREVISION/etc/profile.d/post-relocate.sh" ]; then + bash -ex "$WORK_DIR/$ARCHITECTURE/$PKGNAME/$PKGVERSION-$PKGREVISION/etc/profile.d/post-relocate.sh" +fi # Last package built gets a "latest" mark. ln -snf $PKGVERSION-$PKGREVISION $ARCHITECTURE/$PKGNAME/latest