X-Git-Url: https://git.grml.org/?p=grml-live.git;a=blobdiff_plain;f=grml-live;h=ce61ca7338a54cf1a3fbca02e3481198ab01fc9e;hp=dc36d244cdcc0d236cff986667c49b26e394c8c2;hb=e265e3093a98d723d40b36dde1aba26146aa301f;hpb=5eabf98c5e2bcb6a2a1ad5da385253acca03cdcd diff --git a/grml-live b/grml-live index dc36d24..ce61ca7 100755 --- a/grml-live +++ b/grml-live @@ -8,26 +8,27 @@ # License: This file is licensed under the GPL v2 or any later version. ################################################################################ -# read configuration files, set some misc variables {{{ - +# some misc and global stuff {{{ export LANG=C export LC_ALL=C # define function getfilesize before "set -e" if stat --help >/dev/null 2>&1; then - getfilesize='stat -c %s' # GNU stat + getfilesize='stat -c %s' # GNU stat else - getfilesize='stat -f %z' # BSD stat + getfilesize='stat -f %z' # BSD stat fi # exit on any error: set -e -GRML_LIVE_VERSION='0.9.20' +# global variables +GRML_LIVE_VERSION='0.9.21' PN="$(basename $0)" CMDLINE="$0 $@" ISO_DATE="$(date +%Y-%m-%d)" SOURCES_LIST_FILE='/etc/grml/fai/apt/sources.list' +# }}} # usage information {{{ usage() @@ -81,6 +82,7 @@ if [ "$1" = '-h' -o "$1" = '--help' ] ; then fi # }}} +# some runtime checks {{{ # we need root permissions for the build-process: if [ "$(id -u 2>/dev/null)" != 0 ] ; then echo "Error: please run this script with uid 0 (root)." >&2 @@ -99,7 +101,9 @@ if [ -r /var/run/fai/fai_softupdate_is_running ] ; then echo "You may remove /var/run/fai/fai_softupdate_is_running and try again.">&2 exit 1 fi +# }}} +# lsb-functions and configuration stuff {{{ # make sure they are not set by default VERBOSE='' FORCE='' @@ -120,7 +124,6 @@ fi # source main configuration file: LIVE_CONF=/etc/grml/grml-live.conf . $LIVE_CONF - # }}} # clean exit {{{ @@ -136,28 +139,11 @@ bailout() { trap bailout 1 2 3 3 6 9 14 15 # }}} -# check for important variables {{{ -[ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG=/etc/grml/fai -[ -n "$HOSTNAME" ] || HOSTNAME=grml -[ -n "$USERNAME" ] || USERNAME=grml -[ -n "$CLASSES" ] || CLASSES="GRML,I386" -[ -n "$BOOT_METHOD" ] || BOOT_METHOD='isolinux' -[ -n "$OUTPUT" ] || bailout 1 "${PN}: \$OUTPUT not specified. Please adjust $LIVE_CONF. Exiting." - -[ -n "$VERSION" ] || VERSION="0.0.1" -[ -n "$RELEASENAME" ] || RELEASENAME="grml-live rocks" -[ -n "$GRML_NAME" ] || GRML_NAME='grml' - -# logfile: -if [ -z "$LOGFILE" ] ; then - LOGFILE=/var/log/grml-live.log -fi +# log file stuff {{{ +[ -n "$LOGFILE" ] || LOGFILE=/var/log/grml-live.log touch $LOGFILE chown root:adm $LOGFILE chmod 664 $LOGFILE - -NFSROOT_CONF=/etc/grml/fai/make-fai-nfsroot.conf - # }}} # some important functions {{{ @@ -246,6 +232,23 @@ done 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='GRML,I386' +[ -n "$DISTRI_INFO" ] || DISTRI_INFO='Grml - Live Linux for system administrators ' +[ -n "$DISTRI_NAME" ] || DISTRI_NAME="grml" +[ -n "$DISTRI_SPLASH" ] || DISTRI_SPLASH='grml.png' +[ -n "$GRML_FAI_CONFIG" ] || GRML_FAI_CONFIG='/etc/grml/fai' +[ -n "$GRML_NAME" ] || GRML_NAME='grml' +[ -n "$HOSTNAME" ] || HOSTNAME='grml' +[ -n "$NFSROOT_CONF" ] || NFSROOT_CONF='/etc/grml/fai/make-fai-nfsroot.conf' +[ -n "$RELEASENAME" ] || RELEASENAME='grml-live rocks' +[ -n "$SUITE" ] || SUITE='stable' +[ -n "$USERNAME" ] || USERNAME='grml' +[ -n "$VERSION" ] || VERSION='0.0.1' +# }}} + # some misc checks before executing FAI {{{ [ -n "$CLASSES" ] || bailout 1 "Error: \$CLASSES unset, please set it in $LIVE_CONF or specify it on the command line using the -c option." @@ -374,48 +377,45 @@ if [ -n "$FAI_DEBOOTSTRAP" ] ; then fi # does this suck? YES! -if [ -n "$SUITE" ] ; then - - # /usr/share/debootstrap/scripts/unstable does not exist, instead use 'sid': - case $SUITE in - unstable) SUITE='sid' ;; - # make sure that we *NEVER* write any broken suite name to sources.list, - # otherwise we won't be able to adjust it one next (correct) execution - stable) ;; - testing) ;; - etch) ;; - lenny) ;; - squeeze) ;; - sid) ;; - *) echo "Sorry, $SUITE is not a valid Debian suite, exiting.">&2; bailout 1 ;; - esac - - DIST=" etch\| stable\| lenny\| squeeze\| testing\| sid\| unstable" - sed "s/\(^deb .\+\)\([ \t]*\)\($DIST\)\([ \t]*\)\(main \)/\1 \2$SUITE\4\5/" "$SOURCES_LIST_FILE" | sponge "$SOURCES_LIST_FILE" - for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do - if [ -n "$file" ] ; then - sed "s/^SUITE=.*/SUITE=\"$SUITE\"/" $file | sponge $file - sed "s/\(^deb .\+\)\([ \t]*\)\($DIST\)\([ \t]*\)\(main \)/\1 \2$SUITE\4\5/" "$file" | sponge "$file" - fi - done - - # notice: activate grml-live pool only if we are building against unstable: - if grep -qe unstable -qe sid "$SOURCES_LIST_FILE" ; then - grep -q 'grml-live.*main' "$SOURCES_LIST_FILE" || \ - grep grml-stable "$SOURCES_LIST_FILE" | \ - sed 's/grml-stable/grml-live/' >> "$SOURCES_LIST_FILE" - else - grep -q 'grml-live.*main' "$SOURCES_LIST_FILE" && \ - sed 's/.*grml-live.*/# removed grml-live repository/' "$SOURCES_LIST_FILE" | sponge "$SOURCES_LIST_FILE" - fi +# /usr/share/debootstrap/scripts/unstable does not exist, instead use 'sid': +case $SUITE in + unstable) SUITE='sid' ;; + # make sure that we *NEVER* write any broken suite name to sources.list, + # otherwise we won't be able to adjust it one next (correct) execution + stable) ;; + testing) ;; + etch) ;; + lenny) ;; + squeeze) ;; + sid) ;; + *) echo "Sorry, $SUITE is not a valid Debian suite, exiting.">&2; bailout 1 ;; +esac + +DIST=" etch\| stable\| lenny\| squeeze\| testing\| sid\| unstable" +sed "s/\(^deb .\+\)\([ \t]*\)\($DIST\)\([ \t]*\)\(main \)/\1 \2$SUITE\4\5/" "$SOURCES_LIST_FILE" | sponge "$SOURCES_LIST_FILE" +for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do + if [ -n "$file" ] ; then + sed "s/^SUITE=.*/SUITE=\"$SUITE\"/" $file | sponge $file + sed "s/\(^deb .\+\)\([ \t]*\)\($DIST\)\([ \t]*\)\(main \)/\1 \2$SUITE\4\5/" "$file" | sponge "$file" + fi +done - for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" "$NFSROOT_CONF" ; do - if [ -n "$file" ] ; then - sed "s|^FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file" | sponge "$file" - fi - done +# notice: activate grml-live pool only if we are building against unstable: +if grep -qe unstable -qe sid "$SOURCES_LIST_FILE" ; then + grep -q 'grml-live.*main' "$SOURCES_LIST_FILE" || \ + grep grml-stable "$SOURCES_LIST_FILE" | \ + sed 's/grml-stable/grml-live/' >> "$SOURCES_LIST_FILE" +else + grep -q 'grml-live.*main' "$SOURCES_LIST_FILE" && \ + sed 's/.*grml-live.*/# removed grml-live repository/' "$SOURCES_LIST_FILE" | sponge "$SOURCES_LIST_FILE" fi +for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" "$NFSROOT_CONF" ; do + if [ -n "$file" ] ; then + sed "s|^FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file" | sponge "$file" + fi +done + # validate whether the specified architecture class matches the # architecture (option), otherwise installation of kernel will fail if echo $CLASSES | grep -qi i386 ; then @@ -432,8 +432,6 @@ elif echo $CLASSES | grep -qi amd64 ; then fi fi -# set $ARCH -[ -n "$ARCH" ] || ARCH="$(dpkg --print-architecture)" if grep -q -- 'FAI_DEBOOTSTRAP_OPTS.*--arch' "$NFSROOT_CONF" ; then sed "s/--arch [a-z0-9]* /--arch $ARCH /" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF" else @@ -448,6 +446,7 @@ else [ -n "$CHROOT_OUTPUT" ] || CHROOT_OUTPUT="$OUTPUT/grml_chroot" # provide inform fai about the ISO we build + [ -d "$CHROOT_OUTPUT/etc/" ] || mkdir -p "$CHROOT_OUTPUT/etc/" echo '# This file has been generated by grml-live.' > "$CHROOT_OUTPUT/etc/grml_live_version" [ -n "$GRML_LIVE_VERSION" ] && echo "GRML_LIVE_VERSION=$GRML_LIVE_VERSION" >> "$CHROOT_OUTPUT/etc/grml_live_version" [ -n "$SUITE" ] && echo "SUITE=$SUITE" >> "$CHROOT_OUTPUT/etc/grml_live_version" @@ -548,9 +547,9 @@ mkdir -p "$BUILD_OUTPUT" || bailout 6 "Problem with creating $BUILD_OUTPUT for s # i386: if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then - if [ -d "$BUILD_OUTPUT"/boot -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then - log "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'" - ewarn "$BUILD_OUTPUT/boot exists already, skipping stage 'boot'" ; eend 0 + if [ -d "$BUILD_OUTPUT"/boot/isolinux -a -z "$UPDATE" -a -z "$BUILD_ONLY" ] ; then + log "$BUILD_OUTPUT/boot/isolinux exists already, skipping stage 'boot'" + ewarn "$BUILD_OUTPUT/boot/isolinux exists already, skipping stage 'boot'" ; eend 0 else # booting stuff: [ -d "$BUILD_OUTPUT"/boot/isolinux ] || mkdir -p "$BUILD_OUTPUT"/boot/isolinux @@ -645,6 +644,13 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then sed -i "s/%VERSION%/$VERSION/" "$BUILD_OUTPUT"/boot/grub/grub.cfg sed -i "s/%GRML_NAME%/$SHORT_GRML_NAME/" "$BUILD_OUTPUT"/boot/grub/grub.cfg + sed -i "s/%VERSION%/$VERSION/" "$BUILD_OUTPUT"/boot/isolinux/grml.cfg + sed -i "s/%GRML_NAME%/$GRML_NAME/" "$BUILD_OUTPUT"/boot/isolinux/grml.cfg + sed -i "s/%ARCH%/$ARCH/" "$BUILD_OUTPUT"/boot/isolinux/grml.cfg + + sed -i "s/%DISTRI_INFO%/$DISTRI_INFO/" "$BUILD_OUTPUT"/boot/isolinux/vesamenu.cfg + sed -i "s/%DISTRI_SPLASH%/$DISTRI_SPLASH/" "$BUILD_OUTPUT"/boot/isolinux/vesamenu.cfg + # make sure the squashfs filename is set accordingly: GRML_NAME_SQUASHFS="$GRML_NAME.squashfs" sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/isolinux.cfg @@ -656,6 +662,47 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f4 sed -i "s/%GRML_NAME_SQUASHFS%/$GRML_NAME_SQUASHFS/" "$BUILD_OUTPUT"/boot/isolinux/f5 + if ! [ -r "${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg" ] ; then + log "including grml.cfg in ${BUILD_OUTPUT}/boot/isolinux/distri.cfg" + echo "include grml.cfg" > "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" + [ -n "$NO_ADDONS" ] || echo "include addons.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" + else # assume we are building a custom distribution: + log "File ${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg found, using it." + einfo "File ${BUILD_OUTPUT}/boot/isolinux/${DISTRI_NAME}.cfg found, using it." + if grep -q "^include ${DISTRI_NAME}.cfg" "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" ; then + log "include for ${DISTRI_NAME}.cfg already present, nothing to do." + einfo "include for ${DISTRI_NAME}.cfg already present, nothing to do." + eend $? + else + log "including ${DISTRI_NAME}.cfg in ${BUILD_OUTPUT}/boot/isolinux/distri.cfg" + echo "include ${DISTRI_NAME}.cfg" > "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" + [ -n "$NO_ADDONS" ] || echo "include addons.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" + fi + fi + + # use old style console based isolinux method only if requested: + if [[ "${ISOLINUX_METHOD}" == "console" ]] ; then + log 'Using console based isolinux method as requested via $ISOLINUX_METHOD.' + einfo 'Using console based isolinux method as requested via $ISOLINUX_METHOD.' + if grep -q '^include console.cfg' "${BUILD_OUTPUT}/boot/isolinux/distri.cfg" ; then + einfo "include for console.cfg already foud, nothing to do." + eend 0 + else + log "including console.cfg in ${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg" + einfo "including console.cfg in ${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg" + echo "include console.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg" + eend $? + fi + else + log 'Using graphical boot menu.' + if grep -q '^include vesamenu.cfg' "${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg" ; then + log "include for vesamenu.cfg already foud, nothing to do." + else + log "including vesamenu.cfg in ${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg" + echo "include vesamenu.cfg" >> "${BUILD_OUTPUT}/boot/isolinux/isolinux.cfg" + fi + fi + # jump back to grub from bsd4grml: if [ -e "$BUILD_OUTPUT"/boot/addons/bsd4grml/boot.6 ]; then if [ -e "$BUILD_OUTPUT"/boot/grub/core.img ]; then @@ -812,8 +859,8 @@ else # pad the output ISO to multiples of 256 KiB for partition table support siz=$($getfilesize "${ISO_OUTPUT}/${ISO_NAME}") - cyls=$((siz / 512 / 32 / 16 + 1)) # C=$cyls H=16 S=32 - siz=$((cyls * 16 * 32 * 512)) # size after padding + cyls=$((siz / 512 / 32 / 16 + 1)) # C=$cyls H=16 S=32 + siz=$((cyls * 16 * 32 * 512)) # size after padding dd if=/dev/zero bs=1 count=1 seek=$((siz - 1)) \ of="${ISO_OUTPUT}/${ISO_NAME}" 2>/dev/null