From 3adfc0385e163f49b85f25ec534b218d00b6bed0 Mon Sep 17 00:00:00 2001 From: Jason Mehring Date: Mon, 27 Apr 2015 21:18:07 -0400 Subject: [PATCH] SYSTEMD_NSPAWN_ENABLE was missing from chroot if VERBOSE was < 2 - Added some more chroot wrapper function comments - changed "${@}" to ${1+"$@"} for better form in chroot function --- functions.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/functions.sh b/functions.sh index acc819f..e4c2d27 100755 --- a/functions.sh +++ b/functions.sh @@ -81,19 +81,28 @@ fi if [ "${VERBOSE}" -ge 2 -o "${DEBUG}" == "1" ]; then chroot() { + # Display `chroot` or `systemd-nspawn` in blue ONLY if VERBOSE >= 2 + # or DEBUG == "1" local retval true ${blue} + + # Need to capture exit code after running chroot or systemd-nspawn + # so it will be available as a return value if [ "${SYSTEMD_NSPAWN_ENABLE}" == "1" ]; then - systemd-nspawn $systemd_bind -D "${INSTALLDIR}" -M "${DIST}" "$@" && { retval=$?; true; } || { retval=$?; true; } + systemd-nspawn $systemd_bind -D "${INSTALLDIR}" -M "${DIST}" ${1+"$@"} && { retval=$?; true; } || { retval=$?; true; } else - /usr/sbin/chroot "${INSTALLDIR}" "$@" && { retval=$?; true; } || { retval=$?; true; } + /usr/sbin/chroot "${INSTALLDIR}" ${1+"$@"} && { retval=$?; true; } || { retval=$?; true; } fi true ${reset} return $retval } else chroot() { - /usr/sbin/chroot "${INSTALLDIR}" "$@" + if [ "${SYSTEMD_NSPAWN_ENABLE}" == "1" ]; then + systemd-nspawn $systemd_bind -D "${INSTALLDIR}" -M "${DIST}" ${1+"$@"} + else + /usr/sbin/chroot "${INSTALLDIR}" ${1+"$@"} + fi } fi