[SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (4e69a2498e5584ebc9ec15a17bb10423261ed010)

Justin Boffemmyer scm at sourcemage.org
Sun Dec 28 17:29:30 EST 2008


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

 scripts/spellcaster.sh |  121 ++++++++++++++++++-------------------------------
 1 files changed, 45 insertions(+), 76 deletions(-)

New commits:
commit 4e69a2498e5584ebc9ec15a17bb10423261ed010
Author: Justin Boffemmyer <flux at sourcemage.org>
Commit: Justin Boffemmyer <flux at sourcemage.org>

    scripts/spellcaster.sh: reimplement chroot builds
    
    Reimplemented the chroot building process. It is now cleaner, better
    optimized, and more debug-friendly.

commit eb3cb4743f3af65f9577bb875cfcc655f22ce9cd
Author: Justin Boffemmyer <flux at sourcemage.org>
Commit: Justin Boffemmyer <flux at sourcemage.org>

    scripts/spellcaster.sh: drop source $config output
    
    Don't output any messages from trying to source
    $TARGET/etc/sorcery/local/config, just source it and use it if
    available.

commit 1195526c60777629daa14951a06831b732c48112
Author: Justin Boffemmyer <flux at sourcemage.org>
Commit: Justin Boffemmyer <flux at sourcemage.org>

    scripts/spellcaster.sh: directory_check func
    
    Moved the directory testing and creation code out to a function. This
    makes the code cleaner and easier to read, and easier to add new
    directories to test/create.

diff --git a/scripts/spellcaster.sh b/scripts/spellcaster.sh
index fe619b2..3538f0a 100755
--- a/scripts/spellcaster.sh
+++ b/scripts/spellcaster.sh
@@ -64,6 +64,13 @@ function priv_check() {
 	fi
 }
 
+function directory_check() {
+	if [[ ! -d $1 ]]
+	then
+		mkdir -p $1
+	fi
+}
+
 # check to make sure that the chroot has sorcery set to do caches
 function sanity_check() {
 	local config="$TARGET/etc/sorcery/local/config"
@@ -72,44 +79,31 @@ function sanity_check() {
 
 	# Ensure that TARGET is a directory
 	[[ -d "$TARGET" ]] || {
-		echo "$TARGET does not exist!" && exit 3
+		echo "$TARGET does not exist!"
+		exit 3
 	}
 
 	# If ISODIR is not a directory, create it.
-	[[ ! -d "$ISODIR" ]] && {
-		mkdir -p "$ISODIR" || {
-			echo "couldn't create $ISODIR" &&
-			exit 3
-		}
-	}
+	directory_check "$ISODIR"
 
 	# If ISODIR/var/cache/sorcery is not a directory, create it.
-	[[ ! -d "$ISODIR/var/cache/sorcery" ]] && {
-		mkdir -p "$ISODIR/var/cache/sorcery" || {
-			echo "couldn't create $ISODIR/var/cache/sorcery" &&
-			exit 3
-		}
-	}
+	directory_check "$ISODIR/var/cache/sorcery"
+
+	# If ISODIR/var/spool/sorcery is not a directory, create it.
+	directory_check "$ISODIR/var/spool/sorcery"
 
 	# If SYSDIR is not a directory, create it.
-	[[ ! -d "$SYSDIR" ]] && {
-		mkdir -p "$SYSDIR" || {
-			echo "couldn't create $SYSDIR" &&
-			exit 3
-		}
-	}
+	directory_check "$SYSDIR"
 
 	# If SYSDIR/var/cache/sorcery is not a directory, create it.
-	[[ ! -d "$SYSDIR/var/cache/sorcery" ]] && {
-		mkdir -p "$SYSDIR/var/cache/sorcery" || {
-			echo "couldn't create $SYSDIR/var/cache/sorcery" &&
-			exit 3
-		}
-	}
+	directory_check "$SYSDIR/var/cache/sorcery"
+
+	# If SYSDIR/var/spool/sorcery is not a directory, create it.
+	directory_check "$SYSDIR/var/spool/sorcery"
 
 	if [[ -e "$config" ]]
 	then
-		arch="$(source "$config" && echo $ARCHIVE)"
+		arch="$(source "$config" &> /dev/null && echo $ARCHIVE)"
 		if [[ -n $arch && $arch != "on" ]]
 		then
 			echo "Error! TARGET sorcery does not archive!" >&2
@@ -147,67 +141,48 @@ function prepare_target() {
 	cp "$CAULDRONDIR/ospells.$TYPE" "$TARGET"/ospells
 
 	# generate basesystem casting script inside of TARGET
-	cat > "$TARGET"/build_base.sh <<-'BASE'
-
-	# If console-tools is found in TARGET, get rid of it to make way for kbd
-	[[ $(gaze -q installed console-tools) != "not installed" ]] &&
-		dispel --orphan always console-tools
+	cat > "$TARGET"/build_spells.sh <<-'SPELLS'
 
 	if [[ -n $CAULDRON_CHROOT && $# -eq 0 ]]
 	then
-		# cast basic/required spells
-		/usr/sbin/cast $(tr '\n' ' ' </rspells) || exit $?
+
+		# If console-tools is found in TARGET, get rid of it to make
+		# way for kbd
+		[[ $(gaze -q installed console-tools) != "not installed" ]] &&
+		dispel --orphan always console-tools
+
+		# push the needed spells into the install queue
+		cat rspells ispells ospells > /var/log/sorcery/queue/install
+
+		# cast all the spells using the install queue and save the
+		# return value to a log file
+		/usr/sbin/cast --queue 2> /build_spells.log
+		echo $? >> /build_spells.log
 
 		# make a list of the caches to unpack for system
 		for spell in $(</rspells)
 		do
 			gaze installed $spell &> /dev/null &&
-			echo $spell-$(gaze -q installed $spell) >> /sys-list
-		done || exit 42
-	fi
-BASE
-
-	# generate iso spell casting script inside of TARGET
-	cat > "$TARGET"/build_iso.sh <<-'ISO'
-
-	if [[ -n $CAULDRON_CHROOT && $# -eq 0 ]]
-	then
-		# cast optional spells
-		/usr/sbin/cast $(tr '\n' ' ' </ispells) || exit $?
+			echo $spell-$(gaze -q installed $spell)
+		done > /sys-list || exit 42
 
 		# make a list of the caches to unpack for iso
 		for spell in $(</ispells)
 		do
 			gaze installed $spell &> /dev/null &&
-			echo $spell-$(gaze -q installed $spell) >> /iso-list
-		done || exit 42
-	fi
-ISO
-
-	# generate optional spell casting script inside of TARGET
-	cat > "$TARGET"/build_optional.sh <<-'OPTIONAL'
+			echo $spell-$(gaze -q installed $spell)
+		done > /iso-list || exit 42
 
-	if [[ -n $CAULDRON_CHROOT && $# -eq 0 ]]
-	then
-		# cast optional spells
-		/usr/sbin/cast $(tr '\n' ' ' </ospells) || exit $?
-
-		# make a list of the caches to unpack for iso
+		# make a list of the optional caches to unpack for iso
 		for spell in $(</ospells)
 		do
 			gaze installed $spell &> /dev/null &&
-			echo $spell-$(gaze -q installed $spell) >> /opt-list
-		done || exit 42
-
-		# dispel the optional spells, so that we have only their cache files
-		# available
-		/usr/sbin/dispel $(tr '\n' ' ' </ospells) || exit $?
+			echo $spell-$(gaze -q installed $spell)
+		done > /opt-list || exit 42
 	fi
-OPTIONAL
+SPELLS
 
-	chmod a+x "$TARGET"/build_base.sh
-	chmod a+x "$TARGET"/build_iso.sh
-	chmod a+x "$TARGET"/build_optional.sh
+	chmod a+x "$TARGET"/build_spells.sh
 }
 
 function clean_target() {
@@ -249,17 +224,14 @@ sanity_check
 
 prepare_target
 
-# chroot and build the basesystem inside the TARGET
-"$MYDIR/cauldronchr.sh" -d "$TARGET" /build_base.sh
+# chroot and build all of the spells inside the TARGET
+"$MYDIR/cauldronchr.sh" -d "$TARGET" /build_spells.sh
 
 for cache in $(<"$TARGET"/sys-list)
 do
 	tar xjf "$TARGET"/var/cache/sorcery/$cache*.tar.bz2 -C "$SYSDIR"/
 done
 
-# chroot and build the iso inside the TARGET
-"$MYDIR/cauldronchr.sh" -d "$TARGET" /build_iso.sh
-
 # copy the caches over and unpack their contents
 for cache in $(<"$TARGET"/iso-list)
 do
@@ -267,9 +239,6 @@ do
 	cp "$TARGET"/var/cache/sorcery/$cache*.tar.bz2 "$ISODIR"/var/cache/sorcery/
 done
 
-# chroot and build the optional spells inside the TARGET
-"$MYDIR/cauldronchr.sh" -d "$TARGET" /build_optional.sh
-
 # copy the caches over (only!)
 for cache in $(<"$TARGET"/opt-list)
 do



More information about the SM-Commit mailing list