Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (8ca06997a8b133254157c8b58b2fd2a207370e4f)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Justin Boffemmyer <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (8ca06997a8b133254157c8b58b2fd2a207370e4f)
  • Date: Fri, 10 Oct 2008 10:26:53 -0500

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

scripts/add-sauce.sh | 73 +++++++++++++++++++++++++++------------
scripts/cleaniso.sh | 94
++++++++++++++++++++++++++++++++++++++-------------
scripts/mkrelease.sh | 0
3 files changed, 122 insertions(+), 45 deletions(-)

New commits:
commit 8ca06997a8b133254157c8b58b2fd2a207370e4f
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/cleaniso.sh: better error handling

Moved the usage info out into a real function so it can be used
multiple times. Added checks to make sure that the script is being
called correctly, as well as to make sure that the script is operating
on a sane chroot dir (make sure it has rm and rmdir).

commit 38fcdafcf4eefcc27081fc2cabc6873b40aae7e9
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/cleaniso.sh: add opt to run on all cleaners

Added the option flag '-a' to run the script on all cleaners in the
cauldron repo cleaners dir.

commit 22eeb0eea16592d5e0d119ca2333cbb6c657de5b
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/cleaniso.sh: fix variable names and add comments

Corrected some variable names that were all supposed to match, but
somehow I wrote different var names. I also added more verbosity to
the comments to make it clear what was going on in the main cleaning
loop.

commit 9b1d378c654f96dfe4667e4b8fd80d77963382b3
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/mkrelease.sh: chmod 0755

Forgot to make the script executable in the repo.

commit 8876c73628cf2dfe8b7dfbf2e3d209653600e202
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/add-sauce.sh: added comments

Added comments to explain what the script is doing at different
points, and why it's doing it.

commit f51d8222a5a4d15497adb15306765b51c6c9b73b
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/add-sauce.sh: fix cp, add 'a' response

The cp algorithm now correctly copies. There were two problems
previously: the script failed to ensure that directories were created
if they were missing (shouldn't be a problem in theory as the
directories should exist, but now the script is better because it will
guarantee they exist) and it was copying directly into the base of
CHROOTDIR instead of the tree it belonged in. The 'a' response was
added as an option to "force" overwriting of files, so that if it's
your first time running add-sauce on a dir you don't have to type 'y'
on every file that matches.

commit 980c80789f5fd93f38dd4315c69519b822e7b583
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/add-sauce.sh: use getopts to parse opts

Don't use real arguments to parse options, instead use getopts. This
lets users combine options (-fi for example) with no problems. Also,
we can combine the usage printing so that if wrong options are passed
or if the wrong number of options/arguments are passed we can print
the same usage easily.

diff --git a/scripts/add-sauce.sh b/scripts/add-sauce.sh
index b080e82..57e7ff2 100755
--- a/scripts/add-sauce.sh
+++ b/scripts/add-sauce.sh
@@ -3,26 +3,33 @@
TEMPDIR="/tmp/sauce.$$"

FORCE=false
-if [[ $1 == "-f" ]] ;then
- shift
- FORCE=true
-fi
+TYPE="bad"
+
+function usage() {
+ cat << EndUsage
+Usage: $0 [-f] -i|-s /path/to/target
+Adds the cauldron team files to the given chroot
+Use -i for an iso target, -s for the system tarball
+EndUsage
+ exit 1
+} >&2

-TYPE=bad
-if [[ $1 == "-i" ]] ;then
- TYPE=iso
-elif [[ $1 == "-s" ]] ;then
- TYPE=system
-fi
+while getopts ":fis" Option
+do
+ case $Option in
+ f ) FORCE=true ;;
+ i ) TYPE="iso" ;;
+ s ) TYPE="system" ;;
+ * ) usage ;;
+ esac
+done
+shift $((OPTIND - 1))

-if [[ $TYPE == "bad" || -z $2 ]] ;then
- echo "Usage: $0 [-f] <-i|-s> /path/to/target"
- echo "Adds the cauldron team files to the given chroot"
- echo "Use -i for an iso target, -s for the system tarball"
- exit 1
-fi >&2
+if [[ $TYPE == "bad" || -z $1 ]] ;then
+ usage
+fi

-CHROOTDIR=$2
+CHROOTDIR=$1

if ! $FORCE ;then
if [[ ! -x $CHROOTDIR/bin/bash ]] ;then
@@ -40,12 +47,19 @@ if ! [[ -e $MYDIR/base/etc/shadow ]] ;then
fi >&2


+# make sure we start with a clean TEMPDIR each run
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/

