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
70 changes: 40 additions & 30 deletions bits_helpers/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,18 +950,28 @@ def performPreferCheckWithTempDir(pkg, cmd):
spec["hash"] = spec["local_revision_hash"]
else:
spec["hash"] = spec["remote_revision_hash"]

# We do not use the override for devel packages, because we
# want to avoid having to rebuild things when the /tmp gets cleaned.
if spec["is_devel_pkg"]:
buildWorkDir = args.workDir
else:
buildWorkDir = os.environ.get("BITS_BUILD_WORK_DIR", args.workDir)

buildRoot = join(buildWorkDir, "BUILD", spec["hash"])

spec["old_devel_hash"] = readHashFile(join(
workDir, "BUILD", spec["hash"], spec["package"], ".build_succeeded"))
buildRoot, spec["package"], ".build_succeeded"))

# Recreate symlinks to this development package builds.
if spec["is_devel_pkg"]:
debug("Creating symlinks to builds of devel package %s", spec["package"])
# Ignore errors here, because the path we're linking to might not exist
# (if this is the first run through the loop). On the second run
# through, the path should have been created by the build process.
call_ignoring_oserrors(symlink, spec["hash"], join(workDir, "BUILD", spec["package"] + "-latest"))
call_ignoring_oserrors(symlink, spec["hash"], join(buildWorkDir, "BUILD", spec["package"] + "-latest"))
if develPrefix:
call_ignoring_oserrors(symlink, spec["hash"], join(workDir, "BUILD", spec["package"] + "-latest-" + develPrefix))
call_ignoring_oserrors(symlink, spec["hash"], join(buildWorkDir, "BUILD", spec["package"] + "-latest-" + develPrefix))
# Last package built gets a "latest" mark.
call_ignoring_oserrors(symlink, "{version}-{revision}".format(**spec),
join(workDir, args.architecture, spec["package"], "latest"))
Expand Down Expand Up @@ -1013,7 +1023,7 @@ def performPreferCheckWithTempDir(pkg, cmd):
# assuming the package is not a development one. We also can
# delete the SOURCES in case we have aggressive-cleanup enabled.
if not spec["is_devel_pkg"] and args.autoCleanup:
cleanupDirs = [join(workDir, "BUILD", spec["hash"]),
cleanupDirs = [buildRoot,
join(workDir, "INSTALLROOT", spec["hash"])]
if args.aggressiveCleanup:
cleanupDirs.append(join(workDir, "SOURCES", spec["package"]))
Expand All @@ -1022,13 +1032,13 @@ def performPreferCheckWithTempDir(pkg, cmd):
for d in cleanupDirs:
shutil.rmtree(d.encode("utf8"), True)
try:
unlink(join(workDir, "BUILD", spec["package"] + "-latest"))
unlink(join(buildWorkDir, "BUILD", spec["package"] + "-latest"))
if "develPrefix" in args:
unlink(join(workDir, "BUILD", spec["package"] + "-latest-" + args.develPrefix))
unlink(join(buildWorkDir, "BUILD", spec["package"] + "-latest-" + args.develPrefix))
except:
pass
try:
rmdir(join(workDir, "BUILD"))
rmdir(join(buildWorkDir, "BUILD"))
rmdir(join(workDir, "INSTALLROOT"))
except:
pass
Expand Down Expand Up @@ -1241,28 +1251,28 @@ def performPreferCheckWithTempDir(pkg, cmd):
if spec["is_devel_pkg"]:
updatablePkgs.append(spec["package"])

buildErrMsg = dedent("""\
Error while executing {sd}/build.sh on `{h}'.
Log can be found in {w}/BUILD/{p}-latest{devSuffix}/log
Please upload it to CERNBox/Dropbox if you intend to request support.
Build directory is {w}/BUILD/{p}-latest{devSuffix}/{p}.
""").format(
h=socket.gethostname(),
sd=scriptDir,
w=abspath(args.workDir),
p=spec["package"],
devSuffix="-" + args.develPrefix
if "develPrefix" in args and spec["is_devel_pkg"]
else "",
)
if updatablePkgs:
buildErrMsg += dedent("""
Note that you have packages in development mode.
Devel sources are not updated automatically, you must do it by hand.\n
This problem might be due to one or more outdated devel sources.
To update all development packages required for this build it is usually sufficient to do:
""")
buildErrMsg += "".join("\n ( cd %s && git pull --rebase )" % dp for dp in updatablePkgs)
buildErrMsg = dedent("""\
Error while executing {sd}/build.sh on `{h}'.
Log can be found in {w}/BUILD/{p}-latest{devSuffix}/log
Please upload it to CERNBox/Dropbox if you intend to request support.
Build directory is {w}/BUILD/{p}-latest{devSuffix}/{p}.
""").format(
h=socket.gethostname(),
sd=scriptDir,
w=buildWorkDir,
p=spec["package"],
devSuffix="-" + args.develPrefix
if "develPrefix" in args and spec["is_devel_pkg"]
else "",
)
if updatablePkgs:
buildErrMsg += dedent("""
Note that you have packages in development mode.
Devel sources are not updated automatically, you must do it by hand.\n
This problem might be due to one or more outdated devel sources.
To update all development packages required for this build it is usually sufficient to do:
""")
buildErrMsg += "".join("\n ( cd %s && git pull --rebase )" % dp for dp in updatablePkgs)

# Gather build info for the error message
try:
Expand Down Expand Up @@ -1317,7 +1327,7 @@ def performPreferCheckWithTempDir(pkg, cmd):
for spec in specs.values():
if spec["is_devel_pkg"]:
banner("Build directory for devel package %s:\n%s/BUILD/%s-latest%s/%s",
spec["package"], abspath(args.workDir), spec["package"],
spec["package"], abspath(buildWorkDir), spec["package"],
("-" + args.develPrefix) if "develPrefix" in args else "",
spec["package"])
if untrackedFilesDirectories:
Expand Down
11 changes: 7 additions & 4 deletions bits_helpers/build_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,19 @@ export PKG_BUILDNUM="$PKGREVISION"
export PKGPATH=${ARCHITECTURE}/${PKGNAME}/${PKGVERSION}-${PKGREVISION}
mkdir -p "$WORK_DIR/BUILD" "$WORK_DIR/SOURCES" "$WORK_DIR/TARS" \
"$WORK_DIR/SPECS" "$WORK_DIR/INSTALLROOT"
export BUILDROOT="$WORK_DIR/BUILD/$PKGHASH"

# If we are in development mode, then install directly in $WORK_DIR/$PKGPATH,
# so that we can do "make install" directly into BUILD/$PKGPATH and have
# changes being propagated.
# Moreover, devel packages should always go in the official WORK_DIR
if [ -n "$DEVEL_HASH" ]; then
export BITS_BUILD_WORK_DIR="${WORK_DIR}"
export INSTALLROOT="$WORK_DIR/$PKGPATH"
else
export INSTALLROOT="$WORK_DIR/INSTALLROOT/$PKGHASH/$PKGPATH"
export BITS_BUILD_WORK_DIR="${BITS_BUILD_WORK_DIR:-$WORK_DIR}"
fi

export BUILDROOT="$BITS_BUILD_WORK_DIR/BUILD/$PKGHASH"
export SOURCEDIR="$WORK_DIR/SOURCES/$PKGNAME/$PKGVERSION/$COMMIT_HASH"
export BUILDDIR="$BUILDROOT/$PKGNAME"

Expand Down Expand Up @@ -109,9 +112,9 @@ unset DYLD_LIBRARY_PATH
EOF

cd "$BUILDROOT"
ln -snf $PKGHASH $WORK_DIR/BUILD/$PKGNAME-latest
ln -snf $PKGHASH "${BUILDROOT}-latest"
if [[ $DEVEL_PREFIX ]]; then
ln -snf $PKGHASH $WORK_DIR/BUILD/$PKGNAME-latest-$DEVEL_PREFIX
ln -snf $PKGHASH "${BUILDROOT}-latest-$DEVEL_PREFIX"
fi

cd "$BUILDDIR"
Expand Down
Loading