Adjust configuration files on the fly only when the according lines aren't comments.
[grml-live.git] / grml-live
index 6beb3ba..f9ddd19 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -359,11 +359,11 @@ if [ -n "$SUITE" ] ; then
    esac
 
    DIST=" etch\| stable\| lenny\| squeeze\| testing\| sid\| unstable"
-   sed "s/\(deb .\+\)\([ \t]*\) $DIST\([ \t]*\)\(main \)/\1\2 $SUITE \3\4/" /etc/grml/fai/apt/sources.list | sponge /etc/grml/fai/apt/sources.list
+   sed "s/\(^deb .\+\)\([ \t]*\)\($DIST\)\([ \t]*\)\(main \)/\1 \2$SUITE \4\5/" /etc/grml/fai/apt/sources.list | sponge /etc/grml/fai/apt/sources.list
    for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
        if [ -n "$file" ] ; then
-          sed "s/SUITE=.*/SUITE=\"$SUITE\"/" $LIVE_CONF | sponge $LIVE_CONF
-          sed "s/\(deb .\+\)\([ \t]*\) $DIST\([ \t]*\)\(main \)/\1\2 $SUITE \3\4/" "$file" | sponge "$file"
+          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
 
@@ -379,11 +379,11 @@ if [ -n "$SUITE" ] ; then
 
    for file in "$LIVE_CONF" "$CONFIG" "$LOCAL_CONFIG" ; do
        if [ -n "$file" ] ; then
-          sed "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file" | sponge "$file"
+          sed "s|^FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$file" | sponge "$file"
        fi
    done
 
-   sed "s|FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
+   sed "s|^FAI_DEBOOTSTRAP=\"[a-z]* |FAI_DEBOOTSTRAP=\"$SUITE |" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
 fi
 
 # set $ARCH
@@ -391,7 +391,7 @@ fi
 if grep -q -- 'FAI_DEBOOTSTRAP_OPTS.*--arch' "$NFSROOT_CONF" ; then
    sed "s/--arch [a-z0-9]* /--arch $ARCH /" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
 else
-   sed "s|FAI_DEBOOTSTRAP_OPTS=\"\(.*\)|FAI_DEBOOTSTRAP_OPTS=\"--arch $ARCH \1|" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
+   sed "s|^FAI_DEBOOTSTRAP_OPTS=\"\(.*\)|FAI_DEBOOTSTRAP_OPTS=\"--arch $ARCH \1|" "$NFSROOT_CONF" | sponge "$NFSROOT_CONF"
 fi
 # }}}
 
@@ -541,7 +541,14 @@ if [ "$ARCH" = i386 ] || [ "$ARCH" = amd64 ] ; then
       cp ${TEMPLATE_DIRECTORY}/boot/isolinux/*  "$BUILD_OUTPUT"/boot/isolinux/
 
       if [ -z "$NO_ADDONS" ] ; then
-         cp ${TEMPLATE_DIRECTORY}/boot/addons/*    "$BUILD_OUTPUT"/boot/addons/
+         # copy only files so we can handle bsd4grml on its own
+         for file in ${TEMPLATE_DIRECTORY}/boot/addons/* ; do
+             test -f $file && cp $file "$BUILD_OUTPUT"/boot/addons/
+         done
+
+         if [ -z "$NO_ADDONS_BSD4GRML" ] ; then
+            cp -a ${TEMPLATE_DIRECTORY}/boot/addons/bsd4grml "$BUILD_OUTPUT"/boot/addons/
+         fi
       fi
 
       if ! [ -d "${BUILD_OUTPUT}/boot/grub" ] ; then
@@ -622,9 +629,9 @@ fi
 if [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -z "$UPDATE" -a -z "$BUILD_ONLY" -a -z "$BUILD_DIRTY" ] ; then
    log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'"
    ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs'" ; eend 0
-elif [ -f "$BUILD_OUTPUT"/live/${GRML_NAME}.squashfs -a -n "$SKIP_MKSQUASHFS" ] ; then
-   log "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs' as requested"
-   ewarn "$BUILD_OUTPUT/live exists already, skipping stage 'squashfs' as requested" ; eend 0
+elif [ -n "$SKIP_MKSQUASHFS" ] ; then
+   log "Skipping stage 'squashfs' as requested via option -q"
+   ewarn "Skipping stage 'squashfs' as requested via option -q" ; eend 0
 else
    [ -d "$BUILD_OUTPUT"/live ] || mkdir "$BUILD_OUTPUT"/live
    # make sure we don't leave (even an empty) base.tgz: