[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

patch to simple-cdd-0.3.5/tools/build/debian-cd



Hi Vagrant,

Sorry, but it would be troublesome to reconstruct some of the changes
because once I've solved my problems, I go back to the distributed version
of things.  I don't want to diverge :).  This patch represents some work I did
because I needed to figure out how to edit isolinux.cfg.  So, actually, I
will need to keep the changes to the "debian-cd" script.  Hopefully, you will
be more disposed to incorporate the stuff.  Attached is a patch against
the current release.  "build-simple-cdd" has some debugability tweaks and
tools/build/debian-cd has some needed functionality.  The patch is annotated.

Thanks! - Bruce
##--- build-simple-cdd	2007-09-17 01:21:30 +0000
### -5,8 +5,18 @@
#Add "die" function.
#Let "get_help" emit any message to stderr
#
### -33,11 +43,13 @@
#Let "get_help" exit (zero for usage request, else non-zero)
#
#In option parsing loop, save option to "opt" so the current option name
#can be remembered when argument taking option code shift it off.
#The loop condition also needs to be "if there are more arguments"
#and not "if the current first argument is empty".
#
### -45,50 +57,47 @@
#If "$1" is not empty, then the test ``test -n "$1"'' cannot possibly fail.
#Remove the test and just do the shift.
#At the end of the case statement, the shift may fail if an argument
#taking option does not have an argument.  "die" if you cannot shift
#instead of testing for a non-zero-length option argument.
#
### -228,7 +235,10 @@
### -379,7 +389,10 @@
### -456,14 +469,20 @@
#All three:  Set "PS4" to something related to the file being processed
#so that when command tracing is turned on (``set -x''), you can tell
#which file the command is coming from.
#
##--- tools/build/debian-cd	2007-03-30 22:21:46 +0000
### -1,16 +1,14 @@
#There is no need for a "cache" file.  Reorder the "for p in" loops.
#
### -34,12 +32,19 @@
#$use_serial_console $serial_console_speed and $BOOT_TIMEOUT are nice and
#all, but it is hard to parameterize everything.  Some "build-simple-cdd"
#clients just need more control over the isolinux.cfg file.  Therefore,
#test for the existence of a function named "edit_isolinuxcfg".  If it
#exists, invoke it.

=== modified file 'build-simple-cdd'
--- build-simple-cdd	2007-09-17 01:21:30 +0000
+++ build-simple-cdd	2007-10-26 15:51:11 +0000
@@ -5,8 +5,18 @@
 
 # FIXME: call with LANG=C for parts that need it
 
+die() {
+  exec 1>&2
+  echo "build-simple-cdd error: $*"
+  exit 1
+}
+
 get_help() {
-cat<<EOF
+  test $# -gt 0 && {
+    exec 1>&2
+    echo "build-simple-cdd usage error:  $*"
+  }
+  cat<<EOF
 simple-cdd - create custom debian-installer CDs
 
 Usage:
@@ -33,11 +43,13 @@
 --profiles-udeb-dist  pull simple-cdd-profiles udeb from other distribution
 --extra-udeb-dist  also pull in udebs from specified distribution
 EOF
+  exit $#
 }
 
 commandline_opts="$@"
 while [ -n "$1" ]; do
-  case "$1" in
+  opt=${1}
+  case "${opt}" in
     --conf)
       if [ -f "$2" ]; then
             . "$2"
@@ -45,50 +57,47 @@
             echo "ERROR: simple-cdd configuration file not found: $2"
             exit 1
       fi
-      test -n "$1" && shift ;;
+      shift ;;
     --dist) export CODENAME="$2"
-      test -n "$1" && shift ;;
+      shift ;;
     -g|--g|--graphical-installer) export ISOLINUX_DEFAULT="installgui" ;;
     --serial-console|-s) use_serial_console="true" ;;
     --do-mirror) do_mirror="true" ;;
     --no-do-mirror) do_mirror="false" ;;
     --profiles|-p) profiles="$2" 
-      test -n "$1" && shift ;;
+      shift ;;
     --build-profiles|-b) build_profiles="$2" 
-      test -n "$1" && shift ;;
+      shift ;;
     --auto-profiles|-a) auto_profiles="$2" 
-      test -n "$1" && shift ;;
+      shift ;;
     --local-packages) local_packages="$2" 
-      test -n "$1" && shift ;;
+      shift ;;
     --locale) locale="$2" 
-      test -n "$1" && shift ;;
+      shift ;;
     --keyboard) keyboard="$2"
-      test -n "$1" && shift ;;
+      shift ;;
     --debian-mirror) debian_mirror="$2" 
