X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=grml-live;h=3c1549789baf2da0881e34d6ba12b1b097532c0e;hb=be73298f82e780a3e523756a96f67651f499c310;hp=8ec8348c1a769cc94b57649ef37f721265238d93;hpb=809f9a69adff4b7f2fc923e56b06f754d857e27d;p=grml-live.git diff --git a/grml-live b/grml-live index 8ec8348..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 @@ -151,7 +152,7 @@ umount_all() { # certain FAI versions sadly leave a ramdisk behind, so better safe than sorry if [ -x /usr/lib/fai/mkramdisk ] ; then - /usr/lib/fai/mkramdisk -u "$(realpath ${CHROOT_OUTPUT}/var/lib/dpkg)" >/dev/null 2>&1 || /bin/true + /usr/lib/fai/mkramdisk -u "$(readlink -f ${CHROOT_OUTPUT}/var/lib/dpkg)" >/dev/null 2>&1 || /bin/true fi umount "${CHROOT_OUTPUT}/grml-live/sources/" 2>/dev/null || /bin/true @@ -196,7 +197,7 @@ trap umount_all EXIT # log output: # usage: log "string to log" -log() { echo "$*" >> $LOGFILE ; } +log() { [ -n "$LOGFILE" ] && echo "$*" >> $LOGFILE ; } # cut string at character number int = $1 # usage: cut_string 5 "1234567890" will output "12345" @@ -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 ;; @@ -333,7 +335,7 @@ shift $(($OPTIND - 1)) # set ARGV to the first not parsed commandline parameter # assume sane defaults (if not set already) {{{ [ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)" [ -n "$BOOT_METHOD" ] || BOOT_METHOD='isolinux' -[ -n "$CLASSES" ] || CLASSES="GRMLBASE,GRML_MEDIUM,$(echo ${ARCH} | tr 'a-z' 'A-Z')" +[ -n "$CLASSES" ] || CLASSES="GRMLBASE,GRML_FULL,$(echo ${ARCH} | tr 'a-z' 'A-Z')" [ -n "$DATE" ] || DATE="$(date +%Y-%m-%d)" [ -n "$DISTRI_INFO" ] || DISTRI_INFO='Grml - Live Linux for system administrators ' [ -n "$DISTRI_NAME" ] || DISTRI_NAME="grml" @@ -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" @@ -631,18 +655,18 @@ else # move fai logs into grml_logs directory mkdir -p "$LOG_OUTPUT"/fai/ cp -r "$CHROOT_OUTPUT"/var/log/fai/"$HOSTNAME"/last/* "$LOG_OUTPUT"/fai/ + rm -rf "$CHROOT_OUTPUT"/var/log/fai + # copy fai package list + cp "$CHROOT_OUTPUT"/var/log/install_packages.list "$LOG_OUTPUT"/fai/ + # fixup owners chown root:adm "$LOG_OUTPUT"/fai/* chmod 664 "$LOG_OUTPUT"/fai/* - rm -rf "$CHROOT_OUTPUT"/var/log/fai - - # Remove all FAI logs from chroot if class RELEASE is used: - rm -f "$CHROOT_OUTPUT"/var/log/install_packages.list umount_all # notice: 'fai dirinstall' does not seem to exit appropriate, so: ERROR='' - CHECKLOG=/var/log/fai/$HOSTNAME/last + CHECKLOG="$LOG_OUTPUT"/fai/ if [ -r "$CHECKLOG/software.log" ] ; then # 1 errors during executing of commands grep 'dpkg: error processing' $CHECKLOG/software.log >> $LOGFILE && ERROR=1 @@ -666,10 +690,6 @@ else log "Finished execution of stage 'fai dirinstall' [$(date)]" einfo "Finished execution of stage 'fai dirinstall'" fi - - einfo "Find FAI build logs at $(readlink -f /var/log/fai/$HOSTNAME/last)" - log "Find FAI build logs at $(readlink -f /var/log/fai/$HOSTNAME/last)" - eend 0 fi fi # BUILD_DIRTY? # }}}