aboutsummaryrefslogtreecommitdiff
path: root/sbrun
diff options
context:
space:
mode:
Diffstat (limited to 'sbrun')
-rwxr-xr-xsbrun57
1 files changed, 40 insertions, 17 deletions
diff --git a/sbrun b/sbrun
index fe5f809..f55226c 100755
--- a/sbrun
+++ b/sbrun
@@ -29,7 +29,11 @@ if [ "$(id -u)" != "0" ]; then
"$0" "$@"
fi
+# This is a bit of a hack: I keep my tools in my user's ~/bin,
+# and sourcing /etc/profile blows away PATH...
+OLDPATH=$PATH
source /etc/profile
+PATH=$OLDPATH:$PATH
[ -e "$BUILDLOG" ] && mv "$BUILDLOG" "$BUILDLOG".old
@@ -284,6 +288,30 @@ cleanup_log() {
[ -n "$LOGDIR" ] && rm -rf "$LOGDIR"
}
+cleanup_privdir() {
+ [ "$PRIVDIR" = "" ] && return
+ umount $FAKEROOT/$OUTPUT
+ umount $FAKEROOT/$TMP
+ umount $FAKEROOT
+ if [ "$?" != "0" ]; then
+ cat <<EOF | tee -a $BUILDLOG
+
+********************
+*
+* \$FAKEROOT $FAKEROOT still mounted!
+*
+********************
+
+Can't continue. This is likely a bug in sbrun, please contact
+its author: urchlay@slackware.uk
+EOF
+ exit 1
+ fi
+ # We know this isn't still mounted because we would have
+ # died with a "Can't continue" error, if it were.
+ rm -rf $PRIVDIR
+}
+
cleanup_build() {
[ "$CLEANUP" = "yes" ] && ( rm -rf "$TMP" )
}
@@ -305,6 +333,7 @@ ensure_path() {
signal_handler() {
cleanup_log
cleanup_nonet
+ cleanup_privdir
cleanup_build
exit 130
}
@@ -501,6 +530,7 @@ UPPERDIR=$PRIVDIR/upperdir
WORKDIR=$PRIVDIR/workdir
FAKEROOT=$PRIVDIR/fake_root
mkdir -p $UPPERDIR $WORKDIR $FAKEROOT
+echo "Private dir for overlay FS: $PRIVDIR" | tee -a $BUILDLOG
# Force-load the module
modprobe overlay &> /dev/null
@@ -528,20 +558,6 @@ echo "$SCRIPT exit status: $RET" | tee -a $BUILDLOG
} | tee -a $BUILDLOG
cleanup_nonet
-umount $FAKEROOT/$OUTPUT
-umount $FAKEROOT/$TMP
-umount $FAKEROOT
-if [ "$?" != "0" ]; then
- cat <<EOF | tee -a $BUILDLOG
-
-********************
-*
-* \$FAKEROOT $FAKEROOT still mounted!
-*
-********************
-
-EOF
-fi
### 20260923 bkw:
# Anything in $UPPERDIR after umount was written there by the
@@ -574,7 +590,10 @@ fi
\! -path $TMP \
\! -path $OUTPUT \
-print0 | xargs -r0 ls -bld > $TMP/sbrun.turds.$$
-)
+) 2>/dev/null
+
+cleanup_privdir
+
if [ -s $TMP/sbrun.turds.$$ ]; then
warn "WARNING: files altered outside the sandbox:"
cat $TMP/sbrun.turds.$$ 1>&2
@@ -584,7 +603,11 @@ rm -f $TMP/sbrun.turds.$$
# If linting + installation were both requested, don't install
# the package if it fails to lint.
-[ "$LINTPKG" = "yes" ] && sbopkglint || UPKG=""
+if [ "$LINTPKG" = "yes" ] && sbopkglint; then
+ RET=$?
+else
+ UPKG=""
+fi
# spawn shell(s) if requested. -i and -p are not mutually exclusive.
@@ -616,7 +639,7 @@ fi
cleanup_build
-# Install the package if -u.
+# Install the package if -i.
[ "$RET" = "0" ] && [ "$UPKG" = "yes" ] && upkg
# Our return status is that of the SlackBuild.