From eab80d912a70e64dd95218390dc1221f0792505a Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Sat, 26 Nov 2011 16:48:05 +0100 Subject: [PATCH] Add -T option for unpacking chroot archives --- docs/grml-live.txt | 5 +++++ grml-live | 28 ++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/docs/grml-live.txt b/docs/grml-live.txt index a525e6e..debc706 100644 --- a/docs/grml-live.txt +++ b/docs/grml-live.txt @@ -208,6 +208,11 @@ debootstrap. Specify place of the templates used for building the ISO. By default (and if not manually specified) this is /usr/share/grml-live/templates/. + -T **CHROOT_ARCHIVE**:: + +Unpack chroot tar archive before starting. Most useful in combination with +-A and -b or -u. + -u:: Update existing chroot instead of rebuilding it from scratch. This option is diff --git a/grml-live b/grml-live index 73ee61b..3c15497 100755 --- a/grml-live +++ b/grml-live @@ -59,6 +59,7 @@ Usage: $PN [options, see as follows] -r release name -s Debian suite; values: etch, lenny, squeeze, sid -t place of the templates + -T unpack chroot tar archive before starting -u update existing chroot instead of rebuilding it from scratch -U arrange output to be owned by specified username -v specify version number of the release @@ -298,7 +299,7 @@ fi # }}} # command line parsing {{{ -while getopts "a:C:c:d:D:g:i:I:o:r:s:t:U:v:AbBFnNquVz" opt; do +while getopts "a:C:c:d:D:g:i:I:o:r:s:t:T:U:v:AbBFnNquVz" opt; do case "$opt" in a) ARCH="$OPTARG" ;; A) PACK_ARTIFACTS=1 ;; @@ -318,6 +319,7 @@ while getopts "a:C:c:d:D:g:i:I:o:r:s:t:U:v:AbBFnNquVz" opt; do r) RELEASENAME="$OPTARG" ;; s) SUITE="$OPTARG" ;; t) TEMPLATE_DIRECTORY="$OPTARG";; + T) UNPACK_CHROOT="$(readlink -f $OPTARG)" ;; v) VERSION="$OPTARG" ;; F) FORCE=1 ;; u) UPDATE=1 ;; @@ -395,6 +397,7 @@ if [ -z "$FORCE" ] ; then [ -n "$CONFIG" ] && echo " Configuration: $CONFIG" [ -n "$GRML_FAI_CONFIG" ] && echo " Config directory: $GRML_FAI_CONFIG" echo " main directory: $OUTPUT" + [ -n "$UNPACK_CHROOT" ] && echo " Chroot from: $UNPACK_CHROOT" [ -n "$CHROOT_OUTPUT" ] && echo " Chroot target: $CHROOT_OUTPUT" [ -n "$BUILD_OUTPUT" ] && echo " Build target: $BUILD_OUTPUT" [ -n "$ISO_OUTPUT" ] && echo " ISO target: $ISO_OUTPUT" @@ -444,7 +447,6 @@ if [ -n "${PACK_ARTIFACTS}" ]; then [ -n "${BUILD_OUTPUT}" -a -d "${BUILD_OUTPUT}" ] && rm -r "${BUILD_OUTPUT}" [ -n "${ISO_OUTPUT}" -a -d "${ISO_OUTPUT}" ] && rm -r "${ISO_OUTPUT}" [ -n "${LOG_OUTPUT}" -a -d "${LOG_OUTPUT}" ] && rm -r "${LOG_OUTPUT}" - [ -n "${CHROOT_ARCHIVE}" -a -f "${CHROOT_ARCHIVE}" ] && rm "${CHROOT_ARCHIVE}" fi # }}} @@ -501,6 +503,28 @@ log "$CMDLINE" einfo "Logging actions to logfile $LOGFILE" # }}} +# unpack chroot {{{ +if [ -n "${UNPACK_CHROOT}" ]; then + log "Unpacking chroot from ${UNPACK_CHROOT}" + einfo "Unpacking chroot from ${UNPACK_CHROOT}" + [ -d "$CHROOT_OUTPUT" ] || mkdir -p "${CHROOT_OUTPUT}" + tar -xf "${UNPACK_CHROOT}" -C "${CHROOT_OUTPUT}/" --strip-components 1 | RC=$? + echo $RC + if [ "$RC" != 0 ] ; then + eend 1 + bailout 1 + fi + eend 0 +fi +# }}} + +# cleanup CHROOT_ARCHIVE now {{{ +if [ -n "${PACK_ARTIFACTS}" ]; then + # can't do this earlier, as UNPACK_CHROOT might point to CHROOT_ARCHIVE + [ -n "${CHROOT_ARCHIVE}" -a -f "${CHROOT_ARCHIVE}" ] && rm "${CHROOT_ARCHIVE}" +fi +# }}} + # on-the-fly configuration {{{ if [ -n "$FAI_DEBOOTSTRAP" ] ; then sed "s#^FAI_DEBOOTSTRAP=.*#FAI_DEBOOTSTRAP=\"$FAI_DEBOOTSTRAP\"#" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF" -- 2.1.4