Skip to content

Commit

Permalink
Protect package installation against interruption
Browse files Browse the repository at this point in the history
If rsync is interrupted by the user while installing package files to their
final path, it might already have copied the .build-hash file. That would
cause aliBuild to assume that the package was fully installed on subsequent
runs, even if some parts are missing.

Protect against this by explicitly creating the marker file last, after rsync
has succeeded.
  • Loading branch information
TimoWilken authored and ktf committed Mar 14, 2024
1 parent 583db61 commit 83ffa3f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion alibuild_helpers/build_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ cat <<\EOF > "$INSTALLROOT/etc/profile.d/init.sh"
EOF

cd "$WORK_DIR/INSTALLROOT/$PKGHASH"
echo "$PKGHASH" > "$INSTALLROOT/.build-hash"
# Replace the .envrc to point to the final installation directory.
cat << EOF > "$BUILDDIR/.envrc"
# Source the build environment which was used for this package
Expand Down Expand Up @@ -293,6 +292,9 @@ if [[ $BUILD_FAMILY ]]; then
ln -snf $PKGVERSION-$PKGREVISION $ARCHITECTURE/$PKGNAME/latest-$BUILD_FAMILY
fi

# When the package is definitely fully installed, install the file that marks
# the package as successful.
echo "$PKGHASH" > "$WORK_DIR/$PKGPATH/.build-hash"
# Mark the build as successful with a placeholder. Allows running incremental
# recipe in case the package is in development mode.
echo "${DEVEL_HASH}${DEPS_HASH}" > "$BUILDDIR/.build_succeeded"

0 comments on commit 83ffa3f

Please sign in to comment.