[SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (9c66ae11c4247e990dce47d5a059c5a6bac5104c)

Justin Boffemmyer scm at sourcemage.org
Sat Dec 27 11:58:42 EST 2008


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

 scripts/spellcaster.sh |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

New commits:
commit 9c66ae11c4247e990dce47d5a059c5a6bac5104c
Author: Justin Boffemmyer <flux at sourcemage.org>
Commit: Justin Boffemmyer <flux at sourcemage.org>

    scripts/spellcaster.sh: fix cleanup procedure
    
    The cleanup code wasn't referencing the TARGET directory for the kernel
    config file to remove, but instead was based on $CWD. The code was
    also failing to remove some files that it should have been removing.

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

    scripts/spellcaster.sh: remove trailing '/'
    
    Remove the trailing '/' from directory variables if present. This may
    not be essential, but is more correct.

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

    scripts/spellcaster.sh: create missing dirs
    
    If the ISO or SYS dirs don't exist, create them before attempting to do
    anything with them. Also, exit with error if TARGET isn't a valid
    directory.

diff --git a/scripts/spellcaster.sh b/scripts/spellcaster.sh
index 01cd42c..83abc96 100755
--- a/scripts/spellcaster.sh
+++ b/scripts/spellcaster.sh
@@ -40,8 +40,8 @@ function parse_options() {
 	while getopts ":cdh" Option
 	do
 		case $Option in
-			i ) ISODIR="$OPTARG" ;;
-			s ) SYSDIR="$OPTARG" ;;
+			i ) ISODIR="${OPTARG%/}" ;;
+			s ) SYSDIR="${OPTARG%/}" ;;
 			h ) usage ;;
 			* ) echo "Unrecognized option." >&2 && usage ;;
 		esac
@@ -70,6 +70,15 @@ function sanity_check() {
 	local arch=
 	local choice=
 
+	# Ensure that TARGET is a directory
+	[[ -d "$TARGET" ]] || exit 3
+
+	# If ISODIR is not a directory, create it.
+	[[ ! -d "$ISODIR" ]] && mkdir -p "$ISODIR" || exit 3
+
+	# If SYSDIR is not a directory, create it.
+	[[ ! -d "$SYSDIR" ]] && mkdir -p "$SYSDIR" || exit 3
+
 	if [[ -e "$config" ]]
 	then
 		arch="$(source "$config" && echo $ARCHIVE)"
@@ -171,10 +180,11 @@ OPTIONAL
 }
 
 function clean_target() {
-	local config="etc/sorcery/local/kernel.config"
+	local config="$TARGET/etc/sorcery/local/kernel.config"
 
 	# Restore resolv.conf
-	cp -f "$TARGET"/tmp/resolv.conf "$TARGET"/etc/resolv.conf
+	cp -f "$TARGET/tmp/resolv.conf" "$TARGET/etc/resolv.conf" &&
+		rm -f "$TARGET/tmp/resolv.conf"
 
 	# Clean up the target
 	rm -f "$TARGET/rspells" \
@@ -182,6 +192,7 @@ function clean_target() {
 		"$TARGET/ospells" \
 		"$TARGET/$config" \
 		"$TARGET/build_base.sh" \
+		"$TARGET/build_iso.sh" \
 		"$TARGET/build_optional.sh"
 }
 
@@ -191,7 +202,7 @@ parse_options
 priv_check
 
 [[ $# -lt 1 ]] && usage
-TARGET="$1"
+TARGET="${1%/}"
 shift
 
 [[ $# -gt 0 ]] && TYPE="$1"



More information about the SM-Commit mailing list