# ISO Sauce
if [[ $TYPE == "iso" ]] ;then
+ # copy everything from the cauldron repo iso dir
+ # into the TEMPDIR staging area
cp -a $MYDIR/iso/* $TEMPDIR/
fi

@@ -53,6 +67,8 @@ fi
if [[ $TYPE == "system" ]]
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/
fi

@@ -62,25 +78,38 @@ chmod -R u=rwX,go=u-w $TEMPDIR/
chmod 0600 $TEMPDIR/etc/shadow
# ==== end fixup ====

-for i in $(find $TEMPDIR -print)
+# Get a list of all files we want to install
+for i in $(find $TEMPDIR -mindepth 1 -print)
do
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
continue
fi

- if [[ -e $CHROOTDIR/$FILE ]]
+ # For each file, check to see if it already
+ # exists in CHROOTDIR, and if so prompt if
+ # we should overwrite or not. If
+ # 'a' is passed then skip the prompting and
+ # just overwrite. Else, if 'y' is passed
+ # overwrite that file and prompt on next.
+ # 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 ]]
then
- echo -n "Overwrite ${FILE}? [yn] "
+ echo -n "Overwrite ${FILE}? [yna] "
read -n1 OVERWRITE
echo ""
if [[ $OVERWRITE == y ]]
then
- cp -a $TEMPDIR/$FILE $CHROOTDIR/
+ cp -a $TEMPDIR/$FILE $CHROOTDIR/$FILE
fi
else
- cp -a $TEMPDIR/$FILE $CHROOTDIR/
+ cp -a $TEMPDIR/$FILE $CHROOTDIR/$FILE
fi
done

diff --git a/scripts/cleaniso.sh b/scripts/cleaniso.sh
index 5538e5e..9d63760 100755
--- a/scripts/cleaniso.sh
+++ b/scripts/cleaniso.sh
@@ -2,42 +2,90 @@

# CLEANFILEs are located in cauldron/data/cleaners

-if [[ $# -lt 2 ]]
-then
- echo ""
- echo "Usage: $0 iso_chroot cleaner(s)"
- echo ""
- echo "For each cleaner specified as an argument, cleans the"
- echo "files and directories listed therein from iso_chroot."
- echo "A cleaner is the ouput of 'gaze install \$SPELL' minus"
- echo "whatever you don't want removed."
- echo ""
+CLEANALL=false
+CLEANERS="$(dirname $0)/../data/cleaners"
+
+function usage() {
+ cat <<-USAGE
+ Usage: $0 [-a] iso_chroot cleaner(s)
+
+ For each cleaner specified as an argument, cleans the
+ files and directories listed therein from iso_chroot.
+ A cleaner is the ouput of 'gaze install \$SPELL' minus
+ whatever you don't want removed. If -a is specified,
+ it will use all cleaners found in the cauldron cleaner dir.
+ USAGE
exit 1
-fi >&2
+} >&2
+
+while getopts ":a" Option
+do
+ case $Option in
+ a ) CLEANALL=true ;;
+ * ) ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+# Check to make sure we have the right number of arguments
+# taking the option flag into account
+if [[ $# -eq 1 ]]
+then
+ if ! $CLEANALL
+ then
+ usage
+ fi
+elif [[ $# -lt 2 ]]
+then
+ usage
+fi

# location of ISO chroot to clean from
ISOCHROOT="$1"
shift

-for CLEANER in "$@"
+# Ensure sanity of chroot by making sure that it has
+# rm and rmdir.
+if ! [[ -e "$ISOCHROOT/bin/rm" ]]
+then
+ echo "Error: /bin/rm not found in $ISOCHROOT" >&2
+ exit 1
+fi
+if ! [[ -e "$ISOCHROOT/bin/rmdir" ]]
+then
+ echo "Error: /bin/rmdir not found in $ISOCHROOT" >&2
+ exit 1
+fi
+
+if $CLEANALL
+then
+ LIST=( $(ls $CLEANERS/*) )
+else
+ LIST=( $@ )
+fi
+
+for CLEANER in "${LIST[@]}"
do
# Reverse sort ensures that the gaze install output we have lists
files
# before directories, so that directories can be cleaned using rmdir
# after the files are cleaned first. This is safer, since it avoids
the
# mighty 'rm -fr' oopses.
- for i in $(sort -r "$CLEANFILE")
+ for DIRT in $(sort -r "$CLEANER")
do
- # test if current listing is a dir, should only be true after
- # the files under the dir are already cleaned
- if [[ -d "$i" ]]
+ if [[ -e $ISOCHROOT/$DIRT ]]
then
- # chroot and clean a directory using rmdir
- echo "Attempting to remove directory $i..."
- chroot "$ISOCHROOT" rmdir "$i"
- else
- # chroot and clean an individual file
- echo "Deleting $i"
- chroot "$ISOCHROOT" rm "$i"
+ # test if current listing is a dir, should only be
true after
+ # the files under the dir are already cleaned
+ if [[ -d "$DIRT" ]]
+ then
+ # chroot and clean a directory using rmdir
+ echo "Attempting to remove directory
$ISOCHROOT/$DIRT"
+ chroot "$ISOCHROOT" rmdir "$DIRT"
+ else
+ # chroot and clean an individual file
+ echo "Attempting to delete $ISOCHROOT/$DIRT"
+ chroot "$ISOCHROOT" rm "$DIRT"
+ fi
fi
done
done
diff --git a/scripts/mkrelease.sh b/scripts/mkrelease.sh
old mode 100644
new mode 100755



  • [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (8ca06997a8b133254157c8b58b2fd2a207370e4f), Justin Boffemmyer, 10/10/2008

Archive powered by MHonArc 2.6.24.

Top of Page