Support use of local mirror (like NFS) through mount bind
authorMichael Prokop <devnull@localhost>
Tue, 18 Sep 2007 19:23:19 +0000 (21:23 +0200)
committerMichael Prokop <devnull@localhost>
Tue, 18 Sep 2007 19:23:19 +0000 (21:23 +0200)
etc/grml/grml-live.conf
grml-live

index 1c776e6..4c67f87 100644 (file)
@@ -3,7 +3,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2 or any later version.
-# Latest change: Tue Sep 18 09:31:39 CEST 2007 [mika]
+# Latest change: Tue Sep 18 20:32:37 CEST 2007 [mika]
 ################################################################################
 
 # main output directory
@@ -49,6 +49,12 @@ CLASSES="GRMLBASE,I386"
 # Usage: <flavour> <mirror>
 # FAI_DEBOOTSTRAP="etch http://ftp.de.debian.org/debian"
 
+# Do you want to use a local mirror (like NFS) as well?
+# If so specify the directory where debian/ is available:
+# MIRROR_DIRECTORY="/mnt/mirror"
+# ... and the sources.list entry for the directory:
+# MIRROR_SOURCES="deb file:///mnt/mirror/debian sid main contrib non-free"
+
 # directory of configuration files for grml-live's FAI:
 GRML_FAI_CONFIG=/etc/grml/fai
 
index 91a929d..ec336c2 100755 (executable)
--- a/grml-live
+++ b/grml-live
@@ -4,7 +4,7 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2 or any later version.
-# Latest change: Tue Sep 18 19:29:33 CEST 2007 [mika]
+# Latest change: Tue Sep 18 20:32:35 CEST 2007 [mika]
 ################################################################################
 
 # read configuration files, set some misc variables {{{
@@ -36,6 +36,7 @@ PN=$(basename $0)
 # clean exit {{{
 bailout() {
   # rm -f "$TMPFILE"
+  [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_TARGET}/${MIRROR_DIRECTORY}"
   [ -n "$1" ] && EXIT="$1" || EXIT="1"
   [ -n "$2" ] && echo "$2">&2
   exit "$EXIT"
@@ -129,7 +130,16 @@ fi
 # }}}
 
 # on-the-fly configuration {{{
-if [ -n "$GRML_LIVE_SOURCES" ] ; then
+if [ -n "$MIRROR_DIRECTORY" ] ; then
+   if ! [ -d "$MIRROR_DIRECTORY/debian" ] ; then
+      echo "Sorry, $MIRROR_DIRECTORY/debian does not seem to exist. Exiting.">&2
+      bailout 1
+   fi
+   echo "$MIRROR_SOURCES" > /etc/grml/fai/apt/sources.list
+   if [ -n "$GRML_LIVE_SOURCES" ] ; then
+      echo "$GRML_LIVE_SOURCES" >> /etc/grml/fai/apt/sources.list
+   fi
+elif [ -n "$GRML_LIVE_SOURCES" ] ; then
    echo "$GRML_LIVE_SOURCES" > /etc/grml/fai/apt/sources.list
 fi
 
@@ -158,9 +168,14 @@ if [ -d "$CHROOT_TARGET" ] ; then
    echo "  [x] $CHROOT_TARGET exists already, skipping the stage 'fai dirnstall'"
 else
    mkdir -p "$CHROOT_TARGET" || bailout 5 "Problem with creating $CHROOT_TARGET for FAI"
+   if [ -n "${MIRROR_DIRECTORY}" ] ; then
+      mkdir -p "${CHROOT_TARGET}/${MIRROR_DIRECTORY}"
+      mount --bind "${MIRROR_DIRECTORY}" "${CHROOT_TARGET}/${MIRROR_DIRECTORY}"
+   fi
    fai $VERBOSE -C "$GRML_FAI_CONFIG" -c"$CLASSES" dirinstall "$CHROOT_TARGET" $FAI_ARGS
    umount $CHROOT_TARGET/proc 2>/dev/null || /bin/true
    umount $CHROOT_TARGET/sys  2>/dev/null || /bin/true
+   [ -n "$MIRROR_DIRECTORY" ] && umount "${CHROOT_TARGET}/${MIRROR_DIRECTORY}"
    # notice: 'fai dirinstall' does not seem to exit appropriate ->
    # we need better error handling
    if [ -r "$CHROOT_TARGET"/etc/grml_cd ] ; then