diff options
author | Adrian Schröter <adrian@suse.de> | 2019-11-28 09:37:33 +0100 |
---|---|---|
committer | Adrian Schröter <adrian@suse.de> | 2019-11-28 10:28:09 +0100 |
commit | 6d5cf3aa0b8a7cabc50e091c444b8ed4c73dc1ba (patch) | |
tree | b05ab3e906417f744cdcc00219b4383215c0c551 | |
parent | 8eea00adf2117109281f8e2a6705fd9a0f8f5e92 (diff) |
implement --shell-cmd "CMD" option
also justify code to have only one place to run the shell or command
-rwxr-xr-x | build | 23 | ||||
-rw-r--r-- | build-vm | 8 |
2 files changed, 22 insertions, 9 deletions
@@ -104,6 +104,7 @@ RSYNCDONE= SIGNDUMMY= DO_STATISTICS= RUN_SHELL= +RUN_SHELL_CMD= CCACHE= DLNOSIGNATURE= BUILD_FLAVOR= @@ -163,6 +164,10 @@ Known Parameters: --shell Instead of starting a build start a root shell in the build root. + --shell-cmd CMD + Run the command CMD instead of giving a root shell + --shell option is implicit set. + --sysrq $ Sends a single specifed char as sysrq to the running kernel of the build. @@ -1019,6 +1024,12 @@ while test -n "$1"; do RUN_SHELL=1 shift ;; + -shell-cmd) + needarg + RUN_SHELL=1 + RUN_SHELL_CMD="$ARG" + shift + ;; -signdummy) SIGNDUMMY=1 ;; @@ -1383,10 +1394,14 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do setupccache if test -n "$RUN_SHELL" ; then - echo "You may want to initialize environment via:" - echo " su - $BUILD_USER" - chroot $BUILD_ROOT - cleanup_and_exit 0 + if test -z "$RUN_SHELL_CMD" ; then + echo "" + echo "You may want to initialize environment via:" + echo " su - $BUILD_USER" + echo "" + fi + chroot $BUILD_ROOT "${RUN_SHELL_CMD:=/bin/bash}" + cleanup_and_exit $? fi # fill build directories with sources. Also sets TOPDIR @@ -863,6 +863,7 @@ vm_first_stage() { echo ")" >> $BUILD_ROOT/.build/build.data echo "VM_TYPE='$VM_TYPE'" >> $BUILD_ROOT/.build/build.data echo "RUN_SHELL='$RUN_SHELL'" >> $BUILD_ROOT/.build/build.data + echo "RUN_SHELL_CMD='$RUN_SHELL_CMD'" >> $BUILD_ROOT/.build/build.data echo "DO_STATISTICS='$DO_STATISTICS'" >> $BUILD_ROOT/.build/build.data echo "TIME_PREINSTALL='$TIME_PREINSTALL'" >> $BUILD_ROOT/.build/build.data echo "VM_WATCHDOG='$VM_WATCHDOG'" >> $BUILD_ROOT/.build/build.data @@ -881,11 +882,8 @@ vm_first_stage() { umount -n $BUILD_ROOT/mnt 2> /dev/null || true vm_init_script="/.build/build" - if test -n "$RUN_SHELL"; then - vm_init_script="/bin/bash" - fi if check_use_emulator ; then - vm_init_script="/.build/$INITVM_NAME" + vm_init_script="/.build/$INITVM_NAME" fi if test -n "$VM_ROOT" ; then # copy out kernel & initrd (if they exist) during unmounting VM image @@ -936,7 +934,7 @@ vm_first_stage() { fi vm_attach_root - if test -n "$VM_SWAP" ; then + if test -n "$VM_SWAP" -a -z "$RUN_SHELL" ; then vm_attach_swap BUILDSTATUS=$(dd if="$VM_SWAP" bs=12 count=1 2>/dev/null | tr '\0' a) case $BUILDSTATUS in |