aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-11-30 08:35:46 -0500
committerB. Watson <urchlay@slackware.uk>2026-11-30 08:35:46 -0500
commit6fb5284a9c04db7c0fd22becb1afa36fc99c283c (patch)
treeb8009d21f666fe398a6db3d47b176d6e8a738ef4
parentb4ef259ed064187a8bda00f815854738a14dfc63 (diff)
downloadsbo-maintainer-tools-6fb5284a9c04db7c0fd22becb1afa36fc99c283c.tar.gz
sbrun: replace tab indents with 2 spaces each.
-rwxr-xr-xsbrun256
1 files changed, 128 insertions, 128 deletions
diff --git a/sbrun b/sbrun
index fe828cb..bca7fec 100755
--- a/sbrun
+++ b/sbrun
@@ -22,14 +22,14 @@ DEFAULT_MAKEFLAGS="-j$(( $( nproc ) + 1 ))"
# must be explicity set here as sudo will strip them from the environment
# before executing anything.
if [ "$(id -u)" != "0" ]; then
- exec sudo \
- TMP="$TMP" \
- OUTPUT="$OUTPUT" \
- MAKEFLAGS="$MAKEFLAGS" \
- BUILDLOG="$BUILDLOG" \
- DISTCC_HOSTS="$DISTCC_HOSTS" \
- SBODL_CACHEDIR="${SBODL_CACHEDIR:-$HOME/sbodl-cache}" \
- "$0" "$@"
+ exec sudo \
+ TMP="$TMP" \
+ OUTPUT="$OUTPUT" \
+ MAKEFLAGS="$MAKEFLAGS" \
+ BUILDLOG="$BUILDLOG" \
+ DISTCC_HOSTS="$DISTCC_HOSTS" \
+ SBODL_CACHEDIR="${SBODL_CACHEDIR:-$HOME/sbodl-cache}" \
+ "$0" "$@"
fi
# This is a bit of a hack: I keep my tools in my user's ~/bin,
@@ -61,15 +61,15 @@ SELF=$(basename $0)
NONET_PATH=/mnt/nonet.$SELF.$$
long_help() {
- exec perldoc "$0"
+ exec perldoc "$0"
}
show_help() {
- # don't use warn here, log isn't open yet.
- if [ -n "$1" ]; then
- echo "$SELF: unknown option '$1'" 2>&1
- fi
- cat <<EOF
+ # don't use warn here, log isn't open yet.
+ if [ -n "$1" ]; then
+ echo "$SELF: unknown option '$1'" 2>&1
+ fi
+ cat <<EOF
$SELF: paranoid SlackBuild wrapper.
$SELF written by B. Watson (urchlay@slackware.uk) and released
@@ -106,24 +106,24 @@ EOF
# maybe add 2>/dev/null to these, but for now I wanna know if they fail.
cleanup_nonet() {
- if [ "$NETWORK" = "no" ]; then
- umount $NONET_PATH
- rm -f $NONET_PATH
- fi
+ if [ "$NETWORK" = "no" ]; then
+ umount $NONET_PATH
+ rm -f $NONET_PATH
+ fi
}
cleanup_log() {
- [ -n "$LOGDIR" ] && rm -rf "$LOGDIR"
+ [ -n "$LOGDIR" ] && rm -rf "$LOGDIR"
}
cleanup_privdir() {
- [ -e /root/.sbrun_no_chroot ] && return
- [ "$PRIVDIR" = "" ] && return
- umount $FAKEROOT/$OUTPUT
- umount $FAKEROOT/$TMP
- umount $FAKEROOT
- if [ "$?" != "0" ]; then
- cat <<EOF | tee -a $BUILDLOG
+ [ -e /root/.sbrun_no_chroot ] && return
+ [ "$PRIVDIR" = "" ] && return
+ umount $FAKEROOT/$OUTPUT
+ umount $FAKEROOT/$TMP
+ umount $FAKEROOT
+ if [ "$?" != "0" ]; then
+ cat <<EOF | tee -a $BUILDLOG
********************
*
@@ -134,25 +134,25 @@ cleanup_privdir() {
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
+ 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" )
+ [ "$CLEANUP" = "yes" ] && ( rm -rf "$TMP" )
}
# Add a dir to $PATH, if not already present. This is actually kinda
# pointless, it would work just as well to always add dirs to PATH
# even if they're redundant.
ensure_path() {
- if ! echo "$PATH" | sed 's,:,\n,g' | grep -q "^$1\$"; then
- #echo "$1 not in PATH, adding"
- export PATH="$1:$PATH"
- fi
+ if ! echo "$PATH" | sed 's,:,\n,g' | grep -q "^$1\$"; then
+ #echo "$1 not in PATH, adding"
+ export PATH="$1:$PATH"
+ fi
}
# Handle ^C gracefully. TODO: the exit status should be 128 plus
@@ -160,11 +160,11 @@ ensure_path() {
# the ^C signal, but we trap other signals too. Maybe use:
# http://stackoverflow.com/questions/2175647/is-it-possible-to-detect-which-trap-signal-in-bash
signal_handler() {
- cleanup_log
- cleanup_nonet
- cleanup_privdir
- cleanup_build
- exit 130
+ cleanup_log
+ cleanup_nonet
+ cleanup_privdir
+ cleanup_build
+ exit 130
}
# Print a number of seconds as either MM:SS (if less than 1 hour)
@@ -176,36 +176,36 @@ signal_handler() {
# next day). Hopefully no SlackBuild takes over a day to run, but you
# never know...
print_hms() {
- local sec="$1" hrs min
+ local sec="$1" hrs min
- hrs=$(( $sec / 3600 ))
- sec=$(( $sec % 3600 ))
+ hrs=$(( $sec / 3600 ))
+ sec=$(( $sec % 3600 ))
- min=$(( $sec / 60 ))
- sec=$(( $sec % 60 ))
+ min=$(( $sec / 60 ))
+ sec=$(( $sec % 60 ))
- if [ "$hrs" -gt "0" ]; then
- printf '%02d:%02d:%02d\n' $hrs $min $sec
- else
- printf '%02d:%02d\n' $min $sec
- fi
+ if [ "$hrs" -gt "0" ]; then
+ printf '%02d:%02d:%02d\n' $hrs $min $sec
+ else
+ printf '%02d:%02d\n' $min $sec
+ fi
}
# perl-flavoured error messenger
warn() {
- echo "$SELF:" "$@" 1>&2
- echo "$SELF:" "$@" >> $BUILDLOG
+ echo "$SELF:" "$@" 1>&2
+ echo "$SELF:" "$@" >> $BUILDLOG
}
# Suicide squad, attack!
die() {
- warn "$@"
- exit 1
+ warn "$@"
+ exit 1
}
# -q and -Q
run_queue() {
- exec sbodeps $1 . | sbqrun -
+ exec sbodeps $1 . | sbqrun -
}
### main()
@@ -240,29 +240,29 @@ fi
eval set -- "$OPTS"
while true; do
- case "$1" in
- -l) LINTPKG="yes" ;;
- -j) shift; MAKEFLAGS="$1" ;;
- -n) NETWORK=yes ;;
- -s) STRACE=-f ;;
- -x) X="-x" ;;
- -c) CLEANUP="yes" ;;
- -I) SRCSH="yes" ;;
- -p) PKGSH="yes" ;;
- -D) CC="distcc gcc"
- CXX="distcc g++"
- NETWORK=yes
- export CC CXX ;;
- -i) UPKG=yes ;;
- -d) SBODL=yes ;;
- -q) run_queue ;;
- -Q) run_queue -i ;;
- -h) show_help ; exit 0 ;;
- -H) long_help ; exit 0 ;;
- --) shift ; break ;;
- *) show_help "$1"; exit 1 ;; # never happens?
- esac
- shift
+ case "$1" in
+ -l) LINTPKG="yes" ;;
+ -j) shift; MAKEFLAGS="$1" ;;
+ -n) NETWORK=yes ;;
+ -s) STRACE=-f ;;
+ -x) X="-x" ;;
+ -c) CLEANUP="yes" ;;
+ -I) SRCSH="yes" ;;
+ -p) PKGSH="yes" ;;
+ -D) CC="distcc gcc"
+ CXX="distcc g++"
+ NETWORK=yes
+ export CC CXX ;;
+ -i) UPKG=yes ;;
+ -d) SBODL=yes ;;
+ -q) run_queue ;;
+ -Q) run_queue -i ;;
+ -h) show_help ; exit 0 ;;
+ -H) long_help ; exit 0 ;;
+ --) shift ; break ;;
+ *) show_help "$1"; exit 1 ;; # never happens?
+ esac
+ shift
done
[ "$SBODL" = "yes" ] && sbodl
@@ -284,8 +284,8 @@ chown "$( stat -c %U:%G . )" $BUILDLOG
# rest of arg parsing can use warn or die.
if echo "$1" | grep -qv '='; then
- SCRIPT="$1"
- shift
+ SCRIPT="$1"
+ shift
fi
# $ENV is only for showing to the user
@@ -296,15 +296,15 @@ export MAKEFLAGS TMP OUTPUT
# spaces to occur in the values. There is probably a better modern-bash
# way to do this, but (to me anyway) it'll be less readable.
for arg; do
- if echo "$arg" | grep -qv '='; then
- die "invalid/unknown argument '$1', try -h for help or -H for long help."
- else
- ENV="$ENV $arg"
- #eval export "$arg" # works but doesn't allow spaces
- var="$( echo "$arg" | cut -d= -f1 )"
- val="$( echo "$arg" | cut -d= -f2 )"
- eval "export $var='$val'"
- fi
+ if echo "$arg" | grep -qv '='; then
+ die "invalid/unknown argument '$1', try -h for help or -H for long help."
+ else
+ ENV="$ENV $arg"
+ #eval export "$arg" # works but doesn't allow spaces
+ var="$( echo "$arg" | cut -d= -f1 )"
+ val="$( echo "$arg" | cut -d= -f2 )"
+ eval "export $var='$val'"
+ fi
done
# The easy way to remove the source and PKG dirs after the
@@ -314,10 +314,10 @@ done
# we don't care about troubleshooting so much, and mktemp is
# the way to go.
if [ "$CLEANUP" = "yes" ]; then
- TMP="$( mktemp -d /tmp/sbrun.build.XXXXXX )"
- if [ -z "$TMP" ] || [ ! -d "$TMP" ]; then
- die "Can't create temp build dir in /tmp, bailing"
- fi
+ TMP="$( mktemp -d /tmp/sbrun.build.XXXXXX )"
+ if [ -z "$TMP" ] || [ ! -d "$TMP" ]; then
+ die "Can't create temp build dir in /tmp, bailing"
+ fi
fi
# I wasn't gonna trap signals, but I can't break myself of the habit
@@ -335,17 +335,17 @@ trap signal_handler INT TERM
SCRIPT="${SCRIPT:-$( /bin/ls ./*.SlackBuild | head -1 )}"
if [ ! -e "$SCRIPT" ]; then
- die "$SCRIPT not found, bailing"
+ die "$SCRIPT not found, bailing"
fi
{
- echo "Running $SCRIPT, logging to $BUILDLOG"
- echo "Environment: $ENV"
- echo "Network access: $NETWORK"
- if [ "$STRACE" != "" ]; then
- echo "strace log: strace.out"
- fi
- echo
+ echo "Running $SCRIPT, logging to $BUILDLOG"
+ echo "Environment: $ENV"
+ echo "Network access: $NETWORK"
+ if [ "$STRACE" != "" ]; then
+ echo "strace log: strace.out"
+ fi
+ echo
} | tee -a $BUILDLOG
# Set up no-network namespace. This isn't foolproof, there are probably
@@ -354,9 +354,9 @@ fi
# beloved moderators. Even though it's "no net", lots of stuff needs
# the loopback interface, and it doesn't hurt anything.
if [ "$NETWORK" = "no" ]; then
- touch $NONET_PATH
- unshare --net=$NONET_PATH ifconfig lo 127.0.0.1 up
- NSENTER="nsenter --net=$NONET_PATH"
+ touch $NONET_PATH
+ unshare --net=$NONET_PATH ifconfig lo 127.0.0.1 up
+ NSENTER="nsenter --net=$NONET_PATH"
fi
START_TIME="$( date +%s )"
@@ -381,7 +381,7 @@ else
echo "Private dir for overlay FS: $PRIVDIR" | tee -a $BUILDLOG
if [ "$STRACE" != "" ]; then
- PRECMD="strace -o $PRIVDIR/strace.out $STRACE"
+ PRECMD="strace -o $PRIVDIR/strace.out $STRACE"
fi
# Force-load the module (Slackware >= 15.0 ships the module at least)
@@ -417,8 +417,8 @@ END_TIME="$( date +%s )"
echo "$SCRIPT exit status: $RET" | tee -a $BUILDLOG
{
- echo -n "Elapsed time: "
- print_hms $(( $END_TIME - $START_TIME ))
+ echo -n "Elapsed time: "
+ print_hms $(( $END_TIME - $START_TIME ))
} | tee -a $BUILDLOG
cleanup_nonet
@@ -458,19 +458,19 @@ if [ ! -e /root/.sbrun_no_chroot ]; then
\! -path dev/shm \
\! -path $TMP \
\! -path $OUTPUT \
- -print0 | xargs -r0 ls -bld > $TURDS
+ -print0 | xargs -r0 ls -bld > $TURDS
) 2>/dev/null
if [ -f $PRIVDIR/strace.out ]; then
- mv $PRIVDIR/strace.out .
- chown --reference=$SCRIPT strace.out
+ mv $PRIVDIR/strace.out .
+ chown --reference=$SCRIPT strace.out
fi
cleanup_privdir
if [ -s $TURDS ]; then
- warn "WARNING: files altered outside the sandbox:"
- tee -a $BUILDLOG < $TURDS
+ warn "WARNING: files altered outside the sandbox:"
+ tee -a $BUILDLOG < $TURDS
fi
rm -f $TURDS
fi
@@ -478,21 +478,21 @@ fi
# If linting + installation were both requested, don't install
# the package if it fails to lint.
if [ "$LINTPKG" = "yes" ] && sbopkglint; then
- RET=$?
+ RET=$?
else
- UPKG=""
+ UPKG=""
fi
# spawn shell(s) if requested. -I and -p are not mutually exclusive.
# TODO: do this cleaner?
if [ "$SRCSH" = "yes" ]; then
- if [ "$RET" != "0" ]; then
- warn "Script failed (status $RET), ignoring -I option"
- else
- SRCDIR="$( /bin/ls -td $TMP/*/ | grep -v /package- | head -1 )"
- ( cd $SRCDIR && bash -login )
- fi
+ if [ "$RET" != "0" ]; then
+ warn "Script failed (status $RET), ignoring -I option"
+ else
+ SRCDIR="$( /bin/ls -td $TMP/*/ | grep -v /package- | head -1 )"
+ ( cd $SRCDIR && bash -login )
+ fi
fi
# PRGNAM is problematic. We don't want to use $( basename $( pwd ) )
@@ -502,13 +502,13 @@ fi
# won't work because I want to support passing a script name someday
# instead of hard-coding .SlackBuild.
if [ "$PKGSH" = "yes" ]; then
- PRGNAM="$( echo $SCRIPT | sed 's,^\./\(.*\)\.SlackBuild$,\1,' )"
- PKG=$TMP/package-$PRGNAM
- if [ -d "$PKG" ]; then
- ( cd $PKG && bash -login )
- else
- warn "$PKG not found, ignoring -p option"
- fi
+ PRGNAM="$( echo $SCRIPT | sed 's,^\./\(.*\)\.SlackBuild$,\1,' )"
+ PKG=$TMP/package-$PRGNAM
+ if [ -d "$PKG" ]; then
+ ( cd $PKG && bash -login )
+ else
+ warn "$PKG not found, ignoring -p option"
+ fi
fi
cleanup_build