-      test -n "$1" && shift ;;
+      shift ;;
     --security-mirror) security_mirror="$2" 
-      test -n "$1" && shift ;;
+      shift ;;
     --proposed-updates) proposed_updates="true" 
-      test -n "$1" && shift ;;
+      shift ;;
     --mirror-tools) mirror_tools="$2"
-      test -n "$1" && shift ;;
+      shift ;;
     --build-tools) build_tools="$2"
-      test -n "$1" && shift ;;
+      shift ;;
     --kernel-packages) kernel_packages="$2"
-      test -n "$1" && shift ;;
-    --help|-h) get_help 
-      exit 0 ;;
+      shift ;;
+    --help|-h) get_help ;;
     --qemu|-q) use_qemu="true" ;;
     --force-preseed) force_preseed="true" ;;
     --profiles-udeb-dist) profiles_udeb_dist="$2"
-      test -n "$1" && shift ;;
+      shift ;;
     --extra-udeb-dist) extra_udeb_dist="$2"
-      test -n "$1" && shift ;;
-    *) echo "ERROR: unknown commandline option: $1" 
-      get_help
-      exit 1 ;;
+      shift ;;
+    *) get_help "ERROR: unknown commandline option: $1" ;;
   esac
-  test -n "$1" && shift
+  shift || die "no argument found for ${opt} option"
 done
 
 # turn comma-separated list into whitespace-separated list
@@ -228,7 +235,10 @@
   file="$(find_files profiles/$p.conf)"
   if [ -f "$file" ]; then
     echo "including configuration values for: $file"
+    svps4=${PS4}
+    PS4=">$(basename ${file})> "
     . "$file"
+    PS4=${svps4}
   fi
 done
 }
@@ -379,7 +389,10 @@
     for tool in $mirror_tools ; do
         file="$(find_files tools/mirror/$tool)"
         if [ -f "$file" ]; then
+            svps4=${PS4}
+            PS4=">$(basename ${file})> "
             . "$file"
+            PS4=${svps4}
         fi
     done
 fi
@@ -456,14 +469,20 @@
 for buildtool in $build_tools ; do
     file="$(find_files tools/build/$buildtool)"
     if [ -f "$file" ]; then
+        svps4=${PS4}
+        PS4=">$(basename ${file})> "
         . "$file"
+        PS4=${svps4}
     fi
 done
 
 if [ "true" = "$use_qemu" ]; then
   file="$(find_files tools/testing/qemu)"
   if [ -f "$file" ] ; then
+    svps4=${PS4}
+    PS4=">$(basename ${file})> "
     . "$file"
+    PS4=${svps4}
   else
     echo "Warning: unable to find qemu testing script"
   fi

=== modified file 'tools/build/debian-cd'
--- tools/build/debian-cd	2007-03-30 22:21:46 +0000
+++ tools/build/debian-cd	2007-10-25 22:34:38 +0000
@@ -1,16 +1,14 @@
+#= -*- Mode: shell-script -*-
+
 export PATH="$debian_cd_dir/tools:$PATH"
 
-test -r "$TASK.cache" && mv -f $TASK.cache $TASK.cache.bak
-for p in $all_packages ; do
-  echo $p >> $TASK.cache
-done
-
 test -r "$TASK" && mv -f $TASK $TASK.bak
 for i in $includes ; do
-  echo '#include <'"$i"'>' >> $TASK
-done
-
-sort -u $TASK.cache >> $TASK
+  echo '#include <'"$i"'>'
+done > $TASK
+for p in $all_packages ; do
+  echo $p
+done | sort -u >> $TASK
 
 # copy debian-cd files into working dir
 rsync --delete -aWHr $debian_cd_dir/. $BASEDIR/
@@ -34,12 +32,19 @@
 
 isolinuxcfg="$TDIR/$CODENAME/boot1/isolinux/isolinux.cfg"
 if [ -f "$isolinuxcfg" ]; then
+    : configure isolinux.cfg
     if [ "true" = "$use_serial_console" ] && [ -n "$serial_console_speed" ]; then
         echo "SERIAL 0 $serial_console_speed 0" >> $isolinuxcfg
     fi
+
     if [ -n "$BOOT_TIMEOUT" ]; then
         sed -ie "s,TIMEOUT.*,TIMEOUT $BOOT_TIMEOUT,g" $isolinuxcfg
     fi
+
+    case $(type edit_isolinuxcfg 2>/dev/null) in
+    'edit_isolinuxcfg is a function'* )
+       edit_isolinuxcfg ${isolinuxcfg} ;;
+    esac
 fi
 
 for dir in etc install ; do


Reply to: