From 6fb5284a9c04db7c0fd22becb1afa36fc99c283c Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 30 Nov 2026 08:35:46 -0500 Subject: sbrun: replace tab indents with 2 spaces each. --- sbrun | 256 +++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 128 insertions(+), 128 deletions(-) (limited to 'sbrun') 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 <&1 + fi + cat </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 <&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 -- cgit v1.2.3