Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bits_helpers/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akritkbehera , as the new relocation logic can relocated init.*sh files so why not use
WORK_DIR=<build/work/directory> . the relocation can change it to WORK_DIR=<deploydirectory> ?

@ktf , what was the logic of setting WORK_DIR from outside? Can't we just hard-code it with proper relocation ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that you do not need aliBuild to do the relocation of packages and loading of the environment, so everything related to that must work with WORK_DIR being set from the outside.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ktf , I understand that. But you still need some tool/script to deploy the pre-build packages and that tool will run the relocation .... right? If yes then why not just relocate init.*sh too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one benefit I see with setting WORK_DIR externally is that one can just symlink a pre-installed/deployed package from CVMFS in to local build area and its ${<PKG>_ROOT} will properly point to WORK_DIR/pkg-path.

I am fine with change in the PR. This will allow

  • bits/alibuild to use pre-deployed packages from cvmfs ( as bits/alibuild set WORK_DIR) by just symlinking them
  • No need to set WORK_DIR for setting up package env directly from deployed area as default WORK_DIR in packages' init file will be properly relocated

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal was to avoid relocation as much as possible. That way just untarring the tarballs would have given you a working environment.

# 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
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions bits_helpers/build_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down