[SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (496dd994b22d7f55ab9ee47d9f4b1147cc9716e0)

Justin Boffemmyer scm at sourcemage.org
Tue Oct 14 23:09:40 EDT 2008


GIT changes to test cauldron by Justin Boffemmyer <flux at sourcemage.org>:

 scripts/add-sauce.sh |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

New commits:
commit 496dd994b22d7f55ab9ee47d9f4b1147cc9716e0
Author: Justin Boffemmyer <flux at sourcemage.org>
Commit: Justin Boffemmyer <flux at sourcemage.org>

    scripts/add-sauce.sh: test for grub before copy
    
    Check to see if grub exists in the $CHROOTDIR before trying to copy
    the stage files to $CHROOTDIR/boot/grub. Also added quotes for
    variables to ensure that paths will be properly parsed.

diff --git a/scripts/add-sauce.sh b/scripts/add-sauce.sh
index 1efeb65..2c857b8 100755
--- a/scripts/add-sauce.sh
+++ b/scripts/add-sauce.sh
@@ -41,7 +41,7 @@ do
 done
 shift $(($OPTIND - 1))
 
-SELF=$0
+SELF="$0"
 
 if [[ $UID -ne 0 ]]
 then
@@ -58,18 +58,18 @@ if [[ $TYPE == "bad" || -z $1 ]] ;then
   usage
 fi
 
-CHROOTDIR=$1
+CHROOTDIR="$1"
 
 if ! $FORCE ;then
-  if [[ ! -x $CHROOTDIR/bin/bash ]] ;then
+  if [[ ! -x "$CHROOTDIR"/bin/bash ]] ;then
     echo "Chroot at $CHROOTDIR failed sanity check (no bash?)"
     exit 2
   fi >&2
 fi
 
-MYDIR=$(readlink -f ${0%/*}/..)
+MYDIR="$(readlink -f ${0%/*}/..)"
 
-if ! [[ -e $MYDIR/base/etc/shadow ]] ;then
+if ! [[ -e "$MYDIR"/base/etc/shadow ]] ;then
   echo "Failed sanity check: Cannot find base/etc/shadow in my dir"
   echo "(assumed to be $MYDIR)"
   exit 2
@@ -77,19 +77,19 @@ fi >&2
 
 
 # make sure we start with a clean TEMPDIR each run
- rm -rf $TEMPDIR
- mkdir -m 0700 $TEMPDIR
+ rm -rf "$TEMPDIR"
+ mkdir -m 0700 "$TEMPDIR"
 
 # add the contents of base, which are files that
 # should go onto both iso and system chroots
 # this is mostly /etc content
- cp -a $MYDIR/base/* $TEMPDIR/
+ cp -a "$MYDIR"/base/* "$TEMPDIR"/
 
 # ISO Sauce
 if [[ $TYPE == "iso" ]] ;then
   # copy everything from the cauldron repo iso dir
   # into the TEMPDIR staging area
-   cp -a $MYDIR/iso/* $TEMPDIR/
+   cp -a "$MYDIR"/iso/* "$TEMPDIR"/
 fi
 
 # System Sauce
@@ -98,24 +98,24 @@ then
   # make sure that the grub stage files are available in /boot
   # by copying them from CHROOTDIR (system) into the /boot dir
   # in our TEMPDIR staging area
-   cp -a $CHROOTDIR/usr/lib/grub/i386-pc/* $TEMPDIR/boot/grub/
+  [[ -d "$CHROOTDIR"/usr/lib/grub/i386-pc ]] && cp -a "$CHROOTDIR"/usr/lib/grub/i386-pc/* "$TEMPDIR"/boot/grub/
 fi
 
 # ==== FIXUP starts here ====
- chown -R 0:0 $TEMPDIR/
- chmod -R u=rwX,go=u-w $TEMPDIR/
- chmod 0600 $TEMPDIR/etc/shadow
+ chown -R 0:0 "$TEMPDIR"/
+ chmod -R u=rwX,go=u-w "$TEMPDIR"/
+ chmod 0600 "$TEMPDIR"/etc/shadow
 # ==== end fixup ====
 
 # Get a list of all files we want to install
-for i in $(find $TEMPDIR -mindepth 1 -print)
+for i in $(find "$TEMPDIR" -mindepth 1 -print)
 do
-  FILE=${i#$TEMPDIR/}
+  FILE="${i#$TEMPDIR/}"
   # If FILE is a directory, mkdir in CHROOTDIR
   # This is safe even if the dir already exists
   if [[ -d $i ]]
   then
-     mkdir -p $CHROOTDIR/$FILE
+     mkdir -p "$CHROOTDIR/$FILE"
     continue
   fi
 
@@ -128,19 +128,19 @@ do
   # Since this is checked via an env var,
   # you can be clever and run this as
   # OVERWRITE='a' add-sauce.sh [-i|-s] CHROOTDIR
-  if [[ -e $CHROOTDIR/$FILE && $OVERWRITE != a ]]
+  if [[ -e "$CHROOTDIR/$FILE" && $OVERWRITE != a ]]
   then
     echo -n "Overwrite ${FILE}? [yna] "
     read -n1 OVERWRITE
     echo ""
     if [[ $OVERWRITE == y ]]
     then
-       cp -a $TEMPDIR/$FILE $CHROOTDIR/$FILE
+       cp -a "$TEMPDIR/$FILE" "$CHROOTDIR/$FILE"
     fi
   else
-     cp -a $TEMPDIR/$FILE $CHROOTDIR/$FILE
+     cp -a "$TEMPDIR/$FILE" "$CHROOTDIR/$FILE"
   fi
 done
 
- rm -rf $TEMPDIR
+ rm -rf "$TEMPDIR"
 



More information about the SM-Commit mailing list