public inbox for gnap-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1
@ 2007-08-03 13:16 Philipp Riegger
  2007-08-03 13:26 ` [gnap-dev] [PATCH 1/4] GNAP cleanup Philipp Riegger
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Philipp Riegger @ 2007-08-03 13:16 UTC (permalink / raw
  To: gnap-dev

Hi!

I worked some more on my GNAP patchset, improved some stuff and split it
up nicer. This 5 emails deprecate the previous patchset i found. There
are also some bugs i fixed recently, after i send this stuff to BaSS.
Since I'm only working with gnap_make at the moment, i did no testing
with the other scripts. So any testing and comments are apreciated.

The patches are:

01-gnap-cleanup.patch
02-gnap-split.patch
03-gnap-namespace.patch
04-gnap-environment.patch

I will send them as replies to this email.

Things that still need to be done:
 - Make the portage tarball creation code of gnap_make nicer. Since
catalyst supports overlays, this is probably the way to go: Use the
unmodified potage snapshot and merge all given overlays into one overlay
and give it to catalyst. Maybe catalyst can even handle more than one
overlay, but i do not know since i did not have a look at this.
 - Lots of code is still duplicated in there and could be put to
functions. I espcially mean gnap_make and the stage-specific code.
 - This patchset works on the scripts, mostly n gnap_make and only does
minimal changes to the provided config files. Maybe the gnap-devver
convigfiles have to be changed accordingly, someone should have a look
at the patches and theese files.

Thanks,
	Philipp

-- 
gnap-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gnap-dev] [PATCH 1/4] GNAP cleanup
  2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
@ 2007-08-03 13:26 ` Philipp Riegger
  2007-08-03 13:32 ` [gnap-dev] [PATCH 2/4] GNAP split Philipp Riegger
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Philipp Riegger @ 2007-08-03 13:26 UTC (permalink / raw
  To: gnap-dev

This patch does some cleanup work:
 - ginfo was available and used in only one of the gnap_* scripts. Add
it to the other scripts where it might be needed and use it.
 - mkdir -p ... \n gtest ... was used very often. I put this in a
function, the error messages are now more detailed (no "kernel temp dir
could not be created", but "/some/very/important/path could not be
created".
 - removed ALLTARGET in gnap_make.
 - used storedir from catalyst.conf instead of CATALYST_DIR.
 - some more stuff, which should be obvious.

If there are any questions, just ask.

Philipp


diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh
gnap-2.0/src/gnap_make gnap-2.0+cleanup/src/gnap_make
--- gnap-2.0/src/gnap_make	2007-07-23 14:14:40.000000000 +0300
+++ gnap-2.0+cleanup/src/gnap_make	2007-08-02 15:55:38.000000000 +0300
@@ -21,6 +21,15 @@
 	echo -e " ${W}*${N} ${*}"
 }
 
+ginfo() {
+	echo -e " ${G}*${N} ${*}"
+}
+
+gmkdir() {
+	mkdir -p "$1"
+	gtest continued $? "Failed to create directory \"$1\"."
+}
+
 gconfirm() {
 	if [[ "${FORCEYES}" -eq 1 ]]; then
 		gwarn "${*} forced to yes"
@@ -30,7 +39,7 @@
 			if [[ -n "${TEMPDIR}" ]]; then
 				cleanup
 			fi
-			echo Build aborted !
+			echo Build aborted!
 			exit 2
 		fi
 	fi
@@ -77,7 +86,7 @@
 	echo '    -c catalyst.conf     Use specific catalyst.conf file'
 	echo '    -e specs             Specs directory or tar.bz2 file'
 	echo
-	echo "Please man ${GNAPNAME} for more details."
+	echo "Please use man ${GNAPNAME} for more details."
 }
 
 cleanup() {
@@ -92,19 +101,24 @@
 	fi
 }
 
-if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
+if [[ "$#" -eq 0 ]]; then
 	usage
 	exit 0
 fi
 
 gbegin 'Checking parameters'
 
+# Catalyst executable and config file
+CATALYST_BIN="/usr/bin/catayst"
+CATALYST_CONF="/etc/catalyst/catalyst.conf"
+
 # Read options
 NOTARGET=1
 STAMP=$(date +%Y%m%d)
-while getopts ':hs:p:m:o:v:t:fl:c:e:' options; do
-	case ${options} in
-		h ) usage
+while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
+	case ${option} in
+		h )
+			usage
 			exit 0;;
 		s ) STAGE3FILE="${OPTARG}";;
 		p ) SNAPSHOTFILE="${OPTARG}";;
@@ -112,7 +126,13 @@
 		v ) STAMP="${OPTARG}";;
 		t )
 			case "${OPTARG}" in
-				all ) ALLTARGET=1;;
+				all )
+					STAGE3=1
+					LIVECD1=1
+					LIVECD2=1
+					TARBALL=1
+					MODULES=1
+					NEEDS_SNAPSHOT=1;;
 				stage3 )
 					STAGE3=1
 					NEEDS_SNAPSHOT=1;;
@@ -122,17 +142,19 @@
 				livecd-stage2 )
 					LIVECD2=1
 					NEEDS_SNAPSHOT=1;;
-				tarball ) TARBALL=1;;
+				tarball )
+					TARBALL=1;;
 				extensions )
 					MODULES=1
 					NEEDS_SNAPSHOT=1;;
+				* ) gtest 1 'Specified stage is unknown!';;
 			esac
 			NOTARGET=0;;
 		f ) FORCEYES=1;;
 		l ) GNAPLOGPREFIX="${OPTARG}";;
 		c ) CATALYST_CONF="${OPTARG}";;
 		e ) SPECS="${OPTARG}";;
-		* ) gtest 1 'Specified options are incomplete or unknown !';;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
@@ -147,8 +169,7 @@
 # Prepare specs dir and check common.conf file
 SPECDIR="${TEMPDIR}/specs"
 if [[ -f "${SPECS}" ]]; then
-	mkdir "${SPECDIR}"
-	gtest continued $? 'Failed to create specs temporary subdirectory'
+	gmkdir "${SPECDIR}"
 	tar jx -f "${SPECS}" -C "${SPECDIR}"
 	gtest continued $? 'Failed to unpack specs'
 elif [[ -d "${SPECS}" ]]; then
@@ -158,7 +179,7 @@
 	gtest continued 1 "${SPECS} not found, provide a valid -e option"
 fi
 test -f "${SPECDIR}/common.conf"
-gtest continued $? "Incorrect specdir: ${SPECDIR}/common.conf not
found !"
+gtest continued $? "Incorrect specdir: ${SPECDIR}/common.conf not
found!"
 source "${SPECDIR}/common.conf"
 export CHOST
 export CFLAGS
@@ -169,30 +190,16 @@
 
 # catalyst.conf file
 test -f "${CATALYST_CONF}"
-gtest continued $? "${CATALYST_CONF} file not found !"
+gtest continued $? "${CATALYST_CONF} file not found!"
 source "${CATALYST_CONF}"
 
-# Default targets is complete core build
-if [[ "${ALLTARGET}" -eq 1 ]]; then
-	STAGE3=1
-	LIVECD1=1
-	LIVECD2=1
-	TARBALL=1
-	MODULES=1
-	NEEDS_SNAPSHOT=1
-fi
-
 # At least one target is needed
 test "${NOTARGET}" -eq 0
 gtest continued $? \
 	'No target specified. You should provide at least one -t option.'
 
-# CATALYST_DIR must exist
-if [[ ! -d "${CATALYST_DIR}" ]]; then
-  mkdir "${CATALYST_DIR}"
-  gtest continued $? \
-	"Error: failed to create ${CATALYST_DIR} directory."
-fi
+# storedir must exist
+gmkdir "${storedir}"
 
 # Stage3 needs a seed stage
 if [[ "${STAGE3}" -eq 1 ]]; then
@@ -211,17 +218,14 @@
 	test -f "${STAGE3FILE}"
 	gtest continued $? "${STAGE3FILE} is not a valid stage3 tarball"
 fi
-gtest 0
 
 # If extensions and no stage3, warn that we'll use seedstage as stage3
-STAGE3LOC="${CATALYST_DIR}/builds/${RELTYPE}/stage3-${SUBARCH}-${STAMP}.tar.bz2"
+STAGE3LOC="${storedir}/builds/${RELTYPE}/stage3-${SUBARCH}-${STAMP}.tar.bz2"
 if [[ "${MODULES}" -eq 1 || "${LIVECD1}" -eq 1 ]]; then
 	if [[ "${STAGE3}" -ne 1 && ! -f "${STAGE3LOC}" ]]; then
 		gwarn '"livecd-stage1" or "extensions" was selected without
"stage3".'
-		gconfirm 'Should I use the seed stage as stage3 result ?'
-		if [[ ! -d "${CATALYST_DIR}/builds/${RELTYPE}" ]]; then
-			mkdir -p "${CATALYST_DIR}/builds/${RELTYPE}"
-		fi
+		gconfirm 'Should I use the seed stage as stage3 result?'
+		gmkdir "${storedir}/builds/${RELTYPE}"
 		cp "${STAGE3FILE}" "${STAGE3LOC}"
 	fi
 fi
@@ -242,14 +246,12 @@
 if [[ "${MODULES}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[extensions]"
 fi
-gwarn 'The following targets will be called:'
-gwarn "${TARGETLIST}"
+ginfo 'The following targets will be called:'
+ginfo "${TARGETLIST}"
 
 # Confirm tarball overwrite if TARBALL stage selected
-if [[ "${TARBALL}" -eq 1 ]]; then
-	if [[ -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]]; then
-		gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
-	fi
+if [[ "${TARBALL}" -eq 1 -a -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]];
then
+	gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
 fi
 
 # Logfile setup and confirmation
@@ -275,17 +277,14 @@
 if [[ "${NEEDS_SNAPSHOT}" -eq 1 ]]; then
 	gbegin 'Preparing portage snapshot'
 
-	if [[ ! -d "${CATALYST_DIR}/snapshots" ]]; then
-		mkdir -p "${CATALYST_DIR}/snapshots"
-	fi
+	gmkdir "${storedir}/snapshots"
 
 	if [[ -z "${PORTAGE_OVERLAYS}" ]]; then
-		cp "${SNAPSHOTFILE}"
"${CATALYST_DIR}/snapshots/portage-${STAMP}.tar.bz2"
+		cp "${SNAPSHOTFILE}" "${storedir}/snapshots/portage-${STAMP}.tar.bz2"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
 	else
 		TEMPPRTDIR="${TEMPDIR}/portage"
-		mkdir "${TEMPPRTDIR}"
-		gtest continued $? 'Failed to create portage temporary subdirectory'
+		gmkdir "${TEMPPRTDIR}"
 
 		tar jxf "${SNAPSHOTFILE}" -C "${TEMPPRTDIR}" \
 			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
@@ -295,7 +294,7 @@
 			gtest continued $? "Failed to copy ${overlay}"
 		done
 
-		tar jcf "${CATALYST_DIR}/snapshots/portage-${STAMP}.tar.bz2" \
+		tar jcf "${storedir}/snapshots/portage-${STAMP}.tar.bz2" \
 			-C "${TEMPPRTDIR}" . \
 			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
@@ -306,10 +305,8 @@
 if [[ "${STAGE3}" -eq 1 ]]; then
 	gbegin "${G}[stage3]${N} stage (base system build)"
 
-	if [[ ! -d "${CATALYST_DIR}/builds/${RELTYPE}" ]]; then
-		mkdir -p "${CATALYST_DIR}/builds/${RELTYPE}"
-	fi
-	cp "${STAGE3FILE}"
"${CATALYST_DIR}/builds/${RELTYPE}/seedstage.tar.bz2"
+	gmkdir "${storedir}/builds/${RELTYPE}"
+	cp "${STAGE3FILE}" "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
 
 	TEMPCONF="${TEMPDIR}/stage3.conf"
 	touch "${TEMPCONF}"
@@ -328,7 +325,7 @@
 	$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
 		>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
 	gtest $? "[stage3] failed, ${SEELOGFILES}"
-	rm "${CATALYST_DIR}/builds/${RELTYPE}/seedstage.tar.bz2"
+	rm "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
 fi
 
 # LIVECD-STAGE1 phase
@@ -389,16 +386,14 @@
 	gbegin "${G}[tarball]${N} phase (Creation of core and basefs
components)"
 	test -e "gnap-${GNAPVERSION}-${STAMP}.iso"
 	gtest continued $? "No gnap-${GNAPVERSION}-${STAMP}.iso file to
convert !"
-	test -d "${CATALYST_DIR}/tmp/gnap/livecd-stage1-${SUBARCH}-${STAMP}"
+	test -d "${storedir}/tmp/gnap/livecd-stage1-${SUBARCH}-${STAMP}"
 	gtest $? 'Missing livecd-stage2 results'
 
 	gbegin '  Creating core component'
 	TEMPMNTDIR="${TEMPDIR}/mount"
-	mkdir "${TEMPMNTDIR}"
-	gtest continued $? 'Failed to create mount temporary subdirectory'
+	gmkdir "${TEMPMNTDIR}"
 	TEMPISODIR="${TEMPDIR}/iso"
-	mkdir "${TEMPISODIR}"
-	gtest continued $? 'Failed to create iso temporary subdirectory'
+	gmkdir "${TEMPISODIR}"
 
 	mount -o loop "gnap-${GNAPVERSION}-${STAMP}.iso" ${TEMPMNTDIR} && \
 		cp -r ${TEMPMNTDIR}/* ${TEMPISODIR}
@@ -419,14 +414,14 @@
 
 	gbegin '  Creating basefs component'
 	tar jcf "gnap-basefs-${GNAPVERSION}-${STAMP}.tar.bz2" \
-		-C "${CATALYST_DIR}/tmp/gnap/livecd-stage2-${SUBARCH}-${STAMP}" .
+		-C "${storedir}/tmp/gnap/livecd-stage2-${SUBARCH}-${STAMP}" .
 	gtest $? 'Unable to create basefs tarball'
 fi
 
 # EXTENSIONS phase
 if [[ "${MODULES}" -eq 1 ]]; then
 	gbegin "${G}[extensions]${N} stage start"
-	GRP_PREFIX="${CATALYST_DIR}/builds/${RELTYPE}/grp-${SUBARCH}-${STAMP}"
+	GRP_PREFIX="${storedir}/builds/${RELTYPE}/grp-${SUBARCH}-${STAMP}"
 	SPECMODULE="${SPECDIR}/extensions.conf"
 	mod_list=$(grep '^extensions:' "${SPECMODULE}" 2>/dev/null);
 	mod_list="${mod_list/extensions:/}"
@@ -460,12 +455,10 @@
 
 		$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
 			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
-		gtest continued $? \
-			"Extension build failed, ${SEELOGFILES}"
+		gtest continued $? "Extension build failed, ${SEELOGFILES}"
 
 		TEMPMODULEDIR="${TEMPDIR}/module_${mod_name}"
-		mkdir "${TEMPMODULEDIR}"
-		gtest continued $? 'Failed to create module temporary subdirectory'
+		gmkdir "${TEMPMODULEDIR}"
 		for pkg in $( ls ${GRP_PREFIX}/${mod_name}/All/*.tbz2 ); do
 			tar jxf $pkg -C "${TEMPMODULEDIR}" -p \
 				>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
@@ -488,5 +481,5 @@
 fi
 
 cleanup
-echo 'Build successful !'
+echo 'Build successful!'
 exit 0
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh
gnap-2.0/src/specs/common.conf gnap-2.0+cleanup/src/specs/common.conf
--- gnap-2.0/src/specs/common.conf	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/src/specs/common.conf	2007-07-17 15:40:34.000000000
+0300
@@ -1,9 +1,3 @@
-# Catalyst executable and support files
-CATALYST_NAME='catalyst'
-CATALYST_BIN="/usr/bin/${CATALYST_NAME}"
-CATALYST_CONF="/etc/${CATALYST_NAME}/${CATALYST_NAME}.conf"
-CATALYST_DIR="/var/tmp/${CATALYST_NAME}"
-
 # Profile and build flags to use
 SUBARCH="x86"
 PROFILE="uclibc/x86/hardened"
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh
gnap-2.0/tools/gnap_overlay gnap-2.0+cleanup/tools/gnap_overlay
--- gnap-2.0/tools/gnap_overlay	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/tools/gnap_overlay	2007-08-02 15:56:18.000000000
+0300
@@ -3,8 +3,9 @@
 
 GNAPNAME=$(basename "$0")
 echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
-GNAPCORE='/usr/lib/gnap/gnap-core.tar'
-GNAPMBR='/usr/lib/gnap/mbr/mbr.bin'
+GNAPLIBDIR='/usr/lib/gnap'
+GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
+GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
 TEMPDIR=''
 IMG_SIZE=15
 
@@ -24,6 +25,11 @@
 	echo -e " ${G}*${N} ${*}"
 }
 
+gmkdir() {
+	mkdir -p "$1"
+	gtest continued $? "Failed to create directory \"$1\"."
+}
+
 gconfirm() {
 	if [[ "${FORCEYES}" -eq 1 ]]; then
 		gwarn "${*} forced to yes"
@@ -33,7 +39,7 @@
 			if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
 				cleanup
 			fi
-			echo 'Overlay aborted !'
+			echo 'Overlay aborted!'
 			exit 2
 		fi
 	fi
@@ -98,7 +104,7 @@
     echo '  -S size       Size of image file in megabyte'
     echo '  The disk target options also apply, except -d.'
     echo
-    echo "Please man ${GNAPNAME} for more details."
+    echo "Please use man ${GNAPNAME} for more details."
 }
 
 cleanup() {
@@ -126,8 +132,17 @@
 gbegin 'Checking parameters'
 
 # Read options
-while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' options; do
-	case ${options} in
+NOLOGO=0
+FORCEYES=0
+OUTPUT=''
+TYPE=''
+CREATE='n'
+TARGETROOT=''
+CACHE=''
+SERIAL=''
+BAUDRATE=''
+while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' option; do
+	case ${option} in
 		h ) usage
 			exit 0;;
 		g ) GNAPCORE="${OPTARG}";;
@@ -150,7 +165,7 @@
 		m ) CACHE='docache ';;
 		s ) SERIAL="console=ttyS0,${OPTARG}n81"
 			BAUDRATE="${OPTARG}";;
-		* ) gtest 1 'Specified options are incomplete or unknown !';;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
@@ -192,7 +207,7 @@
 	gwarn "${W}dd if=${GNAPMBR} of=${PARENTDEV} bs=512 count=1${N} if
needed"
 	gwarn "${OUTPUT} must contain an active partition:"
 	gwarn " use ${W}fdisk ${PARENTDEV}${N} if needed"
-	gwarn "Current data on ${OUTPUT} will be ${B}destroyed${N} !"
+	gwarn "Current data on ${OUTPUT} will be ${B}destroyed${N}!"
 	gconfirm 'Are you sure you want to continue ?'
 fi
 
@@ -201,20 +216,18 @@
 TEMPDIR=$(mktemp -d -t gnap_overlay.XXXXXX)
 gtest continued $? 'Failed to create temporary directory'
 TEMPCOREDIR="${TEMPDIR}/core"
-mkdir "${TEMPCOREDIR}"
-gtest continued $? 'Failed to create core temporary subdirectory'
+gmkdir "${TEMPCOREDIR}"
 tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}"
 gtest $? 'Failed to extract core'
 
 gbegin 'Preparing overlay'
 TEMPOVERDIR="${TEMPDIR}/overlay"
-mkdir "${TEMPOVERDIR}"
-gtest $? 'Failed to create overlay temporary subdirectory'
+gmkdir "${TEMPOVERDIR}"
 
 if [[ -n "${BAUDRATE}" ]]; then
 	gbegin 'Adding baudrate for serial console'
-	mkdir -p "${TEMPOVERDIR}/etc/gnap" && \
-		echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
+	gmkdir "${TEMPOVERDIR}/etc/gnap"
+	echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
 	gtest $? 'Failed to create /etc/gnap/baudrate'
 fi
 for overlay in ${OVERLAYS} ; do
@@ -231,8 +244,7 @@
 if [[ -n "${OVERLAYCONF}" ]]; then
 	gbegin "Adding ${OVERLAYCONF} (overlay.conf file)"
 	if [[ ! -d "${TEMPOVERDIR}/etc" ]]; then
-		mkdir "${TEMPOVERDIR}/etc"
-		gtest continued $? 'Failed to create /etc overlay directory'
+		gmkdir "${TEMPOVERDIR}/etc"
 	fi
 	cp "${OVERLAYCONF}" "${TEMPOVERDIR}/etc/overlay.conf"
 	gtest $? "Failed to copy ${OVERLAYCONF}"
@@ -256,7 +268,7 @@
 # Target specific actions
 if [[ "${TYPE}" == 'iso' ]]; then
 	if [[ -f "${OUTPUT}" ]]; then
-		gconfirm "File ${OUTPUT} already exists, overwrite ?"
+		gconfirm "File ${OUTPUT} already exists, overwrite?"
 	fi
 	rm "${TEMPCOREDIR}/syslinux.cfg"
 	gbegin "Building ${OUTPUT} ISO file"
@@ -285,7 +297,7 @@
 
 		if [[ "${CREATE}"  == y ]]; then
 			if [[ -f "${OUTPUT}" ]]; then
-				gconfirm "File ${OUTPUT} already exists, overwrite ?"
+				gconfirm "File ${OUTPUT} already exists, overwrite?"
 			fi
 
 			gbegin 'Creating image file'
@@ -328,8 +340,7 @@
 
 	gbegin "Mounting ${OUTPUT}"
 	TEMPMOUNTDIR="${TEMPDIR}/mount"
-	mkdir "${TEMPMOUNTDIR}"
-	gtest continued $? 'Failed to create mount temporary subdirectory'
+	gmkdir "${TEMPMOUNTDIR}"
 	mount -t msdos "${OUTPUT}" "${TEMPMOUNTDIR}"
 	gtest $?
 
@@ -375,5 +386,5 @@
 
 # Successful finish
 cleanup
-echo 'Overlay successful !'
+echo 'Overlay successful!'
 exit 0
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh
gnap-2.0/tools/gnap_remaster gnap-2.0+cleanup/tools/gnap_remaster
--- gnap-2.0/tools/gnap_remaster	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/tools/gnap_remaster	2007-08-02 15:56:39.000000000
+0300
@@ -3,11 +3,12 @@
 
 GNAPNAME=$(basename "$0")
 echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
-GNAPCORE='/usr/lib/gnap/gnap-core.tar'
-GNAPBASEFS='/usr/lib/gnap/gnap-basefs.tar.bz2'
-GNAPEXTDIR='/usr/lib/gnap/extensions'
-OUTPUT='mygnap-core.tar'
+GNAPLIBDIR='/usr/lib/gnap'
+GNAPEXTDIR="${GNAPLIBDIR}/extensions"
 TEMPDIR=''
+GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
+GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
+OUTPUT='mygnap-core.tar'
 
 G=$'\e[32;01m'
 B=$'\e[31;01m'
@@ -21,6 +22,11 @@
 	echo -e " ${W}*${N} ${*}"
 }
 
+gmkdir() {
+	mkdir -p "$1"
+	gtest continued $? "Failed to create directory \"$1\"."
+}
+
 gconfirm() {
 	if [[ "${FORCEYES}" -eq 1 ]]; then
 		gwarn "${*} forced to yes"
@@ -30,7 +36,7 @@
 			if [[ -n "${TEMPDIR}" ]]; then
 				cleanup
 			fi
-			echo 'Remaster aborted !'
+			echo 'Remaster aborted!'
 			exit 2
 		fi
 	fi
@@ -79,9 +85,9 @@
 	echo '  -g gnap_core    Original GNAP core file'
 	echo '  -b basefs       basefs.tar.bz2 file to use as base'
 	echo '  -d extdir       Directory where to find extensions'
-	echo '  -f              Force all answers to yes (dangerous !)'
+	echo '  -f              Force all answers to yes (dangerous!)'
 	echo
-	echo "Please man ${GNAPNAME} for more details."
+	echo "Please use man ${GNAPNAME} for more details."
 }
 
 cleanup() {
@@ -104,8 +110,14 @@
 gbegin 'Checking parameters'
 
 # Read options
-while getopts ':he:k:m:o:g:b:d:f' options; do
-	case ${options} in
+EXTENSIONS=''
+KERNEXT=''
+MODEXT=''
+GNAPBASEFS=''
+GNAPEXTDIR=''
+FORCEYES=0
+while getopts ':he:k:m:o:g:b:d:f' option; do
+	case ${option} in
 		h ) usage
 			exit 0;;
 		e ) EXTENSIONS="${EXTENSIONS} ${OPTARG}";;
@@ -116,7 +128,7 @@
 		b ) GNAPBASEFS="${OPTARG}";;
 		d ) GNAPEXTDIR="${OPTARG}";;
 		f ) FORCEYES=1;;
-		* ) gtest 1 'Specified options are incomplete or unknown !';;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
@@ -146,8 +158,7 @@
 TEMPDIR=$(mktemp -d -t gnap_remaster.XXXXXX)
 gtest continued $? 'Failed to create temporary directory'
 TEMPOVERDIR="${TEMPDIR}/basefs"
-mkdir "${TEMPOVERDIR}"
-gtest continued $? 'Failed to create basefs temporary subdirectory'
+gmkdir "${TEMPOVERDIR}"
 
 tar jx -C "${TEMPOVERDIR}" -f "${GNAPBASEFS}"
 gtest $? 'Failed to unpack basefs'
@@ -163,8 +174,7 @@
 # Preparing new core
 gbegin 'Extracting core tarball'
 TEMPCOREDIR="${TEMPDIR}/core"
-mkdir "${TEMPCOREDIR}"
-gtest continued $? 'Failed to create core temporary subdirectory'
+gmkdir "${TEMPCOREDIR}"
 
 tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}" --exclude image.squashfs
 gtest $? 'Failed to extract core'
@@ -172,8 +182,7 @@
 if [[ -f "${KERNEXT}" ]]; then
 	gbegin "Replacing kernel and initrd using ${KERNEXT}"
 	TEMPKERNDIR="${TEMPDIR}/kernel"
-	mkdir "${TEMPKERNDIR}"
-	gtest continued $? 'Failed to create kernel temporary subdirectory'
+	gmkdir "${TEMPKERNDIR}"
 
 	tar jx -C "${TEMPKERNDIR}" -f "${KERNEXT}"
 	gtest continued $? 'Failed to extract kernpackage'
@@ -205,6 +214,6 @@
 
 # Successful finish
 cleanup
-echo 'Remaster successful !'
+echo 'Remaster successful!'
 exit 0
 
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh
gnap-2.0/tools/packlister.pl gnap-2.0+cleanup/tools/packlister.pl
--- gnap-2.0/tools/packlister.pl	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/tools/packlister.pl	2007-07-09 21:10:18.000000000
+0300
@@ -1,49 +1,77 @@
-sub dump
+#! /usr/bin/perl
+#
+# packlister.pl prints out the given version number and a list of
+# packages found in the corresponding catalyst package cache and
+# grp cache.
+#
+# Usage: packlister.pl <version>
+#        packlister.pl <version> | reducedsnapshot.pl
+#        packlister.pl <version> > packlisterfile
+
+sub find_and_dump
 {
-  while (<FIND>)
-  {
-    if (/^(\d+)\s+(.+)\/(.+)\/(.+)$/)
-    {
-    	$size = $1;
-	$cstage = $2;
-	$cat = $3;
-	$name = $4;
-	if ($cstage =~ /.*\/(.+)-x86-.+/)
+	if (scalar @_ == 0)
 	{
-		$stage=$1;
+		return;
 	}
-	else
+	
+	open (FIND, "find $_ -name '*.tbz2' -exec ls -Ls {} \\; | "
+		. "grep -v '/All/' |");
+	
+	while (<FIND>)
 	{
-		print STDERR "ERROR ($cstage)\n";
+		if (/^(\d+)\s+(.+)\/([A-Za-z0-9+_]+[A-Za-z0-9+_.-]*)\/(.+)$/)
+		{
+			$size = $1;
+			$cstage = $2;
+			$cat = $3;
+			$name = $4;
+			
+			# There might be more than x86 supported in future versions.
+			if ($cstage =~ /.*\/(.+)-x86-.+/)
+			{
+				$stage=$1;
+			}
+			else
+			{
+				print STDERR "ERROR ($cstage)\n";
+			}
+			
+			# FIXME: The second regex (elsif) seems to match the stuff
+			# the first one also matches. Is this needed?
+			if ($name =~ /^(.+)-(.+-r\d+)\.tbz2/)
+			{
+				$packages{"$cat/$1"} = "$2 - $size Kb - $stage";
+			} 
+			elsif ($name =~ /^(.+)-(.+)\.tbz2/)
+			{
+				$packages{"$cat/$1"} = "$2 - $size Kb - $stage";
+			} 
+			else
+			{
+				print STDERR "ERROR ($name)\n"
+			}	
+		}
+		else
+		{
+			print STDERR "ERROR : $_";
+		}
 	}
-	if ($name =~ /^(.+)-(.+-r\d+)\.tbz2/)
-	{
-		$packages{"$cat/$1"} = "$2 - $size Kb - $stage";
-	} 
-	elsif ($name =~ /^(.+)-(.+)\.tbz2/)
-	{
-		$packages{"$cat/$1"} = "$2 - $size Kb - $stage";
-	} 
-	else
-	{
-		print STDERR "ERROR ($name)\n"
-	}	
-    }
-    else
-    {
-    	print STDERR "ERROR : $_";
-    }
-  }
+	
+	close (FIND);
+}
+
+# Check script parameters
+if (scalar @ARGV == 0)
+{
+	die "Usage: $ENV{_} <version>\n";
 }
+
+# Print version and file list based on catalyst
 print "$ARGV[0]\n";
-$loc = "/var/tmp/catalyst/packages/gnap/*$ARGV[0]";
-open (FIND,"find $loc -name '*.tbz2' -exec ls -Ls {} \\; | grep -v
'/All/' |");
-&dump();
-close FIND;
-$loc = "/var/tmp/catalyst/builds/gnap/grp*$ARGV[0]/*";
-open (FIND,"find $loc -name '*.tbz2' -exec ls -Ls {} \\; | grep -v
'/All/' |");
-&dump();
-close FIND;
+&find_and_dump("/var/tmp/catalyst/packages/gnap/*$ARGV[0]");
+&find_and_dump("/var/tmp/catalyst/packages/gnap/grp*$ARGV[0]/*");
+
 #No need to grab for kernel sources as they are found in the /ALL/
directory
 #$kernel=`grep sys-kernel gnap_make-$ARGV[0].out | grep merged | grep
sources`;
 #if ($kernel =~ /(sys-kernel\/.*-sources)-(.*) merged/)
@@ -54,11 +82,13 @@
 #{
 #  print STDERR "Kernel not found: $kernel\n";
 #}
+
 foreach $key (sort(keys(%packages)))
 {
-  print STDOUT "$key $packages{$key}\n";
+	print STDOUT "$key $packages{$key}\n";
 }
-  #Groff is part of the stage3 tarball but not remerged so we have to
add it manually
-  print STDOUT "sys-apps/groff 1.19.2-r1 - 116 Kb - stage3\n";
-  #htbinit is merged with kernel sources and somehow missed by the
script
-  print STDOUT "net-misc/htbinit 0.8.5-r1 - 116 Kb - livecd-stage2\n";
+
+#Groff is part of the stage3 tarball but not remerged so we have to add
it manually
+print STDOUT "sys-apps/groff 1.19.2-r1 - 116 Kb - stage3\n";
+#htbinit is merged with kernel sources and somehow missed by the script
+print STDOUT "net-misc/htbinit 0.8.5-r1 - 116 Kb - livecd-stage2\n";
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh
gnap-2.0/tools/reducedsnapshot.pl gnap-2.0
+cleanup/tools/reducedsnapshot.pl
--- gnap-2.0/tools/reducedsnapshot.pl	2007-07-23 14:14:39.000000000
+0300
+++ gnap-2.0+cleanup/tools/reducedsnapshot.pl	2007-07-23
14:16:49.000000000 +0300
@@ -1,3 +1,13 @@
+#! /usr/bin/perl
+#
+# resucedsnapshot.pl creates a reduced portage snapshot based on a
+# dfault set (eclasses, profiles) and a packagelist created by
+# packlister.pl.
+#
+# Usage: packlister.pl <version> | reducedsnapshot.pl
+#        reducedsnapshot.pl packlisterfile
+#        reducedsnapshot.pl < packlisterfile
+
 @minportage = ( 
 	"portage/eclass",
 	"portage/profiles/arch.list",
@@ -14,19 +24,21 @@
 	"portage/profiles/uclibc",
 	"portage/profiles/updates",
 	"portage/profiles/use.desc",
-	"portage/profiles/use.local.desc");
+	"portage/profiles/use.local.desc"
+);
+
 print "Building package list...\n";
 $version = <>;
 chop $version;
 while (<>)
 {
-  ($pack,$ver,,,,)=split;
-  push (@minportage,"portage/$pack");
-  push (@minportage,"portage/metadata/cache/$pack-$ver");
+	($pack,$ver,,,,) = split;
+	push (@minportage, "portage/$pack");
+	push (@minportage, "portage/metadata/cache/$pack-$ver");
 }
+
 print "Extracting portage...\n";
 system "mkdir tmp_port";
-
 system "tar jx -C tmp_port
-f /var/tmp/catalyst/snapshots/portage-$version.tar.bz2";
 print "Creating reduced portage snapshot...\n";
 system "tar jc -C tmp_port -f redportage-$version.tar.bz2 @minportage";

-- 
gnap-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gnap-dev] [PATCH 2/4] GNAP split
  2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
  2007-08-03 13:26 ` [gnap-dev] [PATCH 1/4] GNAP cleanup Philipp Riegger
@ 2007-08-03 13:32 ` Philipp Riegger
  2007-08-03 13:37 ` [gnap-dev] [PATCH 3/4] GNAP namespace Philipp Riegger
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Philipp Riegger @ 2007-08-03 13:32 UTC (permalink / raw
  To: gnap-dev

In this patch i put all the sunctions and global variables
(initialisation and read-only stuff) in gnap_shared.sh in tools. This
file is expected to be in GNAP_LIBDIR which defaults to /usr/lib/gnap. I
also initialised all variables... this is a little senseless since it
will be removed in one of the next patches, but i used it as a helper to
know which vars exist, what i have to take care of.

Philipp


diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup/src/gnap_make gnap-2.0+cleanup+split/src/gnap_make
--- gnap-2.0+cleanup/src/gnap_make	2007-08-02 15:55:38.000000000 +0300
+++ gnap-2.0+cleanup+split/src/gnap_make	2007-08-02 15:54:29.000000000
+0300
@@ -1,78 +1,9 @@
 #!/bin/bash
 GNAPVERSION='2.0'
 
-GNAPNAME=$(basename "$0")
-echo "GNAP Core Building tool ${GNAPNAME} version ${GNAPVERSION}"
 GNAPLIBDIR='/usr/lib/gnap'
-STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
-SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
-SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
-TEMPDIR=''
-
-G=$'\e[32;01m'
-B=$'\e[31;01m'
-N=$'\e[0m'
-W=$'\e[33;01m'
-K=$'\e[34;01m'
-C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
-E=$'\e['${C}'G'
-
-gwarn() {
-	echo -e " ${W}*${N} ${*}"
-}
-
-ginfo() {
-	echo -e " ${G}*${N} ${*}"
-}
-
-gmkdir() {
-	mkdir -p "$1"
-	gtest continued $? "Failed to create directory \"$1\"."
-}
-
-gconfirm() {
-	if [[ "${FORCEYES}" -eq 1 ]]; then
-		gwarn "${*} forced to yes"
-	else
-		read -ep " ${W}*${N} ${*} [N]: " answer
-		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" ]]; then
-				cleanup
-			fi
-			echo Build aborted!
-			exit 2
-		fi
-	fi
-}
-
-gbegin() {
-	echo -ne " ${G}*${N} ${*}..."
-}
-
-gtest() {
-	continued=0
-	if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
-		shift
-		continued=1
-	fi
-	if [[ "$#" -eq 0 || "${1}" -eq 0 ]]; then
-		if [[ "${continued}" -eq 0 ]]; then
-			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
-		fi
-	else
-		echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		if [[ "$#" -ge 2 ]]; then
-			shift
-			echo -en " ${B}*${N} ${*}"
-			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		fi
-		if [[ -n "${TEMPDIR}" ]]; then
-			cleanup
-		fi
-		echo "Build failed, try man ${GNAPNAME} for more help"
-		exit 1
-	fi
-}
+source ${GNAPLIBDIR}/gnap_shared.sh
+echo "GNAP Core Building tool ${GNAPNAME} version ${GNAPVERSION}"
 
 usage() {
 	echo 'Options:'
@@ -89,18 +20,6 @@
 	echo "Please use man ${GNAPNAME} for more details."
 }
 
-cleanup() {
-	gbegin 'Cleaning temporary directories'
-	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
-		rm -rf "${DIRTOREMOVE}"
-		gtest $? "Failed to remove ${DIRTOREMOVE}"
-	else
-		gtest 0
-	fi
-}
-
 if [[ "$#" -eq 0 ]]; then
 	usage
 	exit 0
@@ -109,7 +28,7 @@
 gbegin 'Checking parameters'
 
 # Catalyst executable and config file
-CATALYST_BIN="/usr/bin/catayst"
+CATALYST_BIN="/usr/bin/catalyst"
 CATALYST_CONF="/etc/catalyst/catalyst.conf"
 
 # Read options
@@ -250,7 +169,7 @@
 ginfo "${TARGETLIST}"
 
 # Confirm tarball overwrite if TARBALL stage selected
-if [[ "${TARBALL}" -eq 1 -a -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]];
then
+if [[ "${TARBALL}" -eq 1 && -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]];
then
 	gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
 fi
 
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup/tools/gnap_overlay gnap-2.0+cleanup+split/tools/gnap_overlay
--- gnap-2.0+cleanup/tools/gnap_overlay	2007-08-02 15:56:18.000000000
+0300
+++ gnap-2.0+cleanup+split/tools/gnap_overlay	2007-07-27
16:00:56.000000000 +0300
@@ -1,79 +1,11 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAPNAME=$(basename "$0")
-echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
 GNAPLIBDIR='/usr/lib/gnap'
-GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
-GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
-TEMPDIR=''
-IMG_SIZE=15
-
-G=$'\e[32;01m'
-B=$'\e[31;01m'
-N=$'\e[0m'
-W=$'\e[33;01m'
-K=$'\e[34;01m'
-C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
-E=$'\e['${C}'G'
-
-gwarn() {
-	echo -e " ${W}*${N} ${*}"
-}
-
-ginfo() {
-	echo -e " ${G}*${N} ${*}"
-}
-
-gmkdir() {
-	mkdir -p "$1"
-	gtest continued $? "Failed to create directory \"$1\"."
-}
-
-gconfirm() {
-	if [[ "${FORCEYES}" -eq 1 ]]; then
-		gwarn "${*} forced to yes"
-	else
-		read -ep " ${W}*${N} ${*} [N]: " answer
-		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
-				cleanup
-			fi
-			echo 'Overlay aborted!'
-			exit 2
-		fi
-	fi
-}
-
-gbegin() {
-	echo -ne " ${G}*${N} ${*}..."
-}
-
-gtest() {
-	continued=0
-	if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
-		shift
-		continued=1
-	fi
+source ${GNAPLIBDIR}/gnap_shared.sh
+echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
 
-	if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
-		if [[ "${continued}" -eq 0 ]]; then
-			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
-		fi
-	else
-		echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		if [[ "$#" -ge 2 ]]; then
-			shift
-			echo -en " ${B}*${N} ${*}"
-			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		fi
-		if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
-			cleanup
-		fi
-		echo "Overlay failed, try ${GNAPNAME} -h for more help"
-		exit 1
-	fi
-}
+IMG_SIZE=15
 
 usage() {
 	echo
@@ -107,23 +39,6 @@
     echo "Please use man ${GNAPNAME} for more details."
 }
 
-cleanup() {
-	if [[ -n "${LOOP}" ]]; then
-		gbegin 'Unmounting loop filesystem'
-		umount "${LOOP}" && losetup -d "${LOOP}"
-		gtest $? "Failed to unmount ${LOOP}"
-	fi
-	gbegin 'Cleaning temporary directories'
-	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
-		rm -rf "${DIRTOREMOVE}"
-		gtest $? "Failed to remove ${DIRTOREMOVE}"
-	else
-		gtest 0
-	fi
-}
-
 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
 	usage
 	exit 0
@@ -226,7 +141,7 @@
 
 if [[ -n "${BAUDRATE}" ]]; then
 	gbegin 'Adding baudrate for serial console'
-	gmkdir "${TEMPOVERDIR}/etc/gnap"
+	gmkdir -p "${TEMPOVERDIR}/etc/gnap"
 	echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
 	gtest $? 'Failed to create /etc/gnap/baudrate'
 fi
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup/tools/gnap_remaster gnap-2.0+cleanup+split/tools/gnap_remaster
--- gnap-2.0+cleanup/tools/gnap_remaster	2007-08-02 15:56:39.000000000
+0300
+++ gnap-2.0+cleanup+split/tools/gnap_remaster	2007-07-27
16:10:54.000000000 +0300
@@ -1,76 +1,11 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAPNAME=$(basename "$0")
-echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
 GNAPLIBDIR='/usr/lib/gnap'
-GNAPEXTDIR="${GNAPLIBDIR}/extensions"
-TEMPDIR=''
-GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
-GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
-OUTPUT='mygnap-core.tar'
-
-G=$'\e[32;01m'
-B=$'\e[31;01m'
-N=$'\e[0m'
-W=$'\e[33;01m'
-K=$'\e[34;01m'
-C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
-E=$'\e['${C}'G'
-
-gwarn() {
-	echo -e " ${W}*${N} ${*}"
-}
-
-gmkdir() {
-	mkdir -p "$1"
-	gtest continued $? "Failed to create directory \"$1\"."
-}
-
-gconfirm() {
-	if [[ "${FORCEYES}" -eq 1 ]]; then
-		gwarn "${*} forced to yes"
-	else
-		read -ep " ${W}*${N} ${*} [N]: " answer
-		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" ]]; then
-				cleanup
-			fi
-			echo 'Remaster aborted!'
-			exit 2
-		fi
-	fi
-}
-
-gbegin() {
-	echo -ne " ${G}*${N} ${*}..."
-}
+source ${GNAPLIBDIR}/gnap_shared.sh
+echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
 
-gtest() {
-	continued=0
-	if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
-		shift
-		continued=1
-	fi
-
-	if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
-		if [[ "${continued}" -eq 0 ]]; then
-			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
-		fi
-	else
-		echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		if [[ "$#" -ge 2 ]]; then
-			shift
-			echo -en " ${B}*${N} ${*}"
-			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		fi
-		if [[ -n "${TEMPDIR}" ]]; then
-			cleanup
-		fi
-		echo "Remaster failed, try ${GNAPNAME} -h for more help"
-		exit 1
-	fi
-}
+OUTPUT='mygnap-core.tar'
 
 usage() {
 	echo
@@ -90,18 +25,6 @@
 	echo "Please use man ${GNAPNAME} for more details."
 }
 
-cleanup() {
-	gbegin 'Cleaning temporary directories'
-	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
-	 	rm -rf "${DIRTOREMOVE}"
-		gtest $? "Failed to remove ${DIRTOREMOVE}"
-	else
-		gtest 0
-	fi
-}
-
 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
 	usage
 	exit 0
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup/tools/gnap_shared.sh gnap-2.0+cleanup
+split/tools/gnap_shared.sh
--- gnap-2.0+cleanup/tools/gnap_shared.sh	2007-08-03 16:28:37.000000000
+0300
+++ gnap-2.0+cleanup+split/tools/gnap_shared.sh	2007-08-02
15:54:46.000000000 +0300
@@ -0,0 +1,102 @@
+GNAPNAME=$(basename "$0")
+
+case ${GNAPNAME} in
+	gnap_make )     GNAP_PRODUCT="Build";;
+ 	gnap_overlay )  GNAP_PRODUCT="Overlay";;
+ 	gnap_remaster ) GNAP_PRODUCT="Remaster";;
+ 	* )             GNAP_PRODUCT="Something";;
+esac
+STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
+SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
+SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
+GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
+GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
+GNAPEXTDIR="${GNAPLIBDIR}/extensions"
+GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
+
+TEMPDIR=''
+LOOP=''
+FORCEYES=0
+
+G=$'\e[32;01m'
+B=$'\e[31;01m'
+N=$'\e[0m'
+W=$'\e[33;01m'
+K=$'\e[34;01m'
+C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
+E=$'\e['${C}'G'
+
+gwarn() {
+	echo -e " ${W}*${N} ${*}"
+}
+
+ginfo() {
+	echo -e " ${G}*${N} ${*}"
+}
+
+gmkdir() {
+	mkdir -p "$1"
+	gtest continued $? "Failed to create \"$1\"."
+}
+
+gconfirm() {
+	if [[ "${FORCEYES}" -eq 1 ]]; then
+		gwarn "${*} forced to yes"
+	else
+		read -ep " ${W}*${N} ${*} [N]: " answer
+		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
+			if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
+				cleanup
+			fi
+			echo '${GNAP_PRODUCT} aborted!'
+			exit 2
+		fi
+	fi
+}
+
+gbegin() {
+	echo -ne " ${G}*${N} ${*}..."
+}
+
+gtest() {
+	continued=0
+	if [[ "${#}" -gt 0 && "${1}" == 'continued' ]]; then
+		shift
+		continued=1
+	fi
+
+	if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
+		if [[ "${continued}" -eq 0 ]]; then
+			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
+		fi
+	else
+		echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
+		if [[ "${#}" -ge 2 ]]; then
+			shift
+			echo -en " ${B}*${N} ${*}"
+			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
+		fi
+		if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
+			cleanup
+		fi
+		echo " ${GNAP_PRODUCT} failed, try ${GNAPNAME} -h for more help"
+		exit 1
+	fi
+}
+
+cleanup() {
+	if [[ -n "${LOOP}" ]]; then
+		gbegin 'Unmounting loop filesystem'
+		umount "${LOOP}" && losetup -d "${LOOP}"
+		gtest $? "Failed to unmount ${LOOP}"
+	fi
+	gbegin 'Cleaning temporary directories'
+	if [[ -d "${TEMPDIR}" ]]; then
+		DIRTOREMOVE="${TEMPDIR}"
+		TEMPDIR=''
+		rm -rf "${DIRTOREMOVE}"
+		gtest $? "Failed to remove ${DIRTOREMOVE}"
+	else
+		gtest 0
+	fi
+}

-- 
gnap-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gnap-dev] [PATCH 3/4] GNAP namespace
  2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
  2007-08-03 13:26 ` [gnap-dev] [PATCH 1/4] GNAP cleanup Philipp Riegger
  2007-08-03 13:32 ` [gnap-dev] [PATCH 2/4] GNAP split Philipp Riegger
@ 2007-08-03 13:37 ` Philipp Riegger
  2007-08-03 13:53 ` [gnap-dev] [PATCH 4/4] GNAP environment Philipp Riegger
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Philipp Riegger @ 2007-08-03 13:37 UTC (permalink / raw
  To: gnap-dev

This patch clears up the gnap namespace:

I use the GNAP_ prefix for all variables that are directly configurable
by the user, names without GNAP_ are either internally used or not
changeable by the user.

Some of the GNAP_* vars are not changeable by the user in this patch but
will be in the next one.

The variables from common.conf are not changed to GNAP_ since i thought
they were special and i did not make the names longer. But this could be
changed of course.

Philipp


diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup+split/src/gnap_make gnap-2.0+cleanup+split
+namespace/src/gnap_make
--- gnap-2.0+cleanup+split/src/gnap_make	2007-08-02 15:54:29.000000000
+0300
+++ gnap-2.0+cleanup+split+namespace/src/gnap_make	2007-08-02
15:50:45.000000000 +0300
@@ -1,9 +1,9 @@
 #!/bin/bash
-GNAPVERSION='2.0'
+VERSION='2.0'
 
-GNAPLIBDIR='/usr/lib/gnap'
-source ${GNAPLIBDIR}/gnap_shared.sh
-echo "GNAP Core Building tool ${GNAPNAME} version ${GNAPVERSION}"
+GNAP_LIBDIR='/usr/lib/gnap'
+source ${GNAP_LIBDIR}/gnap_shared.sh
+echo "GNAP Core Building tool ${NAME} version ${VERSION}"
 
 usage() {
 	echo 'Options:'
@@ -17,7 +17,7 @@
 	echo '    -c catalyst.conf     Use specific catalyst.conf file'
 	echo '    -e specs             Specs directory or tar.bz2 file'
 	echo
-	echo "Please use man ${GNAPNAME} for more details."
+	echo "Please use man ${NAME} for more details."
 }
 
 if [[ "$#" -eq 0 ]]; then
@@ -28,58 +28,64 @@
 gbegin 'Checking parameters'
 
 # Catalyst executable and config file
-CATALYST_BIN="/usr/bin/catalyst"
-CATALYST_CONF="/etc/catalyst/catalyst.conf"
+GNAP_CATALYST_BIN="/usr/bin/catalyst"
+GNAP_CATALYST_CONF="/etc/catalyst/catalyst.conf"
 
 # Read options
+GNAP_STAGE3=0
+GNAP_LIVECD1=0
+GNAP_LIVECD2=0
+GNAP_TARBALL=0
+GNAP_MODULES=0
+GNAP_STAMP=$(date +%Y%m%d)
 NOTARGET=1
-STAMP=$(date +%Y%m%d)
+NEEDS_SNAPSHOT=0
 while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
 	case ${option} in
 		h )
 			usage
 			exit 0;;
-		s ) STAGE3FILE="${OPTARG}";;
-		p ) SNAPSHOTFILE="${OPTARG}";;
-		o ) PORTAGE_OVERLAYS="${PORTAGE_OVERLAYS} ${OPTARG}";;
-		v ) STAMP="${OPTARG}";;
+		s ) GNAP_STAGE3FILE="${OPTARG}";;
+		p ) GNAP_SNAPSHOTFILE="${OPTARG}";;
+		o ) GNAP_PORTAGE_OVERLAYS="${GNAP_PORTAGE_OVERLAYS} ${OPTARG}";;
+		v ) GNAP_STAMP="${OPTARG}";;
 		t )
 			case "${OPTARG}" in
 				all )
-					STAGE3=1
-					LIVECD1=1
-					LIVECD2=1
-					TARBALL=1
-					MODULES=1
+					GNAP_STAGE3=1
+					GNAP_LIVECD1=1
+					GNAP_LIVECD2=1
+					GNAP_TARBALL=1
+					GNAP_MODULES=1
 					NEEDS_SNAPSHOT=1;;
 				stage3 )
-					STAGE3=1
+					GNAP_STAGE3=1
 					NEEDS_SNAPSHOT=1;;
 				livecd-stage1 )
-					LIVECD1=1
+					GNAP_LIVECD1=1
 					NEEDS_SNAPSHOT=1;;
 				livecd-stage2 )
-					LIVECD2=1
+					GNAP_LIVECD2=1
 					NEEDS_SNAPSHOT=1;;
 				tarball )
-					TARBALL=1;;
+					GNAP_TARBALL=1;;
 				extensions )
-					MODULES=1
+					GNAP_MODULES=1
 					NEEDS_SNAPSHOT=1;;
 				* ) gtest 1 'Specified stage is unknown!';;
 			esac
 			NOTARGET=0;;
-		f ) FORCEYES=1;;
-		l ) GNAPLOGPREFIX="${OPTARG}";;
-		c ) CATALYST_CONF="${OPTARG}";;
-		e ) SPECS="${OPTARG}";;
+		f ) GNAP_FORCEYES=1;;
+		l ) GNAP_LOGPREFIX="${OPTARG}";;
+		c ) GNAP_CATALYST_CONF="${OPTARG}";;
+		e ) GNAP_SPECS="${OPTARG}";;
 		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
 # Root is needed
 test "${EUID}" -eq 0
-gtest continued $? "You need to be root to run ${GNAPNAME}"
+gtest continued $? "You need to be root to run ${NAME}"
 
 # Setting up temporary directory
 TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
@@ -87,15 +93,15 @@
 
 # Prepare specs dir and check common.conf file
 SPECDIR="${TEMPDIR}/specs"
-if [[ -f "${SPECS}" ]]; then
+if [[ -f "${GNAP_SPECS}" ]]; then
 	gmkdir "${SPECDIR}"
-	tar jx -f "${SPECS}" -C "${SPECDIR}"
+	tar jx -f "${GNAP_SPECS}" -C "${SPECDIR}"
 	gtest continued $? 'Failed to unpack specs'
-elif [[ -d "${SPECS}" ]]; then
-	cp -rp "${SPECS}" "${SPECDIR}"
+elif [[ -d "${GNAP_SPECS}" ]]; then
+	cp -rp "${GNAP_SPECS}" "${SPECDIR}"
 	gtest continued $? 'Failed to copy specs directory contents'
 else
-	gtest continued 1 "${SPECS} not found, provide a valid -e option"
+	gtest continued 1 "${GNAP_SPECS} not found, provide a valid -e option"
 fi
 test -f "${SPECDIR}/common.conf"
 gtest continued $? "Incorrect specdir: ${SPECDIR}/common.conf not
found!"
@@ -108,9 +114,9 @@
 fi
 
 # catalyst.conf file
-test -f "${CATALYST_CONF}"
-gtest continued $? "${CATALYST_CONF} file not found!"
-source "${CATALYST_CONF}"
+test -f "${GNAP_CATALYST_CONF}"
+gtest continued $? "${GNAP_CATALYST_CONF} file not found!"
+source "${GNAP_CATALYST_CONF}"
 
 # At least one target is needed
 test "${NOTARGET}" -eq 0
@@ -121,76 +127,76 @@
 gmkdir "${storedir}"
 
 # Stage3 needs a seed stage
-if [[ "${STAGE3}" -eq 1 ]]; then
-	test -f "${STAGE3FILE}"
+if [[ "${GNAP_STAGE3}" -eq 1 ]]; then
+	test -f "${GNAP_STAGE3FILE}"
 	gtest continued $? 'The "-s" option needs to designate a valid seed
stage'
 fi
 
 # Snapshot must exist if a stage is selected
 if [[ "${NEEDS_SNAPSHOT}" -eq 1 ]]; then
-	test -f "${SNAPSHOTFILE}"
-	gtest continued $? "Can't find ${SNAPSHOTFILE}"
+	test -f "${GNAP_SNAPSHOTFILE}"
+	gtest continued $? "Can't find ${GNAP_SNAPSHOTFILE}"
 fi
 
 # Seed stage if needed must be an existing file
-if [[ "${STAGE3}" -eq 1 ]]; then
-	test -f "${STAGE3FILE}"
-	gtest continued $? "${STAGE3FILE} is not a valid stage3 tarball"
+if [[ "${GNAP_STAGE3}" -eq 1 ]]; then
+	test -f "${GNAP_STAGE3FILE}"
+	gtest continued $? "${GNAP_STAGE3FILE} is not a valid stage3 tarball"
 fi
 
 # If extensions and no stage3, warn that we'll use seedstage as stage3
-STAGE3LOC="${storedir}/builds/${RELTYPE}/stage3-${SUBARCH}-${STAMP}.tar.bz2"
-if [[ "${MODULES}" -eq 1 || "${LIVECD1}" -eq 1 ]]; then
-	if [[ "${STAGE3}" -ne 1 && ! -f "${STAGE3LOC}" ]]; then
+STAGE3LOC="${storedir}/builds/${RELTYPE}/stage3-${SUBARCH}-${GNAP_STAMP}.tar.bz2"
+if [[ "${GNAP_MODULES}" -eq 1 || "${GNAP_LIVECD1}" -eq 1 ]]; then
+	if [[ "${GNAP_STAGE3}" -ne 1 && ! -f "${STAGE3LOC}" ]]; then
 		gwarn '"livecd-stage1" or "extensions" was selected without
"stage3".'
 		gconfirm 'Should I use the seed stage as stage3 result?'
 		gmkdir "${storedir}/builds/${RELTYPE}"
-		cp "${STAGE3FILE}" "${STAGE3LOC}"
+		cp "${GNAP_STAGE3FILE}" "${STAGE3LOC}"
 	fi
 fi
 
 # Explain what will get built
-if [[ "${STAGE3}" -eq 1 ]]; then
+if [[ "${GNAP_STAGE3}" -eq 1 ]]; then
 	TARGETLIST='[stage3] '
 fi
-if [[ "${LIVECD1}" -eq 1 ]]; then
+if [[ "${GNAP_LIVECD1}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[livecd-stage1] "
 fi
-if [[ "${LIVECD2}" -eq 1 ]]; then
+if [[ "${GNAP_LIVECD2}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[livecd-stage2] "
 fi
-if [[ "${TARBALL}" -eq 1 ]]; then
+if [[ "${GNAP_TARBALL}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[tarball] "
 fi
-if [[ "${MODULES}" -eq 1 ]]; then
+if [[ "${GNAP_MODULES}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[extensions]"
 fi
 ginfo 'The following targets will be called:'
 ginfo "${TARGETLIST}"
 
 # Confirm tarball overwrite if TARBALL stage selected
-if [[ "${TARBALL}" -eq 1 && -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]];
then
-	gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
+if [[ "${GNAP_TARBALL}" -eq 1 && -e
"gnap-${VERSION}-${GNAP_STAMP}.tar" ]]; then
+	gconfirm "gnap-${VERSION}-${GNAP_STAMP}.tar already exists, overwrite"
 fi
 
 # Logfile setup and confirmation
-if [[ -z "$GNAPLOGPREFIX" ]]; then
-	GNAPLOGPREFIX="./${GNAPNAME}-${STAMP}"
+if [[ -z "$GNAP_LOGPREFIX" ]]; then
+	GNAP_LOGPREFIX="./${NAME}-${GNAP_STAMP}"
 fi
 
-if [[ -f "${GNAPLOGPREFIX}.out" || -f "${GNAPLOGPREFIX}.err" ]]; then
-	if [[ "${FORCEYES}" -ne 1 ]]; then
+if [[ -f "${GNAP_LOGPREFIX}.out" || -f "${GNAP_LOGPREFIX}.err" ]]; then
+	if [[ "${GNAP_FORCEYES}" -ne 1 ]]; then
 		read -ep \
 			" ${W}*${N} Logfile(s) already exists. Append/Overwrite [A]: " \
 			answer
 		if [[ "${answer}" == 'o' || "${answer}" == 'O' ]]; then
-			rm "${GNAPLOGPREFIX}.out" "${GNAPLOGPREFIX}.err"
+			rm "${GNAP_LOGPREFIX}.out" "${GNAP_LOGPREFIX}.err"
 		fi
 	fi
 fi
-touch "${GNAPLOGPREFIX}.out"
-touch "${GNAPLOGPREFIX}.err"
-SEELOGFILES="see ${GNAPLOGPREFIX}.err and .out for details"
+touch "${GNAP_LOGPREFIX}.out"
+touch "${GNAP_LOGPREFIX}.err"
+SEELOGFILES="see ${GNAP_LOGPREFIX}.err and .out for details"
 
 # Snapshot preparation
 if [[ "${NEEDS_SNAPSHOT}" -eq 1 ]]; then
@@ -198,34 +204,34 @@
 
 	gmkdir "${storedir}/snapshots"
 
-	if [[ -z "${PORTAGE_OVERLAYS}" ]]; then
-		cp "${SNAPSHOTFILE}" "${storedir}/snapshots/portage-${STAMP}.tar.bz2"
+	if [[ -z "${GNAP_PORTAGE_OVERLAYS}" ]]; then
+		cp "${GNAP_SNAPSHOTFILE}"
"${storedir}/snapshots/portage-${GNAP_STAMP}.tar.bz2"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
 	else
 		TEMPPRTDIR="${TEMPDIR}/portage"
 		gmkdir "${TEMPPRTDIR}"
 
-		tar jxf "${SNAPSHOTFILE}" -C "${TEMPPRTDIR}" \
-			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+		tar jxf "${GNAP_SNAPSHOTFILE}" -C "${TEMPPRTDIR}" \
+			>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 
-		for overlay in ${PORTAGE_OVERLAYS} ; do
+		for overlay in ${GNAP_PORTAGE_OVERLAYS} ; do
 			cp -rp ${overlay}/* "${TEMPPRTDIR}/portage"
 			gtest continued $? "Failed to copy ${overlay}"
 		done
 
-		tar jcf "${storedir}/snapshots/portage-${STAMP}.tar.bz2" \
+		tar jcf "${storedir}/snapshots/portage-${GNAP_STAMP}.tar.bz2" \
 			-C "${TEMPPRTDIR}" . \
-			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+			>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
 	fi
 fi
 
 # Stage3 phase
-if [[ "${STAGE3}" -eq 1 ]]; then
+if [[ "${GNAP_STAGE3}" -eq 1 ]]; then
 	gbegin "${G}[stage3]${N} stage (base system build)"
 
 	gmkdir "${storedir}/builds/${RELTYPE}"
-	cp "${STAGE3FILE}" "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
+	cp "${GNAP_STAGE3FILE}"
"${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
 
 	TEMPCONF="${TEMPDIR}/stage3.conf"
 	touch "${TEMPCONF}"
@@ -235,20 +241,20 @@
 ${DISTCCSPEC}
 subarch: ${SUBARCH}
 rel_type: ${RELTYPE}
-snapshot: ${STAMP}
-version_stamp: ${STAMP}
+snapshot: ${GNAP_STAMP}
+version_stamp: ${GNAP_STAMP}
 profile: ${PROFILE}
 source_subpath: ${RELTYPE}/seedstage
 portage_confdir: ${SPECDIR}/portage_confdir
 EOF
-	$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
-		>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+	$GNAP_CATALYST_BIN -c "${GNAP_CATALYST_CONF}" -f "${TEMPCONF}" \
+		>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 	gtest $? "[stage3] failed, ${SEELOGFILES}"
 	rm "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
 fi
 
 # LIVECD-STAGE1 phase
-if [[ "${LIVECD1}" -eq 1 ]]; then
+if [[ "${GNAP_LIVECD1}" -eq 1 ]]; then
 	gbegin "${G}[livecd-stage1]${N} stage (GNAP-specific packages build)"
 	TEMPCONF="${TEMPDIR}/livecd-stage1.conf"
 	touch "${TEMPCONF}"
@@ -258,21 +264,21 @@
 ${DISTCCSPEC}
 subarch: ${SUBARCH}
 rel_type: ${RELTYPE}
-snapshot: ${STAMP}
-version_stamp: ${STAMP}
+snapshot: ${GNAP_STAMP}
+version_stamp: ${GNAP_STAMP}
 profile: ${PROFILE}
-source_subpath: ${RELTYPE}/stage3-${SUBARCH}-${STAMP}
+source_subpath: ${RELTYPE}/stage3-${SUBARCH}-${GNAP_STAMP}
 portage_confdir: ${SPECDIR}/portage_confdir
 EOF
 	cat "${SPECDIR}/packages.conf" >> "${TEMPCONF}"
 
-	$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
-		>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+	$GNAP_CATALYST_BIN -c "${GNAP_CATALYST_CONF}" -f "${TEMPCONF}" \
+		>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 	gtest $? "[livecd-stage1] failed, ${SEELOGFILES}"
 fi
 
 # LIVECD-STAGE2 phase
-if [[ "${LIVECD2}" -eq 1 ]]; then
+if [[ "${GNAP_LIVECD2}" -eq 1 ]]; then
 	gbegin "${G}[livecd-stage2]${N} stage (kernel and LiveCD builds)"
 	TEMPCONF="${TEMPDIR}/livecd-stage2.conf"
 	touch "${TEMPCONF}"
@@ -282,30 +288,30 @@
 ${DISTCCSPEC}
 subarch: ${SUBARCH}
 rel_type: ${RELTYPE}
-snapshot: ${STAMP}
-version_stamp: ${STAMP}
+snapshot: ${GNAP_STAMP}
+version_stamp: ${GNAP_STAMP}
 profile: ${PROFILE}
-source_subpath: ${RELTYPE}/livecd-stage1-${SUBARCH}-${STAMP}
+source_subpath: ${RELTYPE}/livecd-stage1-${SUBARCH}-${GNAP_STAMP}
 boot/kernel/gentoo/sources: ${KERNEL_SOURCES}
 boot/kernel/gentoo/config: ${SPECDIR}/kernel.config
-boot/kernel/gentoo/extraversion: GNAP-${GNAPVERSION}
-livecd/iso: gnap-${GNAPVERSION}-${STAMP}.iso
+boot/kernel/gentoo/extraversion: GNAP-${VERSION}
+livecd/iso: gnap-${VERSION}-${GNAP_STAMP}.iso
 livecd/fsscript: ${SPECDIR}/fsscript
 livecd/root_overlay: ${SPECDIR}/root_overlay
 EOF
 	cat "${SPECDIR}/livecd.conf" >> "${TEMPCONF}"
 
-	$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
-		>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+	$GNAP_CATALYST_BIN -c "${GNAP_CATALYST_CONF}" -f "${TEMPCONF}" \
+		>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 	gtest $? "[livecd-stage2] failed, ${SEELOGFILES}"
 fi
 
 # TARBALL phase
-if [[ "${TARBALL}" -eq 1 ]]; then
+if [[ "${GNAP_TARBALL}" -eq 1 ]]; then
 	gbegin "${G}[tarball]${N} phase (Creation of core and basefs
components)"
-	test -e "gnap-${GNAPVERSION}-${STAMP}.iso"
-	gtest continued $? "No gnap-${GNAPVERSION}-${STAMP}.iso file to
convert !"
-	test -d "${storedir}/tmp/gnap/livecd-stage1-${SUBARCH}-${STAMP}"
+	test -e "gnap-${VERSION}-${GNAP_STAMP}.iso"
+	gtest continued $? "No gnap-${VERSION}-${GNAP_STAMP}.iso file to
convert !"
+	test -d "${storedir}/tmp/gnap/livecd-stage1-${SUBARCH}-${GNAP_STAMP}"
 	gtest $? 'Missing livecd-stage2 results'
 
 	gbegin '  Creating core component'
@@ -314,7 +320,7 @@
 	TEMPISODIR="${TEMPDIR}/iso"
 	gmkdir "${TEMPISODIR}"
 
-	mount -o loop "gnap-${GNAPVERSION}-${STAMP}.iso" ${TEMPMNTDIR} && \
+	mount -o loop "gnap-${VERSION}-${GNAP_STAMP}.iso" ${TEMPMNTDIR} && \
 		cp -r ${TEMPMNTDIR}/* ${TEMPISODIR}
 	gtest continued $? 'Failed to mount ISO and copy files'
 	umount "${TEMPMNTDIR}"
@@ -324,23 +330,23 @@
 	cp "${SPECDIR}/isolinux/syslinux.cfg" ${TEMPISODIR}/
 	cp "${SPECDIR}/isolinux/boot.msg" ${TEMPISODIR}/isolinux/
 	DATE=$(date --utc)
-	echo "GNAP-${GNAPVERSION}-${STAMP} built on ${DATE}" \
+	echo "GNAP-${VERSION}-${GNAP_STAMP} built on ${DATE}" \
 		>> "${TEMPISODIR}/isolinux/boot.msg"
 
-	tar cf "gnap-${GNAPVERSION}-${STAMP}.tar" -C "${TEMPISODIR}" .
+	tar cf "gnap-${VERSION}-${GNAP_STAMP}.tar" -C "${TEMPISODIR}" .
 	gtest $? 'Failed to create tarball'
-	rm "gnap-${GNAPVERSION}-${STAMP}.iso"
+	rm "gnap-${VERSION}-${GNAP_STAMP}.iso"
 
 	gbegin '  Creating basefs component'
-	tar jcf "gnap-basefs-${GNAPVERSION}-${STAMP}.tar.bz2" \
-		-C "${storedir}/tmp/gnap/livecd-stage2-${SUBARCH}-${STAMP}" .
+	tar jcf "gnap-basefs-${VERSION}-${GNAP_STAMP}.tar.bz2" \
+		-C "${storedir}/tmp/gnap/livecd-stage2-${SUBARCH}-${GNAP_STAMP}" .
 	gtest $? 'Unable to create basefs tarball'
 fi
 
 # EXTENSIONS phase
-if [[ "${MODULES}" -eq 1 ]]; then
+if [[ "${GNAP_MODULES}" -eq 1 ]]; then
 	gbegin "${G}[extensions]${N} stage start"
-	GRP_PREFIX="${storedir}/builds/${RELTYPE}/grp-${SUBARCH}-${STAMP}"
+
GRP_PREFIX="${storedir}/builds/${RELTYPE}/grp-${SUBARCH}-${GNAP_STAMP}"
 	SPECMODULE="${SPECDIR}/extensions.conf"
 	mod_list=$(grep '^extensions:' "${SPECMODULE}" 2>/dev/null);
 	mod_list="${mod_list/extensions:/}"
@@ -362,25 +368,25 @@
 ${DISTCCSPEC}
 subarch: ${SUBARCH}
 rel_type: ${RELTYPE}
-snapshot: ${STAMP}
-version_stamp: ${STAMP}
+snapshot: ${GNAP_STAMP}
+version_stamp: ${GNAP_STAMP}
 profile: ${PROFILE}
-source_subpath: ${RELTYPE}/stage3-${SUBARCH}-${STAMP}
+source_subpath: ${RELTYPE}/stage3-${SUBARCH}-${GNAP_STAMP}
 grp: ${mod_name}
 grp/use: ${mod_useflags}
 grp/${mod_name}/type: pkgset
 grp/${mod_name}/packages: ${mod_packlist}
 EOF
 
-		$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
-			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+		$GNAP_CATALYST_BIN -c "${GNAP_CATALYST_CONF}" -f "${TEMPCONF}" \
+			>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 		gtest continued $? "Extension build failed, ${SEELOGFILES}"
 
 		TEMPMODULEDIR="${TEMPDIR}/module_${mod_name}"
 		gmkdir "${TEMPMODULEDIR}"
 		for pkg in $( ls ${GRP_PREFIX}/${mod_name}/All/*.tbz2 ); do
 			tar jxf $pkg -C "${TEMPMODULEDIR}" -p \
-				>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+				>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 		done
 		gtest continued $? 'Failed to unpack extension packages'
 
@@ -392,9 +398,9 @@
 		rm -rf ${mod_rmlist}
 		gtest continued $? 'Failed to apply extension cleanup instructions'
 
-		tar jcf "gnapext_${mod_name}-${STAMP}.tbz2" \
+		tar jcf "gnapext_${mod_name}-${GNAP_STAMP}.tbz2" \
 			-C "${TEMPMODULEDIR}" . \
-			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+			>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 		gtest $? 'Failed to build extension file'
 	done
 fi
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup+split/tools/gnap_overlay gnap-2.0+cleanup+split
+namespace/tools/gnap_overlay
--- gnap-2.0+cleanup+split/tools/gnap_overlay	2007-07-27
16:00:56.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace/tools/gnap_overlay	2007-07-27
16:00:02.000000000 +0300
@@ -1,17 +1,15 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAPLIBDIR='/usr/lib/gnap'
-source ${GNAPLIBDIR}/gnap_shared.sh
-echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
-
-IMG_SIZE=15
+GNAP_LIBDIR='/usr/lib/gnap'
+source ${GNAP_LIBDIR}/gnap_shared.sh
+echo "GNAP overlay tool ${NAME} ${VERSION}"
 
 usage() {
 	echo
     echo 'Usage:'
-    echo "  ${GNAPNAME} -i isoname -o overlay [ options ]"
-    echo "  ${GNAPNAME} -d hostdisk -r rootdev -o overlay [ options ]"
+    echo "  ${NAME} -i isoname -o overlay [ options ]"
+    echo "  ${NAME} -d hostdisk -r rootdev -o overlay [ options ]"
     echo
     echo 'Common options:'
     echo '  -o overlay    Overlay directory or tbz2 file'
@@ -36,7 +34,7 @@
     echo '  -S size       Size of image file in megabyte'
     echo '  The disk target options also apply, except -d.'
     echo
-    echo "Please use man ${GNAPNAME} for more details."
+    echo "Please use man ${NAME} for more details."
 }
 
 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
@@ -47,105 +45,106 @@
 gbegin 'Checking parameters'
 
 # Read options
-NOLOGO=0
-FORCEYES=0
-OUTPUT=''
-TYPE=''
-CREATE='n'
-TARGETROOT=''
-CACHE=''
-SERIAL=''
-BAUDRATE=''
+GNAP_NOLOGO=0
+GNAP_FORCEYES=0
+GNAP_OUTPUT=''
+GNAP_TYPE=''
+GNAP_CREATE='n'
+GNAP_IMG_SIZE=15
+GNAP_TARGETROOT=''
+GNAP_CACHE=''
+GNAP_SERIAL=''
+GNAP_BAUDRATE=''
 while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' option; do
 	case ${option} in
 		h ) usage
 			exit 0;;
-		g ) GNAPCORE="${OPTARG}";;
-		o ) OVERLAYS="${OVERLAYS} ${OPTARG}";;
-		c ) OVERLAYCONF="${OPTARG}";;
-		n ) NOLOGO=1;;
-		f ) FORCEYES=1;;
-		i ) OUTPUT="${OPTARG}"
-			TYPE='iso';;
-		d ) OUTPUT="${OPTARG}"
-			TYPE='disk';;
-		l ) OUTPUT="${OPTARG}"
-			TYPE='image'
-			CREATE='n';;
-		L ) OUTPUT="${OPTARG}"
-			TYPE='image'
-			CREATE='y';;
-		S ) IMG_SIZE="${OPTARG}";;
-		r ) TARGETROOT="${OPTARG}";;
-		m ) CACHE='docache ';;
-		s ) SERIAL="console=ttyS0,${OPTARG}n81"
-			BAUDRATE="${OPTARG}";;
+		g ) GNAP_CORE="${OPTARG}";;
+		o ) GNAP_OVERLAYS="${GNAP_OVERLAYS} ${OPTARG}";;
+		c ) GNAP_OVERLAY_CONF="${OPTARG}";;
+		n ) GNAP_NOLOGO=1;;
+		f ) GNAP_FORCEYES=1;;
+		i ) GNAP_OUTPUT="${OPTARG}"
+			GNAP_TYPE='iso';;
+		d ) GNAP_OUTPUT="${OPTARG}"
+			GNAP_TYPE='disk';;
+		l ) GNAP_OUTPUT="${OPTARG}"
+			GNAP_TYPE='image'
+			GNAP_CREATE='n';;
+		L ) GNAP_OUTPUT="${OPTARG}"
+			GNAP_TYPE='image'
+			GNAP_CREATE='y';;
+		S ) GNAP_IMG_SIZE="${OPTARG}";;
+		r ) GNAP_TARGETROOT="${OPTARG}";;
+		m ) GNAP_CACHE='docache ';;
+		s ) GNAP_SERIAL="console=ttyS0,${OPTARG}n81"
+			GNAP_BAUDRATE="${OPTARG}";;
 		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
 # Target type (-i or -d) is needed
-test -n "${TYPE}"
+test -n "${GNAP_TYPE}"
 gtest continued $? 'Please specify a target (-i or -d option)'
 
 # Core file is required
-test -f "${GNAPCORE}"
+test -f "${GNAP_CORE}"
 gtest continued $? 'Please specify a valid GNAP core file (-g option)'
 
-case "${TYPE}" in
+case "${GNAP_TYPE}" in
 	disk)
 		# if disk type, doublecheck everything is ok
-		PARENTDEV="${OUTPUT:0:$((${#OUTPUT}-1))}"
+		PARENTDEV="${GNAP_OUTPUT:0:$((${#GNAP_OUTPUT}-1))}"
 		test -b "${PARENTDEV}"
 		gtest continued $? "${PARENTDEV} device does not exist on this
system"
-		test -b "${OUTPUT}"
-		gtest continued $? "${OUTPUT} partition does not exist on this
system"
+		test -b "${GNAP_OUTPUT}"
+		gtest continued $? "${GNAP_OUTPUT} partition does not exist on this
system"
 	;;
 	image)
-		if [[ "${CREATE}" != 'y' ]]; then
+		if [[ "${GNAP_CREATE}" != 'y' ]]; then
 			# Check whether image file exists
-			test -f "${OUTPUT}"
-			gtest continued $? "Image file ${OUTPUT} does not exist."
+			test -f "${GNAP_OUTPUT}"
+			gtest continued $? "Image file ${GNAP_OUTPUT} does not exist."
 		fi
 	;;
 esac
 
 # At least one overlay is required
-test -n "${OVERLAYS}${OVERLAYCONF}"
+test -n "${GNAP_OVERLAYS}${GNAP_OVERLAY_CONF}"
 gtest $? 'Please specify at least an overlay (-o) or config file (-c)'
 
 # Warning for disk type targets
-if [[ "${TYPE}" == 'disk' ]]; then
+if [[ "${GNAP_TYPE}" == 'disk' ]]; then
 	gwarn 'Warning : you have selected disk install'
-	gwarn "Make sure you are root or have full access to ${OUTPUT}"
+	gwarn "Make sure you are root or have full access to ${GNAP_OUTPUT}"
 	gwarn "${PARENTDEV} must have an MBR installed, run:"
-	gwarn "${W}dd if=${GNAPMBR} of=${PARENTDEV} bs=512 count=1${N} if
needed"
-	gwarn "${OUTPUT} must contain an active partition:"
+	gwarn "${W}dd if=${GNAP_MBR} of=${PARENTDEV} bs=512 count=1${N} if
needed"
+	gwarn "${GNAP_OUTPUT} must contain an active partition:"
 	gwarn " use ${W}fdisk ${PARENTDEV}${N} if needed"
-	gwarn "Current data on ${OUTPUT} will be ${B}destroyed${N}!"
+	gwarn "Current data on ${GNAP_OUTPUT} will be ${B}destroyed${N}!"
 	gconfirm 'Are you sure you want to continue ?'
 fi
 
 # Common actions
-gbegin "Expanding ${GNAPCORE} core"
+gbegin "Expanding ${GNAP_CORE} core"
 TEMPDIR=$(mktemp -d -t gnap_overlay.XXXXXX)
 gtest continued $? 'Failed to create temporary directory'
 TEMPCOREDIR="${TEMPDIR}/core"
 gmkdir "${TEMPCOREDIR}"
-tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}"
+tar x -C "${TEMPCOREDIR}" -f "${GNAP_CORE}"
 gtest $? 'Failed to extract core'
 
 gbegin 'Preparing overlay'
 TEMPOVERDIR="${TEMPDIR}/overlay"
 gmkdir "${TEMPOVERDIR}"
 
-if [[ -n "${BAUDRATE}" ]]; then
+if [[ -n "${GNAP_BAUDRATE}" ]]; then
 	gbegin 'Adding baudrate for serial console'
 	gmkdir -p "${TEMPOVERDIR}/etc/gnap"
-	echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
+	echo -n "${GNAP_BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
 	gtest $? 'Failed to create /etc/gnap/baudrate'
 fi
-for overlay in ${OVERLAYS} ; do
+for overlay in ${GNAP_OVERLAYS} ; do
 	if [[ -d "${overlay}" ]]; then
 		gbegin "Adding ${overlay} (directory overlay)"
 		cp -rp "${overlay}"/* "${TEMPOVERDIR}"
@@ -156,13 +155,13 @@
 		gtest $? "${overlay} is not a valid conflet file (tbz2 format)"
 	fi
 done
-if [[ -n "${OVERLAYCONF}" ]]; then
-	gbegin "Adding ${OVERLAYCONF} (overlay.conf file)"
+if [[ -n "${GNAP_OVERLAY_CONF}" ]]; then
+	gbegin "Adding ${GNAP_OVERLAY_CONF} (overlay.conf file)"
 	if [[ ! -d "${TEMPOVERDIR}/etc" ]]; then
 		gmkdir "${TEMPOVERDIR}/etc"
 	fi
-	cp "${OVERLAYCONF}" "${TEMPOVERDIR}/etc/overlay.conf"
-	gtest $? "Failed to copy ${OVERLAYCONF}"
+	cp "${GNAP_OVERLAY_CONF}" "${TEMPOVERDIR}/etc/overlay.conf"
+	gtest $? "Failed to copy ${GNAP_OVERLAY_CONF}"
 fi
 gbegin 'Creating overlay tarball'
 test -f "${TEMPOVERDIR}/etc/overlay.conf"
@@ -172,28 +171,28 @@
 gtest $? 'Failed to create overlay tarball'
 
 DATE=$(date --utc)
-if [[ "${NOLOGO}" -eq 1 ]]; then
+if [[ "${GNAP_NOLOGO}" -eq 1 ]]; then
 	echo "GNAP ${VERSION}" > "${TEMPCOREDIR}/isolinux/boot.msg"
 fi
-if [[ -n "${OVERLAYS}" ]]; then
-	echo "Overlaid with ${OVERLAYS} on ${DATE}" \
+if [[ -n "${GNAP_OVERLAYS}" ]]; then
+	echo "Overlaid with ${GNAP_OVERLAYS} on ${DATE}" \
 		>> "${TEMPCOREDIR}/isolinux/boot.msg"
 fi
 
 # Target specific actions
-if [[ "${TYPE}" == 'iso' ]]; then
-	if [[ -f "${OUTPUT}" ]]; then
-		gconfirm "File ${OUTPUT} already exists, overwrite?"
+if [[ "${GNAP_TYPE}" == 'iso' ]]; then
+	if [[ -f "${GNAP_OUTPUT}" ]]; then
+		gconfirm "File ${GNAP_OUTPUT} already exists, overwrite?"
 	fi
 	rm "${TEMPCOREDIR}/syslinux.cfg"
-	gbegin "Building ${OUTPUT} ISO file"
-	mkisofs -quiet -J -r -l -x "${TEMPCOREDIR}/.." -o "${OUTPUT}" \
+	gbegin "Building ${GNAP_OUTPUT} ISO file"
+	mkisofs -quiet -J -r -l -x "${TEMPCOREDIR}/.." -o "${GNAP_OUTPUT}" \
 		-b isolinux/isolinux.bin -c isolinux/boot.cat \
 		-no-emul-boot -boot-load-size 4 -boot-info-table "${TEMPCOREDIR}"
 	gtest $?
 
 else
-	if [[ "${TYPE}" == 'image' ]]; then
+	if [[ "${GNAP_TYPE}" == 'image' ]]; then
 		gbegin 'Looking for free loop device'
 		LOOP=''
 		for i in /dev/loop/?* /dev/loop?*; do
@@ -210,25 +209,25 @@
 
 		ginfo "Using loop device ${LOOP}"
 
-		if [[ "${CREATE}"  == y ]]; then
-			if [[ -f "${OUTPUT}" ]]; then
-				gconfirm "File ${OUTPUT} already exists, overwrite?"
+		if [[ "${GNAP_CREATE}"  == y ]]; then
+			if [[ -f "${GNAP_OUTPUT}" ]]; then
+				gconfirm "File ${GNAP_OUTPUT} already exists, overwrite?"
 			fi
 
 			gbegin 'Creating image file'
 			# 1048576 = 1 MiB
-			dd if=/dev/zero of="${OUTPUT}" bs=1048576 count="${IMG_SIZE}" \
+			dd if=/dev/zero of="${GNAP_OUTPUT}" bs=1048576
count="${GNAP_IMG_SIZE}" \
 				>/dev/null 2>&1
 			gtest $?
 
 			gbegin 'Creating partition table'
 			# Create one partition of the full size
-			echo '0;;6;*' | sfdisk -D -H 64 -S 32 "${OUTPUT}" >/dev/null 2>&1
+			echo '0;;6;*' | sfdisk -D -H 64 -S 32 "${GNAP_OUTPUT}" >/dev/null
2>&1
 			gtest $?
 		fi
 
 		gbegin 'Reading Cylinder/Heads/Sectors'
-		CHS=$(sfdisk -G "${OUTPUT}" 2>/dev/null)
+		CHS=$(sfdisk -G "${GNAP_OUTPUT}" 2>/dev/null)
 		gtest $?
 
 		set -- ${CHS/*:/}
@@ -241,22 +240,22 @@
 
 		ginfo "Offset is ${offset}"
 
-		gbegin "Mounting ${OUTPUT} to ${LOOP}"
-		losetup -o "${offset}" "${LOOP}" "${OUTPUT}"
+		gbegin "Mounting ${GNAP_OUTPUT} to ${LOOP}"
+		losetup -o "${offset}" "${LOOP}" "${GNAP_OUTPUT}"
 		gtest $?
 
-		ORIG_OUTPUT="${OUTPUT}"
-		OUTPUT="${LOOP}"
+		ORIG_OUTPUT="${GNAP_OUTPUT}"
+		GNAP_OUTPUT="${LOOP}"
 	fi
 
-	gbegin "Formatting ${OUTPUT}"
-	mkfs.msdos "${OUTPUT}" > /dev/null 2>&1
+	gbegin "Formatting ${GNAP_OUTPUT}"
+	mkfs.msdos "${GNAP_OUTPUT}" > /dev/null 2>&1
 	gtest $?
 
-	gbegin "Mounting ${OUTPUT}"
+	gbegin "Mounting ${GNAP_OUTPUT}"
 	TEMPMOUNTDIR="${TEMPDIR}/mount"
 	gmkdir "${TEMPMOUNTDIR}"
-	mount -t msdos "${OUTPUT}" "${TEMPMOUNTDIR}"
+	mount -t msdos "${GNAP_OUTPUT}" "${TEMPMOUNTDIR}"
 	gtest $?
 
 	gbegin 'Copying files'
@@ -268,31 +267,31 @@
 	cp ${TEMPCOREDIR}/overlay.tgz			${TEMPMOUNTDIR}/			&&\
 	cp ${TEMPCOREDIR}/image.squashfs		${TEMPMOUNTDIR}/image.sfs	&&\
 	sed -i \
-		"s:cdroot:cdroot=/dev/${TARGETROOT} ${CACHE}${SERIAL}:" \
+		"s:cdroot:cdroot=/dev/${GNAP_TARGETROOT}
${GNAP_CACHE}${GNAP_SERIAL}:" \
 		"${TEMPMOUNTDIR}/syslinux.cfg"
 	gtest $?
 
-	gbegin "Unmounting ${OUTPUT}"
+	gbegin "Unmounting ${GNAP_OUTPUT}"
 	umount "${TEMPMOUNTDIR}"
 	gtest $?
 
 	# Is autocleaned so maybe not useful
-	if [[ "${TYPE}" == 'image' ]]; then
+	if [[ "${GNAP_TYPE}" == 'image' ]]; then
 		losetup -d "${LOOP}"
 		LOOP=
 	fi
 
 	export MTOOLS_SKIP_CHECK=1
-	case "${TYPE}" in
+	case "${GNAP_TYPE}" in
 		disk)
 			gbegin 'Syslinuxing'
-			syslinux "${OUTPUT}"
+			syslinux "${GNAP_OUTPUT}"
 			gtest $?
 		;;
 		image)
 			gbegin 'Preparing disk for boot'
 			syslinux -o "${offset}" "${ORIG_OUTPUT}" && \
-			dd if="${GNAPMBR}" of="${ORIG_OUTPUT}" bs=512 count=1 \
+			dd if="${GNAP_MBR}" of="${ORIG_OUTPUT}" bs=512 count=1 \
 				conv=notrunc >/dev/null 2>&1
 			gtest $?
 		;;
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup+split/tools/gnap_remaster gnap-2.0+cleanup+split
+namespace/tools/gnap_remaster
--- gnap-2.0+cleanup+split/tools/gnap_remaster	2007-07-27
16:10:54.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace/tools/gnap_remaster	2007-07-27
16:17:48.000000000 +0300
@@ -1,16 +1,16 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAPLIBDIR='/usr/lib/gnap'
-source ${GNAPLIBDIR}/gnap_shared.sh
-echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
+GNAP_LIBDIR='/usr/lib/gnap'
+source ${GNAP_LIBDIR}/gnap_shared.sh
+echo "GNAP remastering tool ${NAME} ${VERSION}"
 
-OUTPUT='mygnap-core.tar'
+GNAP_OUTPUT='mygnap-core.tar'
 
 usage() {
 	echo
 	echo 'Usage:'
-	echo "  ${GNAPNAME} [ options ]"
+	echo "  ${NAME} [ options ]"
 	echo
 	echo 'Options:'
 	echo '  -e extension    Extension to include in core file'
@@ -22,7 +22,7 @@
 	echo '  -d extdir       Directory where to find extensions'
 	echo '  -f              Force all answers to yes (dangerous!)'
 	echo
-	echo "Please use man ${GNAPNAME} for more details."
+	echo "Please use man ${NAME} for more details."
 }
 
 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
@@ -33,64 +33,64 @@
 gbegin 'Checking parameters'
 
 # Read options
-EXTENSIONS=''
-KERNEXT=''
-MODEXT=''
-GNAPBASEFS=''
-GNAPEXTDIR=''
-FORCEYES=0
+GNAP_EXTENSIONS=''
+GNAP_KERNEXT=''
+GNAP_MODEXT=''
+GNAP_BASEFS=''
+GNAP_EXTDIR=''
+GNAP_FORCEYES=0
 while getopts ':he:k:m:o:g:b:d:f' option; do
 	case ${option} in
 		h ) usage
 			exit 0;;
-		e ) EXTENSIONS="${EXTENSIONS} ${OPTARG}";;
-		k ) KERNEXT="${OPTARG}";;
-		m ) MODEXT="${OPTARG}";;
-		o ) OUTPUT="${OPTARG}";;
-		g ) GNAPCORE="${OPTARG}";;
-		b ) GNAPBASEFS="${OPTARG}";;
-		d ) GNAPEXTDIR="${OPTARG}";;
-		f ) FORCEYES=1;;
+		e ) GNAP_EXTENSIONS="${GNAP_EXTENSIONS} ${OPTARG}";;
+		k ) GNAP_KERNEXT="${OPTARG}";;
+		m ) GNAP_MODEXT="${OPTARG}";;
+		o ) GNAP_OUTPUT="${OPTARG}";;
+		g ) GNAP_CORE="${OPTARG}";;
+		b ) GNAP_BASEFS="${OPTARG}";;
+		d ) GNAP_EXTDIR="${OPTARG}";;
+		f ) GNAP_FORCEYES=1;;
 		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
 # Root is needed
 test "${EUID}" -eq 0
-gtest continued $? "You need to be root to run ${GNAPNAME}"
+gtest continued $? "You need to be root to run ${NAME}"
 
 # basefs file is required
-test -f "${GNAPBASEFS}"
+test -f "${GNAP_BASEFS}"
 gtest continued $? 'Please specify a valid GNAP basefs file (-b
option)'
 
 # core file is required
-test -f "${GNAPCORE}"
+test -f "${GNAP_CORE}"
 gtest continued $? 'Please specify a valid GNAP core file (-g option)'
 
 # At least one operation is required
-test -n "${EXTENSIONS}" -o -n "${KERNEXT}" -o -n "${MODEXT}"
+test -n "${GNAP_EXTENSIONS}" -o -n "${GNAP_KERNEXT}" -o -n
"${GNAP_MODEXT}"
 gtest $? 'Please specify at least one operation (-e, -k, -m) to
perform'
 
 # Confirm tarball overwrite
-if [[ -e "${OUTPUT}" ]]; then
-	gconfirm "${OUTPUT} already exists, overwrite"
+if [[ -e "${GNAP_OUTPUT}" ]]; then
+	gconfirm "${GNAP_OUTPUT} already exists, overwrite"
 fi
 
 # Preparing new FS
-gbegin "Unpacking ${GNAPBASEFS} basefs"
+gbegin "Unpacking ${GNAP_BASEFS} basefs"
 TEMPDIR=$(mktemp -d -t gnap_remaster.XXXXXX)
 gtest continued $? 'Failed to create temporary directory'
 TEMPOVERDIR="${TEMPDIR}/basefs"
 gmkdir "${TEMPOVERDIR}"
 
-tar jx -C "${TEMPOVERDIR}" -f "${GNAPBASEFS}"
+tar jx -C "${TEMPOVERDIR}" -f "${GNAP_BASEFS}"
 gtest $? 'Failed to unpack basefs'
 
-for overlay in ${EXTENSIONS} ; do
+for overlay in ${GNAP_EXTENSIONS} ; do
 	gbegin "Adding ${overlay} extension"
-	test -f "${GNAPEXTDIR}/gnapext_${overlay}.tbz2"
-	gtest continued $? "${GNAPEXTDIR}/gnapext_${overlay}.tbz2 does not
exist"
-	tar jxf "${GNAPEXTDIR}/gnapext_${overlay}.tbz2" -C "${TEMPOVERDIR}"
+	test -f "${GNAP_EXTDIR}/gnapext_${overlay}.tbz2"
+	gtest continued $? "${GNAP_EXTDIR}/gnapext_${overlay}.tbz2 does not
exist"
+	tar jxf "${GNAP_EXTDIR}/gnapext_${overlay}.tbz2" -C "${TEMPOVERDIR}"
 	gtest $? "${overlay} is not a valid extension (tbz2 format)"
 done
 
@@ -99,31 +99,31 @@
 TEMPCOREDIR="${TEMPDIR}/core"
 gmkdir "${TEMPCOREDIR}"
 
-tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}" --exclude image.squashfs
+tar x -C "${TEMPCOREDIR}" -f "${GNAP_CORE}" --exclude image.squashfs
 gtest $? 'Failed to extract core'
 
-if [[ -f "${KERNEXT}" ]]; then
-	gbegin "Replacing kernel and initrd using ${KERNEXT}"
+if [[ -f "${GNAP_KERNEXT}" ]]; then
+	gbegin "Replacing kernel and initrd using ${GNAP_KERNEXT}"
 	TEMPKERNDIR="${TEMPDIR}/kernel"
 	gmkdir "${TEMPKERNDIR}"
 
-	tar jx -C "${TEMPKERNDIR}" -f "${KERNEXT}"
+	tar jx -C "${TEMPKERNDIR}" -f "${GNAP_KERNEXT}"
 	gtest continued $? 'Failed to extract kernpackage'
 	cp ${TEMPKERNDIR}/kernel* "${TEMPCOREDIR}/isolinux/gentoo" && \
 		cp ${TEMPKERNDIR}/initr* "${TEMPCOREDIR}/isolinux/gentoo.igz"
 	gtest $? 'Failed to copy kernel and initrd'
 
-elif [[ -n "${KERNEXT}" ]]; then
-	gwarn "${KERNEXT} does not exist, ignoring..."
+elif [[ -n "${GNAP_KERNEXT}" ]]; then
+	gwarn "${GNAP_KERNEXT} does not exist, ignoring..."
 fi
 
-if [[ -f "${MODEXT}" ]]; then
-	gbegin "Replacing modules using ${MODEXT}"
+if [[ -f "${GNAP_MODEXT}" ]]; then
+	gbegin "Replacing modules using ${GNAP_MODEXT}"
 	rm -rf "${TEMPOVERDIR}/lib/modules" &&
-		tar jx -C "${TEMPOVERDIR}" -f "${MODEXT}"
+		tar jx -C "${TEMPOVERDIR}" -f "${GNAP_MODEXT}"
 	gtest $? 'Failed to replace modules'
-elif [[ -n "${MODEXT}" ]]; then
-	gwarn "${MODEXT} does not exist, ignoring..."
+elif [[ -n "${GNAP_MODEXT}" ]]; then
+	gwarn "${GNAP_MODEXT} does not exist, ignoring..."
 fi
 
 gbegin 'Creating new squashfs filesystem'
@@ -131,8 +131,8 @@
 	> /dev/null 2>/dev/null
 gtest $? 'Failed to create squashfs'
 
-gbegin "Creating ${OUTPUT} core file"
-tar cf "${OUTPUT}" -C "${TEMPCOREDIR}" .
+gbegin "Creating ${GNAP_OUTPUT} core file"
+tar cf "${GNAP_OUTPUT}" -C "${TEMPCOREDIR}" .
 gtest $? 'Failed to create new core tarball'
 
 # Successful finish
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup+split/tools/gnap_shared.sh gnap-2.0+cleanup+split
+namespace/tools/gnap_shared.sh
--- gnap-2.0+cleanup+split/tools/gnap_shared.sh	2007-08-02
15:54:46.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace/tools/gnap_shared.sh	2007-08-02
15:51:30.000000000 +0300
@@ -1,22 +1,22 @@
-GNAPNAME=$(basename "$0")
+NAME=$(basename "$0")
 
-case ${GNAPNAME} in
+case ${NAME} in
 	gnap_make )     GNAP_PRODUCT="Build";;
  	gnap_overlay )  GNAP_PRODUCT="Overlay";;
  	gnap_remaster ) GNAP_PRODUCT="Remaster";;
  	* )             GNAP_PRODUCT="Something";;
 esac
-STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
-SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
-SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
-GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
-GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
-GNAPEXTDIR="${GNAPLIBDIR}/extensions"
-GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
+GNAP_STAGE3FILE="${GNAP_LIBDIR}/gnap-stage3seed.tar.bz2"
+GNAP_SNAPSHOTFILE="${GNAP_LIBDIR}/gnap-portagesnapshot.tar.bz2"
+GNAP_SPECS="${GNAP_LIBDIR}/gnap-specs.tar.bz2"
+GNAP_CORE="${GNAP_LIBDIR}/gnap-core.tar"
+GNAP_MBR="${GNAP_LIBDIR}/mbr/mbr.bin"
+GNAP_EXTDIR="${GNAP_LIBDIR}/extensions"
+GNAP_BASEFS="${GNAP_LIBDIR}/gnap-basefs.tar.bz2"
 
+GNAP_FORCEYES=0
 TEMPDIR=''
 LOOP=''
-FORCEYES=0
 
 G=$'\e[32;01m'
 B=$'\e[31;01m'
@@ -40,7 +40,7 @@
 }
 
 gconfirm() {
-	if [[ "${FORCEYES}" -eq 1 ]]; then
+	if [[ "${GNAP_FORCEYES}" -eq 1 ]]; then
 		gwarn "${*} forced to yes"
 	else
 		read -ep " ${W}*${N} ${*} [N]: " answer
@@ -79,7 +79,7 @@
 		if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
 			cleanup
 		fi
-		echo " ${GNAP_PRODUCT} failed, try ${GNAPNAME} -h for more help"
+		echo " ${GNAP_PRODUCT} failed, try ${NAME} -h for more help"
 		exit 1
 	fi
 }

-- 
gnap-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gnap-dev] [PATCH 4/4] GNAP environment
  2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
                   ` (2 preceding siblings ...)
  2007-08-03 13:37 ` [gnap-dev] [PATCH 3/4] GNAP namespace Philipp Riegger
@ 2007-08-03 13:53 ` Philipp Riegger
  2007-08-03 13:57 ` [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Philipp Riegger @ 2007-08-03 13:53 UTC (permalink / raw
  To: gnap-dev

This cleans up the way gnap_* scripts get their information. Since i
mostly worked on gnap_make this is optimized for gnap_make and the other
scripts are only changed in the same way. In gnap_make we have the
following sources of configuration:

 - The command line
 - common.conf
 - catalyst.conf
 - the environment

Until now, catalyst.conf was used for... i don't know, it was sourced
but not really used, i think. common.conf was used for all the arch
specific stuff, that has to be passed to catalyst. The command line was
used for most of the configuration options, including the location of
common.conf and catalyst.conf.

The new behavior is the following:

gnap_make and gnap_shared specify default values for all the GNAP_
variables (sometimes undef is default). This can be overwritten by
environment variables (export GNAP_LIBDIR=/home/test/foo/bar for
specifying the place of all the gnap files for testing new
configurations, export GNAP_CATALYST_BIN="echo catalyst" for only
getting the configurations created by gnap_make and not building the
stuff come to mind), next the spec location is read from command line if
available and common.conf is sourced, the catalyst.conf info is read
from the command line if available and the file is sourced, the rest of
the command line is read and sets/overwrites whatever is given there.

With this you can:
 - add GNAP_ options to catalyst.conf (DON'T DO THAT)
 - add GNAP_ options to common.conf (shorter command line, nice)
 - add GNAP_ options to the environment (GNAP_LIBDIR since we only use
tha lates testing stuff located in /home/somewhere, whatever you want)
 - have new problems because you don't know why a special option is set.
Well, if you are advanced enough to make such a mess, you are advanced
enough for cat, grep, export -p and set -x to debug that.

Before i gorget it: I also did some more cleanup here. I was too lazy to
apply it to all the previous branches that it would be in the -cleanup
patch, i hope you can live with that.

Enjoy,
	Philipp


diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup+split+namespace/src/gnap_make gnap-2.0+cleanup+split+namespace
+environment/src/gnap_make
--- gnap-2.0+cleanup+split+namespace/src/gnap_make	2007-08-02
15:50:45.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace+environment/src/gnap_make
2007-08-02 15:46:54.000000000 +0300
@@ -1,7 +1,7 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAP_LIBDIR='/usr/lib/gnap'
+GNAP_LIBDIR=${GNAP_LIBDIR:-'/usr/lib/gnap'}
 source ${GNAP_LIBDIR}/gnap_shared.sh
 echo "GNAP Core Building tool ${NAME} version ${VERSION}"
 
@@ -25,65 +25,31 @@
 	exit 0
 fi
 
-gbegin 'Checking parameters'
-
 # Catalyst executable and config file
-GNAP_CATALYST_BIN="/usr/bin/catalyst"
-GNAP_CATALYST_CONF="/etc/catalyst/catalyst.conf"
+GNAP_CATALYST_BIN=${GNAP_CATALYST_BIN:-"/usr/bin/catalyst"}
+GNAP_CATALYST_CONF=${GNAP_CATALYST_CONF:-"/etc/catalyst/catalyst.conf"}
 
-# Read options
-GNAP_STAGE3=0
-GNAP_LIVECD1=0
-GNAP_LIVECD2=0
-GNAP_TARBALL=0
-GNAP_MODULES=0
-GNAP_STAMP=$(date +%Y%m%d)
-NOTARGET=1
-NEEDS_SNAPSHOT=0
+# Default options
+GNAP_STAMP=${GNAP_STAMP:-$(date +%Y%m%d)}
+
+# Read options (phase 1)
+gbegin 'Checking parameters'
+
+OPTIND=0
 while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
 	case ${option} in
-		h )
+		h ) 
+			gtest
 			usage
 			exit 0;;
-		s ) GNAP_STAGE3FILE="${OPTARG}";;
-		p ) GNAP_SNAPSHOTFILE="${OPTARG}";;
-		o ) GNAP_PORTAGE_OVERLAYS="${GNAP_PORTAGE_OVERLAYS} ${OPTARG}";;
-		v ) GNAP_STAMP="${OPTARG}";;
-		t )
-			case "${OPTARG}" in
-				all )
-					GNAP_STAGE3=1
-					GNAP_LIVECD1=1
-					GNAP_LIVECD2=1
-					GNAP_TARBALL=1
-					GNAP_MODULES=1
-					NEEDS_SNAPSHOT=1;;
-				stage3 )
-					GNAP_STAGE3=1
-					NEEDS_SNAPSHOT=1;;
-				livecd-stage1 )
-					GNAP_LIVECD1=1
-					NEEDS_SNAPSHOT=1;;
-				livecd-stage2 )
-					GNAP_LIVECD2=1
-					NEEDS_SNAPSHOT=1;;
-				tarball )
-					GNAP_TARBALL=1;;
-				extensions )
-					GNAP_MODULES=1
-					NEEDS_SNAPSHOT=1;;
-				* ) gtest 1 'Specified stage is unknown!';;
-			esac
-			NOTARGET=0;;
-		f ) GNAP_FORCEYES=1;;
-		l ) GNAP_LOGPREFIX="${OPTARG}";;
-		c ) GNAP_CATALYST_CONF="${OPTARG}";;
 		e ) GNAP_SPECS="${OPTARG}";;
+		s|p|o|v|t|f|l|c ) :;;
 		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
 # Root is needed
+# * non-root can only use "gnap_make -h"
 test "${EUID}" -eq 0
 gtest continued $? "You need to be root to run ${NAME}"
 
@@ -113,15 +79,71 @@
 	DISTCCSPEC="distcc_hosts: ${DISTCC_HOSTS}"
 fi
 
+
+# Read options (phase 2)
+OPTIND=0
+while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
+	case ${option} in
+		c ) GNAP_CATALYST_CONF="${OPTARG}";;
+		s|p|o|v|t|f|l|e|h ) :;;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
+	esac
+done
+
 # catalyst.conf file
 test -f "${GNAP_CATALYST_CONF}"
 gtest continued $? "${GNAP_CATALYST_CONF} file not found!"
 source "${GNAP_CATALYST_CONF}"
 
+# Read options (phase 3)
+OPTIND=0
+while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
+	case ${option} in
+		s ) GNAP_STAGE3FILE="${OPTARG}";;
+		p ) GNAP_SNAPSHOTFILE="${OPTARG}";;
+		o ) GNAP_PORTAGE_OVERLAYS="${GNAP_PORTAGE_OVERLAYS} ${OPTARG}";;
+		v ) GNAP_STAMP="${OPTARG}";;
+		t )
+			case "${OPTARG}" in
+				all )
+					GNAP_STAGE3=1
+					GNAP_LIVECD1=1
+					GNAP_LIVECD2=1
+					GNAP_TARBALL=1
+					GNAP_MODULES=1;;
+				stage3 ) GNAP_STAGE3=1;;
+				livecd-stage1 ) GNAP_LIVECD1=1;;
+				livecd-stage2 ) GNAP_LIVECD2=1;;
+				tarball ) GNAP_TARBALL=1;;
+				extensions ) GNAP_MODULES=1;;
+				* ) gtest 1 'Specified stage is unknown!';;
+			esac;;
+		f ) GNAP_FORCEYES=1;;
+		l ) GNAP_LOGPREFIX="${OPTARG}";;
+		c|e|h ) :;;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
+	esac
+done
+
 # At least one target is needed
-test "${NOTARGET}" -eq 0
-gtest continued $? \
+test "${GNAP_STAGE3}" -eq 0 &&
+test "${GNAP_LIVECD1}" -eq 0 &&
+test "${GNAP_LIVECD2}" -eq 0 &&
+test "${GNAP_TARBALL}" -eq 0 &&
+test "${GNAP_MODULES}" -eq 0
+if [[ $? -eq 0 ]]; then
+	gtest continued 1 \
 	'No target specified. You should provide at least one -t option.'
+fi
+
+NEEDS_SNAPSHOT=0
+test "${GNAP_STAGE3}" -eq 1 ||
+test "${GNAP_LIVECD1}" -eq 1 ||
+test "${GNAP_LIVECD2}" -eq 1 ||
+test "${GNAP_MODULES}" -eq 1
+if [[ $? -eq 0 ]]; then
+	NEEDS_SNAPSHOT=1
+fi
 
 # storedir must exist
 gmkdir "${storedir}"
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup+split+namespace/tools/gnap_overlay gnap-2.0+cleanup+split
+namespace+environment/tools/gnap_overlay
--- gnap-2.0+cleanup+split+namespace/tools/gnap_overlay	2007-07-27
16:00:02.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace+environment/tools/gnap_overlay
2007-07-31 23:22:33.000000000 +0300
@@ -1,7 +1,7 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAP_LIBDIR='/usr/lib/gnap'
+GNAP_LIBDIR=${GNAP_LIBDIR:-'/usr/lib/gnap'}
 source ${GNAP_LIBDIR}/gnap_shared.sh
 echo "GNAP overlay tool ${NAME} ${VERSION}"
 
@@ -42,19 +42,14 @@
 	exit 0
 fi
 
-gbegin 'Checking parameters'
+# Default settings
+GNAP_NOLOGO=${GNAP_NOLOGO:-0}
+GNAP_CREATE=${GNAP_CREATE:-'n'}
+GNAP_IMG_SIZE=${GNAP_IMG_SIZE:-15}
 
 # Read options
-GNAP_NOLOGO=0
-GNAP_FORCEYES=0
-GNAP_OUTPUT=''
-GNAP_TYPE=''
-GNAP_CREATE='n'
-GNAP_IMG_SIZE=15
-GNAP_TARGETROOT=''
-GNAP_CACHE=''
-GNAP_SERIAL=''
-GNAP_BAUDRATE=''
+gbegin 'Checking parameters'
+
 while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' option; do
 	case ${option} in
 		h ) usage
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup+split+namespace/tools/gnap_remaster gnap-2.0+cleanup+split
+namespace+environment/tools/gnap_remaster
--- gnap-2.0+cleanup+split+namespace/tools/gnap_remaster	2007-07-27
16:17:48.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace+environment/tools/gnap_remaster
2007-07-31 23:29:03.000000000 +0300
@@ -1,12 +1,10 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAP_LIBDIR='/usr/lib/gnap'
+GNAP_LIBDIR=${GNAP_LIBDIR:-'/usr/lib/gnap'}
 source ${GNAP_LIBDIR}/gnap_shared.sh
 echo "GNAP remastering tool ${NAME} ${VERSION}"
 
-GNAP_OUTPUT='mygnap-core.tar'
-
 usage() {
 	echo
 	echo 'Usage:'
@@ -33,12 +31,8 @@
 gbegin 'Checking parameters'
 
 # Read options
-GNAP_EXTENSIONS=''
-GNAP_KERNEXT=''
-GNAP_MODEXT=''
-GNAP_BASEFS=''
-GNAP_EXTDIR=''
-GNAP_FORCEYES=0
+GNAP_OUTPUT=${GNAP_OUTPUT:-'mygnap-core.tar'}
+
 while getopts ':he:k:m:o:g:b:d:f' option; do
 	case ${option} in
 		h ) usage
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0
+cleanup+split+namespace/tools/gnap_shared.sh gnap-2.0+cleanup+split
+namespace+environment/tools/gnap_shared.sh
--- gnap-2.0+cleanup+split+namespace/tools/gnap_shared.sh	2007-08-02
15:51:30.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace+environment/tools/gnap_shared.sh
2007-08-02 15:46:44.000000000 +0300
@@ -6,34 +6,44 @@
  	gnap_remaster ) GNAP_PRODUCT="Remaster";;
  	* )             GNAP_PRODUCT="Something";;
 esac
-GNAP_STAGE3FILE="${GNAP_LIBDIR}/gnap-stage3seed.tar.bz2"
-GNAP_SNAPSHOTFILE="${GNAP_LIBDIR}/gnap-portagesnapshot.tar.bz2"
-GNAP_SPECS="${GNAP_LIBDIR}/gnap-specs.tar.bz2"
-GNAP_CORE="${GNAP_LIBDIR}/gnap-core.tar"
-GNAP_MBR="${GNAP_LIBDIR}/mbr/mbr.bin"
-GNAP_EXTDIR="${GNAP_LIBDIR}/extensions"
-GNAP_BASEFS="${GNAP_LIBDIR}/gnap-basefs.tar.bz2"
 
-GNAP_FORCEYES=0
+GNAP_STAGE3FILE=
${GNAP_STAGE3FILE:-"${GNAP_LIBDIR}/gnap-stage3seed.tar.bz2"}
+GNAP_SNAPSHOTFILE=
${GNAP_SNAPSHOTFILE:-"${GNAP_LIBDIR}/gnap-portagesnapshot.tar.bz2"}
+GNAP_SPECS=${GNAP_SPECS:-"${GNAP_LIBDIR}/gnap-specs.tar.bz2"}
+GNAP_CORE=${GNAP_CORE:-"${GNAP_LIBDIR}/gnap-core.tar"}
+GNAP_MBR=${GNAP_MBR:-"${GNAP_LIBDIR}/mbr/mbr.bin"}
+GNAP_EXTDIR=${GNAP_EXTDIR:-"${GNAP_LIBDIR}/extensions"}
+GNAP_BASEFS=${GNAP_BASEFS:-"${GNAP_LIBDIR}/gnap-basefs.tar.bz2"}
+
+GNAP_FORCEYES=${GNAP_FORCEYES:-0}
+
+#CONTINUED=0
 TEMPDIR=''
 LOOP=''
 
-G=$'\e[32;01m'
-B=$'\e[31;01m'
-N=$'\e[0m'
-W=$'\e[33;01m'
-K=$'\e[34;01m'
-C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
-E=$'\e['${C}'G'
+G=$'\e[32;01m' # green
+B=$'\e[31;01m' # red
+N=$'\e[0m'     # neutral
+W=$'\e[33;01m' # yellow
+K=$'\e[34;01m' # blue
+C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]" # end of line
helper
+E=$'\e['${C}'G' # end of line
+
+ginfo() {
+	echo -e " ${G}*${N} ${*}"
+}
 
 gwarn() {
 	echo -e " ${W}*${N} ${*}"
 }
 
-ginfo() {
-	echo -e " ${G}*${N} ${*}"
+gdie() {
+	echo -e " ${B}*${N} ${*}"
+	cleanup
+	exit 1
 }
 
+
 gmkdir() {
 	mkdir -p "$1"
 	gtest continued $? "Failed to create \"$1\"."
@@ -44,29 +54,31 @@
 		gwarn "${*} forced to yes"
 	else
 		read -ep " ${W}*${N} ${*} [N]: " answer
-		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
-				cleanup
-			fi
-			echo '${GNAP_PRODUCT} aborted!'
-			exit 2
-		fi
+		[[ "${answer}" != 'y' && "${answer}" != 'Y' ]] && \
+			gdie "${GNAP_PRODUCT} aborted!"
 	fi
 }
 
 gbegin() {
+#	[[ "${CONTINUED}" -eq 1 ]] && gdie "BUG triggered by gbegin()"
+
 	echo -ne " ${G}*${N} ${*}..."
+#	CONTINUED=1
 }
 
 gtest() {
-	continued=0
+#	# TODO: Remove this after removing all "gtest continued"
+#	if [[ "${#}" -gt 0 && "${1}" == 'continued' ]]; then
+#		shift
+#	fi
+	CONTINUED=0
 	if [[ "${#}" -gt 0 && "${1}" == 'continued' ]]; then
+		CONTINUED=1
 		shift
-		continued=1
 	fi
 
 	if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
-		if [[ "${continued}" -eq 0 ]]; then
+		if [[ "${CONTINUED}" -eq 0 ]]; then
 			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
 		fi
 	else
@@ -76,11 +88,7 @@
 			echo -en " ${B}*${N} ${*}"
 			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
 		fi
-		if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
-			cleanup
-		fi
-		echo " ${GNAP_PRODUCT} failed, try ${NAME} -h for more help"
-		exit 1
+		gdie "${GNAP_PRODUCT} failed, try man ${NAME} for more help"
 	fi
 }
 
@@ -90,13 +98,10 @@
 		umount "${LOOP}" && losetup -d "${LOOP}"
 		gtest $? "Failed to unmount ${LOOP}"
 	fi
-	gbegin 'Cleaning temporary directories'
 	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
-		rm -rf "${DIRTOREMOVE}"
+		gbegin 'Cleaning temporary directories'
+		rm -rf "${TEMPDIR}"
 		gtest $? "Failed to remove ${DIRTOREMOVE}"
-	else
-		gtest 0
+		TEMPDIR=''
 	fi
 }

-- 
gnap-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1
  2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
                   ` (3 preceding siblings ...)
  2007-08-03 13:53 ` [gnap-dev] [PATCH 4/4] GNAP environment Philipp Riegger
@ 2007-08-03 13:57 ` Philipp Riegger
  2007-08-03 14:01 ` Philipp Riegger
  2007-08-03 14:02 ` Philipp Riegger
  6 siblings, 0 replies; 8+ messages in thread
From: Philipp Riegger @ 2007-08-03 13:57 UTC (permalink / raw
  To: gnap-dev

On Fri, 2007-08-03 at 16:16 +0300, Philipp Riegger wrote:
> Things that still need to be done:
>  - Make the portage tarball creation code of gnap_make nicer. Since
> catalyst supports overlays, this is probably the way to go: Use the
> unmodified potage snapshot and merge all given overlays into one
> overlay
> and give it to catalyst. Maybe catalyst can even handle more than one
> overlay, but i do not know since i did not have a look at this.
>  - Lots of code is still duplicated in there and could be put to
> functions. I espcially mean gnap_make and the stage-specific code.
>  - This patchset works on the scripts, mostly n gnap_make and only
> does
> minimal changes to the provided config files. Maybe the gnap-devver
> convigfiles have to be changed accordingly, someone should have a look
> at the patches and theese files.

 - I was planign to have a look at a test set for gnap_make this would
do the following:
   - Create a test for every error patch (gtest $?, gdie) to look i they
are triggered corrrectly and if the output is right.
   - Create a test case that builds every possible stage with an empty
storedir (possibly 1 test per stage).
   - Weekly builds with the gnap tree/a tree snapshot from upstream.

Philipp

-- 
gnap-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1
  2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
                   ` (4 preceding siblings ...)
  2007-08-03 13:57 ` [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
@ 2007-08-03 14:01 ` Philipp Riegger
  2007-08-03 14:02 ` Philipp Riegger
  6 siblings, 0 replies; 8+ messages in thread
From: Philipp Riegger @ 2007-08-03 14:01 UTC (permalink / raw
  To: gnap-dev

[-- Attachment #1: Type: text/plain, Size: 158 bytes --]

On Fri, 2007-08-03 at 16:16 +0300, Philipp Riegger wrote:
> So any testing and comments are apreciated.

I attached a snapshot of my current work.

Philipp



[-- Attachment #2: gnap-2.0+cleanup+split+namespace+environment.tar.bz2 --]
[-- Type: application/x-bzip-compressed-tar, Size: 45698 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1
  2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
                   ` (5 preceding siblings ...)
  2007-08-03 14:01 ` Philipp Riegger
@ 2007-08-03 14:02 ` Philipp Riegger
  6 siblings, 0 replies; 8+ messages in thread
From: Philipp Riegger @ 2007-08-03 14:02 UTC (permalink / raw
  To: gnap-dev

[-- Attachment #1: Type: text/plain, Size: 284 bytes --]

On Fri, 2007-08-03 at 16:16 +0300, Philipp Riegger wrote:
> The patches are:
> 
> 01-gnap-cleanup.patch
> 02-gnap-split.patch
> 03-gnap-namespace.patch
> 04-gnap-environment.patch

I also attached theese, since come newline dmaage got done. Sorry for
sending all this twice.

Philipp

[-- Attachment #2: 01-gnap-cleanup.patch --]
[-- Type: text/x-patch, Size: 23264 bytes --]

diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0/src/gnap_make gnap-2.0+cleanup/src/gnap_make
--- gnap-2.0/src/gnap_make	2007-07-23 14:14:40.000000000 +0300
+++ gnap-2.0+cleanup/src/gnap_make	2007-08-02 15:55:38.000000000 +0300
@@ -21,6 +21,15 @@
 	echo -e " ${W}*${N} ${*}"
 }
 
+ginfo() {
+	echo -e " ${G}*${N} ${*}"
+}
+
+gmkdir() {
+	mkdir -p "$1"
+	gtest continued $? "Failed to create directory \"$1\"."
+}
+
 gconfirm() {
 	if [[ "${FORCEYES}" -eq 1 ]]; then
 		gwarn "${*} forced to yes"
@@ -30,7 +39,7 @@
 			if [[ -n "${TEMPDIR}" ]]; then
 				cleanup
 			fi
-			echo Build aborted !
+			echo Build aborted!
 			exit 2
 		fi
 	fi
@@ -77,7 +86,7 @@
 	echo '    -c catalyst.conf     Use specific catalyst.conf file'
 	echo '    -e specs             Specs directory or tar.bz2 file'
 	echo
-	echo "Please man ${GNAPNAME} for more details."
+	echo "Please use man ${GNAPNAME} for more details."
 }
 
 cleanup() {
@@ -92,19 +101,24 @@
 	fi
 }
 
-if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
+if [[ "$#" -eq 0 ]]; then
 	usage
 	exit 0
 fi
 
 gbegin 'Checking parameters'
 
+# Catalyst executable and config file
+CATALYST_BIN="/usr/bin/catayst"
+CATALYST_CONF="/etc/catalyst/catalyst.conf"
+
 # Read options
 NOTARGET=1
 STAMP=$(date +%Y%m%d)
-while getopts ':hs:p:m:o:v:t:fl:c:e:' options; do
-	case ${options} in
-		h ) usage
+while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
+	case ${option} in
+		h )
+			usage
 			exit 0;;
 		s ) STAGE3FILE="${OPTARG}";;
 		p ) SNAPSHOTFILE="${OPTARG}";;
@@ -112,7 +126,13 @@
 		v ) STAMP="${OPTARG}";;
 		t )
 			case "${OPTARG}" in
-				all ) ALLTARGET=1;;
+				all )
+					STAGE3=1
+					LIVECD1=1
+					LIVECD2=1
+					TARBALL=1
+					MODULES=1
+					NEEDS_SNAPSHOT=1;;
 				stage3 )
 					STAGE3=1
 					NEEDS_SNAPSHOT=1;;
@@ -122,17 +142,19 @@
 				livecd-stage2 )
 					LIVECD2=1
 					NEEDS_SNAPSHOT=1;;
-				tarball ) TARBALL=1;;
+				tarball )
+					TARBALL=1;;
 				extensions )
 					MODULES=1
 					NEEDS_SNAPSHOT=1;;
+				* ) gtest 1 'Specified stage is unknown!';;
 			esac
 			NOTARGET=0;;
 		f ) FORCEYES=1;;
 		l ) GNAPLOGPREFIX="${OPTARG}";;
 		c ) CATALYST_CONF="${OPTARG}";;
 		e ) SPECS="${OPTARG}";;
-		* ) gtest 1 'Specified options are incomplete or unknown !';;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
@@ -147,8 +169,7 @@
 # Prepare specs dir and check common.conf file
 SPECDIR="${TEMPDIR}/specs"
 if [[ -f "${SPECS}" ]]; then
-	mkdir "${SPECDIR}"
-	gtest continued $? 'Failed to create specs temporary subdirectory'
+	gmkdir "${SPECDIR}"
 	tar jx -f "${SPECS}" -C "${SPECDIR}"
 	gtest continued $? 'Failed to unpack specs'
 elif [[ -d "${SPECS}" ]]; then
@@ -158,7 +179,7 @@
 	gtest continued 1 "${SPECS} not found, provide a valid -e option"
 fi
 test -f "${SPECDIR}/common.conf"
-gtest continued $? "Incorrect specdir: ${SPECDIR}/common.conf not found !"
+gtest continued $? "Incorrect specdir: ${SPECDIR}/common.conf not found!"
 source "${SPECDIR}/common.conf"
 export CHOST
 export CFLAGS
@@ -169,30 +190,16 @@
 
 # catalyst.conf file
 test -f "${CATALYST_CONF}"
-gtest continued $? "${CATALYST_CONF} file not found !"
+gtest continued $? "${CATALYST_CONF} file not found!"
 source "${CATALYST_CONF}"
 
-# Default targets is complete core build
-if [[ "${ALLTARGET}" -eq 1 ]]; then
-	STAGE3=1
-	LIVECD1=1
-	LIVECD2=1
-	TARBALL=1
-	MODULES=1
-	NEEDS_SNAPSHOT=1
-fi
-
 # At least one target is needed
 test "${NOTARGET}" -eq 0
 gtest continued $? \
 	'No target specified. You should provide at least one -t option.'
 
-# CATALYST_DIR must exist
-if [[ ! -d "${CATALYST_DIR}" ]]; then
-  mkdir "${CATALYST_DIR}"
-  gtest continued $? \
-	"Error: failed to create ${CATALYST_DIR} directory."
-fi
+# storedir must exist
+gmkdir "${storedir}"
 
 # Stage3 needs a seed stage
 if [[ "${STAGE3}" -eq 1 ]]; then
@@ -211,17 +218,14 @@
 	test -f "${STAGE3FILE}"
 	gtest continued $? "${STAGE3FILE} is not a valid stage3 tarball"
 fi
-gtest 0
 
 # If extensions and no stage3, warn that we'll use seedstage as stage3
-STAGE3LOC="${CATALYST_DIR}/builds/${RELTYPE}/stage3-${SUBARCH}-${STAMP}.tar.bz2"
+STAGE3LOC="${storedir}/builds/${RELTYPE}/stage3-${SUBARCH}-${STAMP}.tar.bz2"
 if [[ "${MODULES}" -eq 1 || "${LIVECD1}" -eq 1 ]]; then
 	if [[ "${STAGE3}" -ne 1 && ! -f "${STAGE3LOC}" ]]; then
 		gwarn '"livecd-stage1" or "extensions" was selected without "stage3".'
-		gconfirm 'Should I use the seed stage as stage3 result ?'
-		if [[ ! -d "${CATALYST_DIR}/builds/${RELTYPE}" ]]; then
-			mkdir -p "${CATALYST_DIR}/builds/${RELTYPE}"
-		fi
+		gconfirm 'Should I use the seed stage as stage3 result?'
+		gmkdir "${storedir}/builds/${RELTYPE}"
 		cp "${STAGE3FILE}" "${STAGE3LOC}"
 	fi
 fi
@@ -242,14 +246,12 @@
 if [[ "${MODULES}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[extensions]"
 fi
-gwarn 'The following targets will be called:'
-gwarn "${TARGETLIST}"
+ginfo 'The following targets will be called:'
+ginfo "${TARGETLIST}"
 
 # Confirm tarball overwrite if TARBALL stage selected
-if [[ "${TARBALL}" -eq 1 ]]; then
-	if [[ -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]]; then
-		gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
-	fi
+if [[ "${TARBALL}" -eq 1 -a -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]]; then
+	gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
 fi
 
 # Logfile setup and confirmation
@@ -275,17 +277,14 @@
 if [[ "${NEEDS_SNAPSHOT}" -eq 1 ]]; then
 	gbegin 'Preparing portage snapshot'
 
-	if [[ ! -d "${CATALYST_DIR}/snapshots" ]]; then
-		mkdir -p "${CATALYST_DIR}/snapshots"
-	fi
+	gmkdir "${storedir}/snapshots"
 
 	if [[ -z "${PORTAGE_OVERLAYS}" ]]; then
-		cp "${SNAPSHOTFILE}" "${CATALYST_DIR}/snapshots/portage-${STAMP}.tar.bz2"
+		cp "${SNAPSHOTFILE}" "${storedir}/snapshots/portage-${STAMP}.tar.bz2"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
 	else
 		TEMPPRTDIR="${TEMPDIR}/portage"
-		mkdir "${TEMPPRTDIR}"
-		gtest continued $? 'Failed to create portage temporary subdirectory'
+		gmkdir "${TEMPPRTDIR}"
 
 		tar jxf "${SNAPSHOTFILE}" -C "${TEMPPRTDIR}" \
 			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
@@ -295,7 +294,7 @@
 			gtest continued $? "Failed to copy ${overlay}"
 		done
 
-		tar jcf "${CATALYST_DIR}/snapshots/portage-${STAMP}.tar.bz2" \
+		tar jcf "${storedir}/snapshots/portage-${STAMP}.tar.bz2" \
 			-C "${TEMPPRTDIR}" . \
 			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
@@ -306,10 +305,8 @@
 if [[ "${STAGE3}" -eq 1 ]]; then
 	gbegin "${G}[stage3]${N} stage (base system build)"
 
-	if [[ ! -d "${CATALYST_DIR}/builds/${RELTYPE}" ]]; then
-		mkdir -p "${CATALYST_DIR}/builds/${RELTYPE}"
-	fi
-	cp "${STAGE3FILE}" "${CATALYST_DIR}/builds/${RELTYPE}/seedstage.tar.bz2"
+	gmkdir "${storedir}/builds/${RELTYPE}"
+	cp "${STAGE3FILE}" "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
 
 	TEMPCONF="${TEMPDIR}/stage3.conf"
 	touch "${TEMPCONF}"
@@ -328,7 +325,7 @@
 	$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
 		>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
 	gtest $? "[stage3] failed, ${SEELOGFILES}"
-	rm "${CATALYST_DIR}/builds/${RELTYPE}/seedstage.tar.bz2"
+	rm "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
 fi
 
 # LIVECD-STAGE1 phase
@@ -389,16 +386,14 @@
 	gbegin "${G}[tarball]${N} phase (Creation of core and basefs components)"
 	test -e "gnap-${GNAPVERSION}-${STAMP}.iso"
 	gtest continued $? "No gnap-${GNAPVERSION}-${STAMP}.iso file to convert !"
-	test -d "${CATALYST_DIR}/tmp/gnap/livecd-stage1-${SUBARCH}-${STAMP}"
+	test -d "${storedir}/tmp/gnap/livecd-stage1-${SUBARCH}-${STAMP}"
 	gtest $? 'Missing livecd-stage2 results'
 
 	gbegin '  Creating core component'
 	TEMPMNTDIR="${TEMPDIR}/mount"
-	mkdir "${TEMPMNTDIR}"
-	gtest continued $? 'Failed to create mount temporary subdirectory'
+	gmkdir "${TEMPMNTDIR}"
 	TEMPISODIR="${TEMPDIR}/iso"
-	mkdir "${TEMPISODIR}"
-	gtest continued $? 'Failed to create iso temporary subdirectory'
+	gmkdir "${TEMPISODIR}"
 
 	mount -o loop "gnap-${GNAPVERSION}-${STAMP}.iso" ${TEMPMNTDIR} && \
 		cp -r ${TEMPMNTDIR}/* ${TEMPISODIR}
@@ -419,14 +414,14 @@
 
 	gbegin '  Creating basefs component'
 	tar jcf "gnap-basefs-${GNAPVERSION}-${STAMP}.tar.bz2" \
-		-C "${CATALYST_DIR}/tmp/gnap/livecd-stage2-${SUBARCH}-${STAMP}" .
+		-C "${storedir}/tmp/gnap/livecd-stage2-${SUBARCH}-${STAMP}" .
 	gtest $? 'Unable to create basefs tarball'
 fi
 
 # EXTENSIONS phase
 if [[ "${MODULES}" -eq 1 ]]; then
 	gbegin "${G}[extensions]${N} stage start"
-	GRP_PREFIX="${CATALYST_DIR}/builds/${RELTYPE}/grp-${SUBARCH}-${STAMP}"
+	GRP_PREFIX="${storedir}/builds/${RELTYPE}/grp-${SUBARCH}-${STAMP}"
 	SPECMODULE="${SPECDIR}/extensions.conf"
 	mod_list=$(grep '^extensions:' "${SPECMODULE}" 2>/dev/null);
 	mod_list="${mod_list/extensions:/}"
@@ -460,12 +455,10 @@
 
 		$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
 			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
-		gtest continued $? \
-			"Extension build failed, ${SEELOGFILES}"
+		gtest continued $? "Extension build failed, ${SEELOGFILES}"
 
 		TEMPMODULEDIR="${TEMPDIR}/module_${mod_name}"
-		mkdir "${TEMPMODULEDIR}"
-		gtest continued $? 'Failed to create module temporary subdirectory'
+		gmkdir "${TEMPMODULEDIR}"
 		for pkg in $( ls ${GRP_PREFIX}/${mod_name}/All/*.tbz2 ); do
 			tar jxf $pkg -C "${TEMPMODULEDIR}" -p \
 				>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
@@ -488,5 +481,5 @@
 fi
 
 cleanup
-echo 'Build successful !'
+echo 'Build successful!'
 exit 0
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0/src/specs/common.conf gnap-2.0+cleanup/src/specs/common.conf
--- gnap-2.0/src/specs/common.conf	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/src/specs/common.conf	2007-07-17 15:40:34.000000000 +0300
@@ -1,9 +1,3 @@
-# Catalyst executable and support files
-CATALYST_NAME='catalyst'
-CATALYST_BIN="/usr/bin/${CATALYST_NAME}"
-CATALYST_CONF="/etc/${CATALYST_NAME}/${CATALYST_NAME}.conf"
-CATALYST_DIR="/var/tmp/${CATALYST_NAME}"
-
 # Profile and build flags to use
 SUBARCH="x86"
 PROFILE="uclibc/x86/hardened"
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0/tools/gnap_overlay gnap-2.0+cleanup/tools/gnap_overlay
--- gnap-2.0/tools/gnap_overlay	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/tools/gnap_overlay	2007-08-02 15:56:18.000000000 +0300
@@ -3,8 +3,9 @@
 
 GNAPNAME=$(basename "$0")
 echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
-GNAPCORE='/usr/lib/gnap/gnap-core.tar'
-GNAPMBR='/usr/lib/gnap/mbr/mbr.bin'
+GNAPLIBDIR='/usr/lib/gnap'
+GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
+GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
 TEMPDIR=''
 IMG_SIZE=15
 
@@ -24,6 +25,11 @@
 	echo -e " ${G}*${N} ${*}"
 }
 
+gmkdir() {
+	mkdir -p "$1"
+	gtest continued $? "Failed to create directory \"$1\"."
+}
+
 gconfirm() {
 	if [[ "${FORCEYES}" -eq 1 ]]; then
 		gwarn "${*} forced to yes"
@@ -33,7 +39,7 @@
 			if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
 				cleanup
 			fi
-			echo 'Overlay aborted !'
+			echo 'Overlay aborted!'
 			exit 2
 		fi
 	fi
@@ -98,7 +104,7 @@
     echo '  -S size       Size of image file in megabyte'
     echo '  The disk target options also apply, except -d.'
     echo
-    echo "Please man ${GNAPNAME} for more details."
+    echo "Please use man ${GNAPNAME} for more details."
 }
 
 cleanup() {
@@ -126,8 +132,17 @@
 gbegin 'Checking parameters'
 
 # Read options
-while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' options; do
-	case ${options} in
+NOLOGO=0
+FORCEYES=0
+OUTPUT=''
+TYPE=''
+CREATE='n'
+TARGETROOT=''
+CACHE=''
+SERIAL=''
+BAUDRATE=''
+while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' option; do
+	case ${option} in
 		h ) usage
 			exit 0;;
 		g ) GNAPCORE="${OPTARG}";;
@@ -150,7 +165,7 @@
 		m ) CACHE='docache ';;
 		s ) SERIAL="console=ttyS0,${OPTARG}n81"
 			BAUDRATE="${OPTARG}";;
-		* ) gtest 1 'Specified options are incomplete or unknown !';;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
@@ -192,7 +207,7 @@
 	gwarn "${W}dd if=${GNAPMBR} of=${PARENTDEV} bs=512 count=1${N} if needed"
 	gwarn "${OUTPUT} must contain an active partition:"
 	gwarn " use ${W}fdisk ${PARENTDEV}${N} if needed"
-	gwarn "Current data on ${OUTPUT} will be ${B}destroyed${N} !"
+	gwarn "Current data on ${OUTPUT} will be ${B}destroyed${N}!"
 	gconfirm 'Are you sure you want to continue ?'
 fi
 
@@ -201,20 +216,18 @@
 TEMPDIR=$(mktemp -d -t gnap_overlay.XXXXXX)
 gtest continued $? 'Failed to create temporary directory'
 TEMPCOREDIR="${TEMPDIR}/core"
-mkdir "${TEMPCOREDIR}"
-gtest continued $? 'Failed to create core temporary subdirectory'
+gmkdir "${TEMPCOREDIR}"
 tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}"
 gtest $? 'Failed to extract core'
 
 gbegin 'Preparing overlay'
 TEMPOVERDIR="${TEMPDIR}/overlay"
-mkdir "${TEMPOVERDIR}"
-gtest $? 'Failed to create overlay temporary subdirectory'
+gmkdir "${TEMPOVERDIR}"
 
 if [[ -n "${BAUDRATE}" ]]; then
 	gbegin 'Adding baudrate for serial console'
-	mkdir -p "${TEMPOVERDIR}/etc/gnap" && \
-		echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
+	gmkdir "${TEMPOVERDIR}/etc/gnap"
+	echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
 	gtest $? 'Failed to create /etc/gnap/baudrate'
 fi
 for overlay in ${OVERLAYS} ; do
@@ -231,8 +244,7 @@
 if [[ -n "${OVERLAYCONF}" ]]; then
 	gbegin "Adding ${OVERLAYCONF} (overlay.conf file)"
 	if [[ ! -d "${TEMPOVERDIR}/etc" ]]; then
-		mkdir "${TEMPOVERDIR}/etc"
-		gtest continued $? 'Failed to create /etc overlay directory'
+		gmkdir "${TEMPOVERDIR}/etc"
 	fi
 	cp "${OVERLAYCONF}" "${TEMPOVERDIR}/etc/overlay.conf"
 	gtest $? "Failed to copy ${OVERLAYCONF}"
@@ -256,7 +268,7 @@
 # Target specific actions
 if [[ "${TYPE}" == 'iso' ]]; then
 	if [[ -f "${OUTPUT}" ]]; then
-		gconfirm "File ${OUTPUT} already exists, overwrite ?"
+		gconfirm "File ${OUTPUT} already exists, overwrite?"
 	fi
 	rm "${TEMPCOREDIR}/syslinux.cfg"
 	gbegin "Building ${OUTPUT} ISO file"
@@ -285,7 +297,7 @@
 
 		if [[ "${CREATE}"  == y ]]; then
 			if [[ -f "${OUTPUT}" ]]; then
-				gconfirm "File ${OUTPUT} already exists, overwrite ?"
+				gconfirm "File ${OUTPUT} already exists, overwrite?"
 			fi
 
 			gbegin 'Creating image file'
@@ -328,8 +340,7 @@
 
 	gbegin "Mounting ${OUTPUT}"
 	TEMPMOUNTDIR="${TEMPDIR}/mount"
-	mkdir "${TEMPMOUNTDIR}"
-	gtest continued $? 'Failed to create mount temporary subdirectory'
+	gmkdir "${TEMPMOUNTDIR}"
 	mount -t msdos "${OUTPUT}" "${TEMPMOUNTDIR}"
 	gtest $?
 
@@ -375,5 +386,5 @@
 
 # Successful finish
 cleanup
-echo 'Overlay successful !'
+echo 'Overlay successful!'
 exit 0
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0/tools/gnap_remaster gnap-2.0+cleanup/tools/gnap_remaster
--- gnap-2.0/tools/gnap_remaster	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/tools/gnap_remaster	2007-08-02 15:56:39.000000000 +0300
@@ -3,11 +3,12 @@
 
 GNAPNAME=$(basename "$0")
 echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
-GNAPCORE='/usr/lib/gnap/gnap-core.tar'
-GNAPBASEFS='/usr/lib/gnap/gnap-basefs.tar.bz2'
-GNAPEXTDIR='/usr/lib/gnap/extensions'
-OUTPUT='mygnap-core.tar'
+GNAPLIBDIR='/usr/lib/gnap'
+GNAPEXTDIR="${GNAPLIBDIR}/extensions"
 TEMPDIR=''
+GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
+GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
+OUTPUT='mygnap-core.tar'
 
 G=$'\e[32;01m'
 B=$'\e[31;01m'
@@ -21,6 +22,11 @@
 	echo -e " ${W}*${N} ${*}"
 }
 
+gmkdir() {
+	mkdir -p "$1"
+	gtest continued $? "Failed to create directory \"$1\"."
+}
+
 gconfirm() {
 	if [[ "${FORCEYES}" -eq 1 ]]; then
 		gwarn "${*} forced to yes"
@@ -30,7 +36,7 @@
 			if [[ -n "${TEMPDIR}" ]]; then
 				cleanup
 			fi
-			echo 'Remaster aborted !'
+			echo 'Remaster aborted!'
 			exit 2
 		fi
 	fi
@@ -79,9 +85,9 @@
 	echo '  -g gnap_core    Original GNAP core file'
 	echo '  -b basefs       basefs.tar.bz2 file to use as base'
 	echo '  -d extdir       Directory where to find extensions'
-	echo '  -f              Force all answers to yes (dangerous !)'
+	echo '  -f              Force all answers to yes (dangerous!)'
 	echo
-	echo "Please man ${GNAPNAME} for more details."
+	echo "Please use man ${GNAPNAME} for more details."
 }
 
 cleanup() {
@@ -104,8 +110,14 @@
 gbegin 'Checking parameters'
 
 # Read options
-while getopts ':he:k:m:o:g:b:d:f' options; do
-	case ${options} in
+EXTENSIONS=''
+KERNEXT=''
+MODEXT=''
+GNAPBASEFS=''
+GNAPEXTDIR=''
+FORCEYES=0
+while getopts ':he:k:m:o:g:b:d:f' option; do
+	case ${option} in
 		h ) usage
 			exit 0;;
 		e ) EXTENSIONS="${EXTENSIONS} ${OPTARG}";;
@@ -116,7 +128,7 @@
 		b ) GNAPBASEFS="${OPTARG}";;
 		d ) GNAPEXTDIR="${OPTARG}";;
 		f ) FORCEYES=1;;
-		* ) gtest 1 'Specified options are incomplete or unknown !';;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
@@ -146,8 +158,7 @@
 TEMPDIR=$(mktemp -d -t gnap_remaster.XXXXXX)
 gtest continued $? 'Failed to create temporary directory'
 TEMPOVERDIR="${TEMPDIR}/basefs"
-mkdir "${TEMPOVERDIR}"
-gtest continued $? 'Failed to create basefs temporary subdirectory'
+gmkdir "${TEMPOVERDIR}"
 
 tar jx -C "${TEMPOVERDIR}" -f "${GNAPBASEFS}"
 gtest $? 'Failed to unpack basefs'
@@ -163,8 +174,7 @@
 # Preparing new core
 gbegin 'Extracting core tarball'
 TEMPCOREDIR="${TEMPDIR}/core"
-mkdir "${TEMPCOREDIR}"
-gtest continued $? 'Failed to create core temporary subdirectory'
+gmkdir "${TEMPCOREDIR}"
 
 tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}" --exclude image.squashfs
 gtest $? 'Failed to extract core'
@@ -172,8 +182,7 @@
 if [[ -f "${KERNEXT}" ]]; then
 	gbegin "Replacing kernel and initrd using ${KERNEXT}"
 	TEMPKERNDIR="${TEMPDIR}/kernel"
-	mkdir "${TEMPKERNDIR}"
-	gtest continued $? 'Failed to create kernel temporary subdirectory'
+	gmkdir "${TEMPKERNDIR}"
 
 	tar jx -C "${TEMPKERNDIR}" -f "${KERNEXT}"
 	gtest continued $? 'Failed to extract kernpackage'
@@ -205,6 +214,6 @@
 
 # Successful finish
 cleanup
-echo 'Remaster successful !'
+echo 'Remaster successful!'
 exit 0
 
Only in gnap-2.0+cleanup/tools: gnap_shared.sh
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0/tools/packlister.pl gnap-2.0+cleanup/tools/packlister.pl
--- gnap-2.0/tools/packlister.pl	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/tools/packlister.pl	2007-07-09 21:10:18.000000000 +0300
@@ -1,49 +1,77 @@
-sub dump
+#! /usr/bin/perl
+#
+# packlister.pl prints out the given version number and a list of
+# packages found in the corresponding catalyst package cache and
+# grp cache.
+#
+# Usage: packlister.pl <version>
+#        packlister.pl <version> | reducedsnapshot.pl
+#        packlister.pl <version> > packlisterfile
+
+sub find_and_dump
 {
-  while (<FIND>)
-  {
-    if (/^(\d+)\s+(.+)\/(.+)\/(.+)$/)
-    {
-    	$size = $1;
-	$cstage = $2;
-	$cat = $3;
-	$name = $4;
-	if ($cstage =~ /.*\/(.+)-x86-.+/)
+	if (scalar @_ == 0)
 	{
-		$stage=$1;
+		return;
 	}
-	else
+	
+	open (FIND, "find $_ -name '*.tbz2' -exec ls -Ls {} \\; | "
+		. "grep -v '/All/' |");
+	
+	while (<FIND>)
 	{
-		print STDERR "ERROR ($cstage)\n";
+		if (/^(\d+)\s+(.+)\/([A-Za-z0-9+_]+[A-Za-z0-9+_.-]*)\/(.+)$/)
+		{
+			$size = $1;
+			$cstage = $2;
+			$cat = $3;
+			$name = $4;
+			
+			# There might be more than x86 supported in future versions.
+			if ($cstage =~ /.*\/(.+)-x86-.+/)
+			{
+				$stage=$1;
+			}
+			else
+			{
+				print STDERR "ERROR ($cstage)\n";
+			}
+			
+			# FIXME: The second regex (elsif) seems to match the stuff
+			# the first one also matches. Is this needed?
+			if ($name =~ /^(.+)-(.+-r\d+)\.tbz2/)
+			{
+				$packages{"$cat/$1"} = "$2 - $size Kb - $stage";
+			} 
+			elsif ($name =~ /^(.+)-(.+)\.tbz2/)
+			{
+				$packages{"$cat/$1"} = "$2 - $size Kb - $stage";
+			} 
+			else
+			{
+				print STDERR "ERROR ($name)\n"
+			}	
+		}
+		else
+		{
+			print STDERR "ERROR : $_";
+		}
 	}
-	if ($name =~ /^(.+)-(.+-r\d+)\.tbz2/)
-	{
-		$packages{"$cat/$1"} = "$2 - $size Kb - $stage";
-	} 
-	elsif ($name =~ /^(.+)-(.+)\.tbz2/)
-	{
-		$packages{"$cat/$1"} = "$2 - $size Kb - $stage";
-	} 
-	else
-	{
-		print STDERR "ERROR ($name)\n"
-	}	
-    }
-    else
-    {
-    	print STDERR "ERROR : $_";
-    }
-  }
+	
+	close (FIND);
+}
+
+# Check script parameters
+if (scalar @ARGV == 0)
+{
+	die "Usage: $ENV{_} <version>\n";
 }
+
+# Print version and file list based on catalyst
 print "$ARGV[0]\n";
-$loc = "/var/tmp/catalyst/packages/gnap/*$ARGV[0]";
-open (FIND,"find $loc -name '*.tbz2' -exec ls -Ls {} \\; | grep -v '/All/' |");
-&dump();
-close FIND;
-$loc = "/var/tmp/catalyst/builds/gnap/grp*$ARGV[0]/*";
-open (FIND,"find $loc -name '*.tbz2' -exec ls -Ls {} \\; | grep -v '/All/' |");
-&dump();
-close FIND;
+&find_and_dump("/var/tmp/catalyst/packages/gnap/*$ARGV[0]");
+&find_and_dump("/var/tmp/catalyst/packages/gnap/grp*$ARGV[0]/*");
+
 #No need to grab for kernel sources as they are found in the /ALL/ directory
 #$kernel=`grep sys-kernel gnap_make-$ARGV[0].out | grep merged | grep sources`;
 #if ($kernel =~ /(sys-kernel\/.*-sources)-(.*) merged/)
@@ -54,11 +82,13 @@
 #{
 #  print STDERR "Kernel not found: $kernel\n";
 #}
+
 foreach $key (sort(keys(%packages)))
 {
-  print STDOUT "$key $packages{$key}\n";
+	print STDOUT "$key $packages{$key}\n";
 }
-  #Groff is part of the stage3 tarball but not remerged so we have to add it manually
-  print STDOUT "sys-apps/groff 1.19.2-r1 - 116 Kb - stage3\n";
-  #htbinit is merged with kernel sources and somehow missed by the script
-  print STDOUT "net-misc/htbinit 0.8.5-r1 - 116 Kb - livecd-stage2\n";
+
+#Groff is part of the stage3 tarball but not remerged so we have to add it manually
+print STDOUT "sys-apps/groff 1.19.2-r1 - 116 Kb - stage3\n";
+#htbinit is merged with kernel sources and somehow missed by the script
+print STDOUT "net-misc/htbinit 0.8.5-r1 - 116 Kb - livecd-stage2\n";
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0/tools/reducedsnapshot.pl gnap-2.0+cleanup/tools/reducedsnapshot.pl
--- gnap-2.0/tools/reducedsnapshot.pl	2007-07-23 14:14:39.000000000 +0300
+++ gnap-2.0+cleanup/tools/reducedsnapshot.pl	2007-07-23 14:16:49.000000000 +0300
@@ -1,3 +1,13 @@
+#! /usr/bin/perl
+#
+# resucedsnapshot.pl creates a reduced portage snapshot based on a
+# dfault set (eclasses, profiles) and a packagelist created by
+# packlister.pl.
+#
+# Usage: packlister.pl <version> | reducedsnapshot.pl
+#        reducedsnapshot.pl packlisterfile
+#        reducedsnapshot.pl < packlisterfile
+
 @minportage = ( 
 	"portage/eclass",
 	"portage/profiles/arch.list",
@@ -14,19 +24,21 @@
 	"portage/profiles/uclibc",
 	"portage/profiles/updates",
 	"portage/profiles/use.desc",
-	"portage/profiles/use.local.desc");
+	"portage/profiles/use.local.desc"
+);
+
 print "Building package list...\n";
 $version = <>;
 chop $version;
 while (<>)
 {
-  ($pack,$ver,,,,)=split;
-  push (@minportage,"portage/$pack");
-  push (@minportage,"portage/metadata/cache/$pack-$ver");
+	($pack,$ver,,,,) = split;
+	push (@minportage, "portage/$pack");
+	push (@minportage, "portage/metadata/cache/$pack-$ver");
 }
+
 print "Extracting portage...\n";
 system "mkdir tmp_port";
-
 system "tar jx -C tmp_port -f /var/tmp/catalyst/snapshots/portage-$version.tar.bz2";
 print "Creating reduced portage snapshot...\n";
 system "tar jc -C tmp_port -f redportage-$version.tar.bz2 @minportage";

[-- Attachment #3: 02-gnap-split.patch --]
[-- Type: text/x-patch, Size: 10490 bytes --]

diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup/src/gnap_make gnap-2.0+cleanup+split/src/gnap_make
--- gnap-2.0+cleanup/src/gnap_make	2007-08-02 15:55:38.000000000 +0300
+++ gnap-2.0+cleanup+split/src/gnap_make	2007-08-02 15:54:29.000000000 +0300
@@ -1,78 +1,9 @@
 #!/bin/bash
 GNAPVERSION='2.0'
 
-GNAPNAME=$(basename "$0")
-echo "GNAP Core Building tool ${GNAPNAME} version ${GNAPVERSION}"
 GNAPLIBDIR='/usr/lib/gnap'
-STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
-SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
-SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
-TEMPDIR=''
-
-G=$'\e[32;01m'
-B=$'\e[31;01m'
-N=$'\e[0m'
-W=$'\e[33;01m'
-K=$'\e[34;01m'
-C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
-E=$'\e['${C}'G'
-
-gwarn() {
-	echo -e " ${W}*${N} ${*}"
-}
-
-ginfo() {
-	echo -e " ${G}*${N} ${*}"
-}
-
-gmkdir() {
-	mkdir -p "$1"
-	gtest continued $? "Failed to create directory \"$1\"."
-}
-
-gconfirm() {
-	if [[ "${FORCEYES}" -eq 1 ]]; then
-		gwarn "${*} forced to yes"
-	else
-		read -ep " ${W}*${N} ${*} [N]: " answer
-		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" ]]; then
-				cleanup
-			fi
-			echo Build aborted!
-			exit 2
-		fi
-	fi
-}
-
-gbegin() {
-	echo -ne " ${G}*${N} ${*}..."
-}
-
-gtest() {
-	continued=0
-	if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
-		shift
-		continued=1
-	fi
-	if [[ "$#" -eq 0 || "${1}" -eq 0 ]]; then
-		if [[ "${continued}" -eq 0 ]]; then
-			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
-		fi
-	else
-		echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		if [[ "$#" -ge 2 ]]; then
-			shift
-			echo -en " ${B}*${N} ${*}"
-			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		fi
-		if [[ -n "${TEMPDIR}" ]]; then
-			cleanup
-		fi
-		echo "Build failed, try man ${GNAPNAME} for more help"
-		exit 1
-	fi
-}
+source ${GNAPLIBDIR}/gnap_shared.sh
+echo "GNAP Core Building tool ${GNAPNAME} version ${GNAPVERSION}"
 
 usage() {
 	echo 'Options:'
@@ -89,18 +20,6 @@
 	echo "Please use man ${GNAPNAME} for more details."
 }
 
-cleanup() {
-	gbegin 'Cleaning temporary directories'
-	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
-		rm -rf "${DIRTOREMOVE}"
-		gtest $? "Failed to remove ${DIRTOREMOVE}"
-	else
-		gtest 0
-	fi
-}
-
 if [[ "$#" -eq 0 ]]; then
 	usage
 	exit 0
@@ -109,7 +28,7 @@
 gbegin 'Checking parameters'
 
 # Catalyst executable and config file
-CATALYST_BIN="/usr/bin/catayst"
+CATALYST_BIN="/usr/bin/catalyst"
 CATALYST_CONF="/etc/catalyst/catalyst.conf"
 
 # Read options
@@ -250,7 +169,7 @@
 ginfo "${TARGETLIST}"
 
 # Confirm tarball overwrite if TARBALL stage selected
-if [[ "${TARBALL}" -eq 1 -a -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]]; then
+if [[ "${TARBALL}" -eq 1 && -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]]; then
 	gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
 fi
 
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup/tools/gnap_overlay gnap-2.0+cleanup+split/tools/gnap_overlay
--- gnap-2.0+cleanup/tools/gnap_overlay	2007-08-02 15:56:18.000000000 +0300
+++ gnap-2.0+cleanup+split/tools/gnap_overlay	2007-07-27 16:00:56.000000000 +0300
@@ -1,79 +1,11 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAPNAME=$(basename "$0")
-echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
 GNAPLIBDIR='/usr/lib/gnap'
-GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
-GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
-TEMPDIR=''
-IMG_SIZE=15
-
-G=$'\e[32;01m'
-B=$'\e[31;01m'
-N=$'\e[0m'
-W=$'\e[33;01m'
-K=$'\e[34;01m'
-C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
-E=$'\e['${C}'G'
-
-gwarn() {
-	echo -e " ${W}*${N} ${*}"
-}
-
-ginfo() {
-	echo -e " ${G}*${N} ${*}"
-}
-
-gmkdir() {
-	mkdir -p "$1"
-	gtest continued $? "Failed to create directory \"$1\"."
-}
-
-gconfirm() {
-	if [[ "${FORCEYES}" -eq 1 ]]; then
-		gwarn "${*} forced to yes"
-	else
-		read -ep " ${W}*${N} ${*} [N]: " answer
-		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
-				cleanup
-			fi
-			echo 'Overlay aborted!'
-			exit 2
-		fi
-	fi
-}
-
-gbegin() {
-	echo -ne " ${G}*${N} ${*}..."
-}
-
-gtest() {
-	continued=0
-	if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
-		shift
-		continued=1
-	fi
+source ${GNAPLIBDIR}/gnap_shared.sh
+echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
 
-	if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
-		if [[ "${continued}" -eq 0 ]]; then
-			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
-		fi
-	else
-		echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		if [[ "$#" -ge 2 ]]; then
-			shift
-			echo -en " ${B}*${N} ${*}"
-			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		fi
-		if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
-			cleanup
-		fi
-		echo "Overlay failed, try ${GNAPNAME} -h for more help"
-		exit 1
-	fi
-}
+IMG_SIZE=15
 
 usage() {
 	echo
@@ -107,23 +39,6 @@
     echo "Please use man ${GNAPNAME} for more details."
 }
 
-cleanup() {
-	if [[ -n "${LOOP}" ]]; then
-		gbegin 'Unmounting loop filesystem'
-		umount "${LOOP}" && losetup -d "${LOOP}"
-		gtest $? "Failed to unmount ${LOOP}"
-	fi
-	gbegin 'Cleaning temporary directories'
-	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
-		rm -rf "${DIRTOREMOVE}"
-		gtest $? "Failed to remove ${DIRTOREMOVE}"
-	else
-		gtest 0
-	fi
-}
-
 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
 	usage
 	exit 0
@@ -226,7 +141,7 @@
 
 if [[ -n "${BAUDRATE}" ]]; then
 	gbegin 'Adding baudrate for serial console'
-	gmkdir "${TEMPOVERDIR}/etc/gnap"
+	gmkdir -p "${TEMPOVERDIR}/etc/gnap"
 	echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
 	gtest $? 'Failed to create /etc/gnap/baudrate'
 fi
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup/tools/gnap_remaster gnap-2.0+cleanup+split/tools/gnap_remaster
--- gnap-2.0+cleanup/tools/gnap_remaster	2007-08-02 15:56:39.000000000 +0300
+++ gnap-2.0+cleanup+split/tools/gnap_remaster	2007-07-27 16:10:54.000000000 +0300
@@ -1,76 +1,11 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAPNAME=$(basename "$0")
-echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
 GNAPLIBDIR='/usr/lib/gnap'
-GNAPEXTDIR="${GNAPLIBDIR}/extensions"
-TEMPDIR=''
-GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
-GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
-OUTPUT='mygnap-core.tar'
-
-G=$'\e[32;01m'
-B=$'\e[31;01m'
-N=$'\e[0m'
-W=$'\e[33;01m'
-K=$'\e[34;01m'
-C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
-E=$'\e['${C}'G'
-
-gwarn() {
-	echo -e " ${W}*${N} ${*}"
-}
-
-gmkdir() {
-	mkdir -p "$1"
-	gtest continued $? "Failed to create directory \"$1\"."
-}
-
-gconfirm() {
-	if [[ "${FORCEYES}" -eq 1 ]]; then
-		gwarn "${*} forced to yes"
-	else
-		read -ep " ${W}*${N} ${*} [N]: " answer
-		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" ]]; then
-				cleanup
-			fi
-			echo 'Remaster aborted!'
-			exit 2
-		fi
-	fi
-}
-
-gbegin() {
-	echo -ne " ${G}*${N} ${*}..."
-}
+source ${GNAPLIBDIR}/gnap_shared.sh
+echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
 
-gtest() {
-	continued=0
-	if [[ "$#" -gt 0 && "${1}" == 'continued' ]]; then
-		shift
-		continued=1
-	fi
-
-	if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
-		if [[ "${continued}" -eq 0 ]]; then
-			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
-		fi
-	else
-		echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		if [[ "$#" -ge 2 ]]; then
-			shift
-			echo -en " ${B}*${N} ${*}"
-			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
-		fi
-		if [[ -n "${TEMPDIR}" ]]; then
-			cleanup
-		fi
-		echo "Remaster failed, try ${GNAPNAME} -h for more help"
-		exit 1
-	fi
-}
+OUTPUT='mygnap-core.tar'
 
 usage() {
 	echo
@@ -90,18 +25,6 @@
 	echo "Please use man ${GNAPNAME} for more details."
 }
 
-cleanup() {
-	gbegin 'Cleaning temporary directories'
-	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
-	 	rm -rf "${DIRTOREMOVE}"
-		gtest $? "Failed to remove ${DIRTOREMOVE}"
-	else
-		gtest 0
-	fi
-}
-
 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
 	usage
 	exit 0
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup/tools/gnap_shared.sh gnap-2.0+cleanup+split/tools/gnap_shared.sh
--- gnap-2.0+cleanup/tools/gnap_shared.sh	2007-08-03 16:28:37.000000000 +0300
+++ gnap-2.0+cleanup+split/tools/gnap_shared.sh	2007-08-02 15:54:46.000000000 +0300
@@ -0,0 +1,102 @@
+GNAPNAME=$(basename "$0")
+
+case ${GNAPNAME} in
+	gnap_make )     GNAP_PRODUCT="Build";;
+ 	gnap_overlay )  GNAP_PRODUCT="Overlay";;
+ 	gnap_remaster ) GNAP_PRODUCT="Remaster";;
+ 	* )             GNAP_PRODUCT="Something";;
+esac
+STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
+SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
+SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
+GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
+GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
+GNAPEXTDIR="${GNAPLIBDIR}/extensions"
+GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
+
+TEMPDIR=''
+LOOP=''
+FORCEYES=0
+
+G=$'\e[32;01m'
+B=$'\e[31;01m'
+N=$'\e[0m'
+W=$'\e[33;01m'
+K=$'\e[34;01m'
+C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
+E=$'\e['${C}'G'
+
+gwarn() {
+	echo -e " ${W}*${N} ${*}"
+}
+
+ginfo() {
+	echo -e " ${G}*${N} ${*}"
+}
+
+gmkdir() {
+	mkdir -p "$1"
+	gtest continued $? "Failed to create \"$1\"."
+}
+
+gconfirm() {
+	if [[ "${FORCEYES}" -eq 1 ]]; then
+		gwarn "${*} forced to yes"
+	else
+		read -ep " ${W}*${N} ${*} [N]: " answer
+		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
+			if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
+				cleanup
+			fi
+			echo '${GNAP_PRODUCT} aborted!'
+			exit 2
+		fi
+	fi
+}
+
+gbegin() {
+	echo -ne " ${G}*${N} ${*}..."
+}
+
+gtest() {
+	continued=0
+	if [[ "${#}" -gt 0 && "${1}" == 'continued' ]]; then
+		shift
+		continued=1
+	fi
+
+	if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
+		if [[ "${continued}" -eq 0 ]]; then
+			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
+		fi
+	else
+		echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
+		if [[ "${#}" -ge 2 ]]; then
+			shift
+			echo -en " ${B}*${N} ${*}"
+			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
+		fi
+		if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
+			cleanup
+		fi
+		echo " ${GNAP_PRODUCT} failed, try ${GNAPNAME} -h for more help"
+		exit 1
+	fi
+}
+
+cleanup() {
+	if [[ -n "${LOOP}" ]]; then
+		gbegin 'Unmounting loop filesystem'
+		umount "${LOOP}" && losetup -d "${LOOP}"
+		gtest $? "Failed to unmount ${LOOP}"
+	fi
+	gbegin 'Cleaning temporary directories'
+	if [[ -d "${TEMPDIR}" ]]; then
+		DIRTOREMOVE="${TEMPDIR}"
+		TEMPDIR=''
+		rm -rf "${DIRTOREMOVE}"
+		gtest $? "Failed to remove ${DIRTOREMOVE}"
+	else
+		gtest 0
+	fi
+}

[-- Attachment #4: 03-gnap-namespace.patch --]
[-- Type: text/x-patch, Size: 34886 bytes --]

diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup+split/src/gnap_make gnap-2.0+cleanup+split+namespace/src/gnap_make
--- gnap-2.0+cleanup+split/src/gnap_make	2007-08-02 15:54:29.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace/src/gnap_make	2007-08-02 15:50:45.000000000 +0300
@@ -1,9 +1,9 @@
 #!/bin/bash
-GNAPVERSION='2.0'
+VERSION='2.0'
 
-GNAPLIBDIR='/usr/lib/gnap'
-source ${GNAPLIBDIR}/gnap_shared.sh
-echo "GNAP Core Building tool ${GNAPNAME} version ${GNAPVERSION}"
+GNAP_LIBDIR='/usr/lib/gnap'
+source ${GNAP_LIBDIR}/gnap_shared.sh
+echo "GNAP Core Building tool ${NAME} version ${VERSION}"
 
 usage() {
 	echo 'Options:'
@@ -17,7 +17,7 @@
 	echo '    -c catalyst.conf     Use specific catalyst.conf file'
 	echo '    -e specs             Specs directory or tar.bz2 file'
 	echo
-	echo "Please use man ${GNAPNAME} for more details."
+	echo "Please use man ${NAME} for more details."
 }
 
 if [[ "$#" -eq 0 ]]; then
@@ -28,58 +28,64 @@
 gbegin 'Checking parameters'
 
 # Catalyst executable and config file
-CATALYST_BIN="/usr/bin/catalyst"
-CATALYST_CONF="/etc/catalyst/catalyst.conf"
+GNAP_CATALYST_BIN="/usr/bin/catalyst"
+GNAP_CATALYST_CONF="/etc/catalyst/catalyst.conf"
 
 # Read options
+GNAP_STAGE3=0
+GNAP_LIVECD1=0
+GNAP_LIVECD2=0
+GNAP_TARBALL=0
+GNAP_MODULES=0
+GNAP_STAMP=$(date +%Y%m%d)
 NOTARGET=1
-STAMP=$(date +%Y%m%d)
+NEEDS_SNAPSHOT=0
 while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
 	case ${option} in
 		h )
 			usage
 			exit 0;;
-		s ) STAGE3FILE="${OPTARG}";;
-		p ) SNAPSHOTFILE="${OPTARG}";;
-		o ) PORTAGE_OVERLAYS="${PORTAGE_OVERLAYS} ${OPTARG}";;
-		v ) STAMP="${OPTARG}";;
+		s ) GNAP_STAGE3FILE="${OPTARG}";;
+		p ) GNAP_SNAPSHOTFILE="${OPTARG}";;
+		o ) GNAP_PORTAGE_OVERLAYS="${GNAP_PORTAGE_OVERLAYS} ${OPTARG}";;
+		v ) GNAP_STAMP="${OPTARG}";;
 		t )
 			case "${OPTARG}" in
 				all )
-					STAGE3=1
-					LIVECD1=1
-					LIVECD2=1
-					TARBALL=1
-					MODULES=1
+					GNAP_STAGE3=1
+					GNAP_LIVECD1=1
+					GNAP_LIVECD2=1
+					GNAP_TARBALL=1
+					GNAP_MODULES=1
 					NEEDS_SNAPSHOT=1;;
 				stage3 )
-					STAGE3=1
+					GNAP_STAGE3=1
 					NEEDS_SNAPSHOT=1;;
 				livecd-stage1 )
-					LIVECD1=1
+					GNAP_LIVECD1=1
 					NEEDS_SNAPSHOT=1;;
 				livecd-stage2 )
-					LIVECD2=1
+					GNAP_LIVECD2=1
 					NEEDS_SNAPSHOT=1;;
 				tarball )
-					TARBALL=1;;
+					GNAP_TARBALL=1;;
 				extensions )
-					MODULES=1
+					GNAP_MODULES=1
 					NEEDS_SNAPSHOT=1;;
 				* ) gtest 1 'Specified stage is unknown!';;
 			esac
 			NOTARGET=0;;
-		f ) FORCEYES=1;;
-		l ) GNAPLOGPREFIX="${OPTARG}";;
-		c ) CATALYST_CONF="${OPTARG}";;
-		e ) SPECS="${OPTARG}";;
+		f ) GNAP_FORCEYES=1;;
+		l ) GNAP_LOGPREFIX="${OPTARG}";;
+		c ) GNAP_CATALYST_CONF="${OPTARG}";;
+		e ) GNAP_SPECS="${OPTARG}";;
 		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
 # Root is needed
 test "${EUID}" -eq 0
-gtest continued $? "You need to be root to run ${GNAPNAME}"
+gtest continued $? "You need to be root to run ${NAME}"
 
 # Setting up temporary directory
 TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
@@ -87,15 +93,15 @@
 
 # Prepare specs dir and check common.conf file
 SPECDIR="${TEMPDIR}/specs"
-if [[ -f "${SPECS}" ]]; then
+if [[ -f "${GNAP_SPECS}" ]]; then
 	gmkdir "${SPECDIR}"
-	tar jx -f "${SPECS}" -C "${SPECDIR}"
+	tar jx -f "${GNAP_SPECS}" -C "${SPECDIR}"
 	gtest continued $? 'Failed to unpack specs'
-elif [[ -d "${SPECS}" ]]; then
-	cp -rp "${SPECS}" "${SPECDIR}"
+elif [[ -d "${GNAP_SPECS}" ]]; then
+	cp -rp "${GNAP_SPECS}" "${SPECDIR}"
 	gtest continued $? 'Failed to copy specs directory contents'
 else
-	gtest continued 1 "${SPECS} not found, provide a valid -e option"
+	gtest continued 1 "${GNAP_SPECS} not found, provide a valid -e option"
 fi
 test -f "${SPECDIR}/common.conf"
 gtest continued $? "Incorrect specdir: ${SPECDIR}/common.conf not found!"
@@ -108,9 +114,9 @@
 fi
 
 # catalyst.conf file
-test -f "${CATALYST_CONF}"
-gtest continued $? "${CATALYST_CONF} file not found!"
-source "${CATALYST_CONF}"
+test -f "${GNAP_CATALYST_CONF}"
+gtest continued $? "${GNAP_CATALYST_CONF} file not found!"
+source "${GNAP_CATALYST_CONF}"
 
 # At least one target is needed
 test "${NOTARGET}" -eq 0
@@ -121,76 +127,76 @@
 gmkdir "${storedir}"
 
 # Stage3 needs a seed stage
-if [[ "${STAGE3}" -eq 1 ]]; then
-	test -f "${STAGE3FILE}"
+if [[ "${GNAP_STAGE3}" -eq 1 ]]; then
+	test -f "${GNAP_STAGE3FILE}"
 	gtest continued $? 'The "-s" option needs to designate a valid seed stage'
 fi
 
 # Snapshot must exist if a stage is selected
 if [[ "${NEEDS_SNAPSHOT}" -eq 1 ]]; then
-	test -f "${SNAPSHOTFILE}"
-	gtest continued $? "Can't find ${SNAPSHOTFILE}"
+	test -f "${GNAP_SNAPSHOTFILE}"
+	gtest continued $? "Can't find ${GNAP_SNAPSHOTFILE}"
 fi
 
 # Seed stage if needed must be an existing file
-if [[ "${STAGE3}" -eq 1 ]]; then
-	test -f "${STAGE3FILE}"
-	gtest continued $? "${STAGE3FILE} is not a valid stage3 tarball"
+if [[ "${GNAP_STAGE3}" -eq 1 ]]; then
+	test -f "${GNAP_STAGE3FILE}"
+	gtest continued $? "${GNAP_STAGE3FILE} is not a valid stage3 tarball"
 fi
 
 # If extensions and no stage3, warn that we'll use seedstage as stage3
-STAGE3LOC="${storedir}/builds/${RELTYPE}/stage3-${SUBARCH}-${STAMP}.tar.bz2"
-if [[ "${MODULES}" -eq 1 || "${LIVECD1}" -eq 1 ]]; then
-	if [[ "${STAGE3}" -ne 1 && ! -f "${STAGE3LOC}" ]]; then
+STAGE3LOC="${storedir}/builds/${RELTYPE}/stage3-${SUBARCH}-${GNAP_STAMP}.tar.bz2"
+if [[ "${GNAP_MODULES}" -eq 1 || "${GNAP_LIVECD1}" -eq 1 ]]; then
+	if [[ "${GNAP_STAGE3}" -ne 1 && ! -f "${STAGE3LOC}" ]]; then
 		gwarn '"livecd-stage1" or "extensions" was selected without "stage3".'
 		gconfirm 'Should I use the seed stage as stage3 result?'
 		gmkdir "${storedir}/builds/${RELTYPE}"
-		cp "${STAGE3FILE}" "${STAGE3LOC}"
+		cp "${GNAP_STAGE3FILE}" "${STAGE3LOC}"
 	fi
 fi
 
 # Explain what will get built
-if [[ "${STAGE3}" -eq 1 ]]; then
+if [[ "${GNAP_STAGE3}" -eq 1 ]]; then
 	TARGETLIST='[stage3] '
 fi
-if [[ "${LIVECD1}" -eq 1 ]]; then
+if [[ "${GNAP_LIVECD1}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[livecd-stage1] "
 fi
-if [[ "${LIVECD2}" -eq 1 ]]; then
+if [[ "${GNAP_LIVECD2}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[livecd-stage2] "
 fi
-if [[ "${TARBALL}" -eq 1 ]]; then
+if [[ "${GNAP_TARBALL}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[tarball] "
 fi
-if [[ "${MODULES}" -eq 1 ]]; then
+if [[ "${GNAP_MODULES}" -eq 1 ]]; then
 	TARGETLIST="${TARGETLIST}[extensions]"
 fi
 ginfo 'The following targets will be called:'
 ginfo "${TARGETLIST}"
 
 # Confirm tarball overwrite if TARBALL stage selected
-if [[ "${TARBALL}" -eq 1 && -e "gnap-${GNAPVERSION}-${STAMP}.tar" ]]; then
-	gconfirm "gnap-${GNAPVERSION}-${STAMP}.tar already exists, overwrite"
+if [[ "${GNAP_TARBALL}" -eq 1 && -e "gnap-${VERSION}-${GNAP_STAMP}.tar" ]]; then
+	gconfirm "gnap-${VERSION}-${GNAP_STAMP}.tar already exists, overwrite"
 fi
 
 # Logfile setup and confirmation
-if [[ -z "$GNAPLOGPREFIX" ]]; then
-	GNAPLOGPREFIX="./${GNAPNAME}-${STAMP}"
+if [[ -z "$GNAP_LOGPREFIX" ]]; then
+	GNAP_LOGPREFIX="./${NAME}-${GNAP_STAMP}"
 fi
 
-if [[ -f "${GNAPLOGPREFIX}.out" || -f "${GNAPLOGPREFIX}.err" ]]; then
-	if [[ "${FORCEYES}" -ne 1 ]]; then
+if [[ -f "${GNAP_LOGPREFIX}.out" || -f "${GNAP_LOGPREFIX}.err" ]]; then
+	if [[ "${GNAP_FORCEYES}" -ne 1 ]]; then
 		read -ep \
 			" ${W}*${N} Logfile(s) already exists. Append/Overwrite [A]: " \
 			answer
 		if [[ "${answer}" == 'o' || "${answer}" == 'O' ]]; then
-			rm "${GNAPLOGPREFIX}.out" "${GNAPLOGPREFIX}.err"
+			rm "${GNAP_LOGPREFIX}.out" "${GNAP_LOGPREFIX}.err"
 		fi
 	fi
 fi
-touch "${GNAPLOGPREFIX}.out"
-touch "${GNAPLOGPREFIX}.err"
-SEELOGFILES="see ${GNAPLOGPREFIX}.err and .out for details"
+touch "${GNAP_LOGPREFIX}.out"
+touch "${GNAP_LOGPREFIX}.err"
+SEELOGFILES="see ${GNAP_LOGPREFIX}.err and .out for details"
 
 # Snapshot preparation
 if [[ "${NEEDS_SNAPSHOT}" -eq 1 ]]; then
@@ -198,34 +204,34 @@
 
 	gmkdir "${storedir}/snapshots"
 
-	if [[ -z "${PORTAGE_OVERLAYS}" ]]; then
-		cp "${SNAPSHOTFILE}" "${storedir}/snapshots/portage-${STAMP}.tar.bz2"
+	if [[ -z "${GNAP_PORTAGE_OVERLAYS}" ]]; then
+		cp "${GNAP_SNAPSHOTFILE}" "${storedir}/snapshots/portage-${GNAP_STAMP}.tar.bz2"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
 	else
 		TEMPPRTDIR="${TEMPDIR}/portage"
 		gmkdir "${TEMPPRTDIR}"
 
-		tar jxf "${SNAPSHOTFILE}" -C "${TEMPPRTDIR}" \
-			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+		tar jxf "${GNAP_SNAPSHOTFILE}" -C "${TEMPPRTDIR}" \
+			>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 
-		for overlay in ${PORTAGE_OVERLAYS} ; do
+		for overlay in ${GNAP_PORTAGE_OVERLAYS} ; do
 			cp -rp ${overlay}/* "${TEMPPRTDIR}/portage"
 			gtest continued $? "Failed to copy ${overlay}"
 		done
 
-		tar jcf "${storedir}/snapshots/portage-${STAMP}.tar.bz2" \
+		tar jcf "${storedir}/snapshots/portage-${GNAP_STAMP}.tar.bz2" \
 			-C "${TEMPPRTDIR}" . \
-			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+			>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
 	fi
 fi
 
 # Stage3 phase
-if [[ "${STAGE3}" -eq 1 ]]; then
+if [[ "${GNAP_STAGE3}" -eq 1 ]]; then
 	gbegin "${G}[stage3]${N} stage (base system build)"
 
 	gmkdir "${storedir}/builds/${RELTYPE}"
-	cp "${STAGE3FILE}" "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
+	cp "${GNAP_STAGE3FILE}" "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
 
 	TEMPCONF="${TEMPDIR}/stage3.conf"
 	touch "${TEMPCONF}"
@@ -235,20 +241,20 @@
 ${DISTCCSPEC}
 subarch: ${SUBARCH}
 rel_type: ${RELTYPE}
-snapshot: ${STAMP}
-version_stamp: ${STAMP}
+snapshot: ${GNAP_STAMP}
+version_stamp: ${GNAP_STAMP}
 profile: ${PROFILE}
 source_subpath: ${RELTYPE}/seedstage
 portage_confdir: ${SPECDIR}/portage_confdir
 EOF
-	$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
-		>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+	$GNAP_CATALYST_BIN -c "${GNAP_CATALYST_CONF}" -f "${TEMPCONF}" \
+		>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 	gtest $? "[stage3] failed, ${SEELOGFILES}"
 	rm "${storedir}/builds/${RELTYPE}/seedstage.tar.bz2"
 fi
 
 # LIVECD-STAGE1 phase
-if [[ "${LIVECD1}" -eq 1 ]]; then
+if [[ "${GNAP_LIVECD1}" -eq 1 ]]; then
 	gbegin "${G}[livecd-stage1]${N} stage (GNAP-specific packages build)"
 	TEMPCONF="${TEMPDIR}/livecd-stage1.conf"
 	touch "${TEMPCONF}"
@@ -258,21 +264,21 @@
 ${DISTCCSPEC}
 subarch: ${SUBARCH}
 rel_type: ${RELTYPE}
-snapshot: ${STAMP}
-version_stamp: ${STAMP}
+snapshot: ${GNAP_STAMP}
+version_stamp: ${GNAP_STAMP}
 profile: ${PROFILE}
-source_subpath: ${RELTYPE}/stage3-${SUBARCH}-${STAMP}
+source_subpath: ${RELTYPE}/stage3-${SUBARCH}-${GNAP_STAMP}
 portage_confdir: ${SPECDIR}/portage_confdir
 EOF
 	cat "${SPECDIR}/packages.conf" >> "${TEMPCONF}"
 
-	$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
-		>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+	$GNAP_CATALYST_BIN -c "${GNAP_CATALYST_CONF}" -f "${TEMPCONF}" \
+		>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 	gtest $? "[livecd-stage1] failed, ${SEELOGFILES}"
 fi
 
 # LIVECD-STAGE2 phase
-if [[ "${LIVECD2}" -eq 1 ]]; then
+if [[ "${GNAP_LIVECD2}" -eq 1 ]]; then
 	gbegin "${G}[livecd-stage2]${N} stage (kernel and LiveCD builds)"
 	TEMPCONF="${TEMPDIR}/livecd-stage2.conf"
 	touch "${TEMPCONF}"
@@ -282,30 +288,30 @@
 ${DISTCCSPEC}
 subarch: ${SUBARCH}
 rel_type: ${RELTYPE}
-snapshot: ${STAMP}
-version_stamp: ${STAMP}
+snapshot: ${GNAP_STAMP}
+version_stamp: ${GNAP_STAMP}
 profile: ${PROFILE}
-source_subpath: ${RELTYPE}/livecd-stage1-${SUBARCH}-${STAMP}
+source_subpath: ${RELTYPE}/livecd-stage1-${SUBARCH}-${GNAP_STAMP}
 boot/kernel/gentoo/sources: ${KERNEL_SOURCES}
 boot/kernel/gentoo/config: ${SPECDIR}/kernel.config
-boot/kernel/gentoo/extraversion: GNAP-${GNAPVERSION}
-livecd/iso: gnap-${GNAPVERSION}-${STAMP}.iso
+boot/kernel/gentoo/extraversion: GNAP-${VERSION}
+livecd/iso: gnap-${VERSION}-${GNAP_STAMP}.iso
 livecd/fsscript: ${SPECDIR}/fsscript
 livecd/root_overlay: ${SPECDIR}/root_overlay
 EOF
 	cat "${SPECDIR}/livecd.conf" >> "${TEMPCONF}"
 
-	$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
-		>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+	$GNAP_CATALYST_BIN -c "${GNAP_CATALYST_CONF}" -f "${TEMPCONF}" \
+		>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 	gtest $? "[livecd-stage2] failed, ${SEELOGFILES}"
 fi
 
 # TARBALL phase
-if [[ "${TARBALL}" -eq 1 ]]; then
+if [[ "${GNAP_TARBALL}" -eq 1 ]]; then
 	gbegin "${G}[tarball]${N} phase (Creation of core and basefs components)"
-	test -e "gnap-${GNAPVERSION}-${STAMP}.iso"
-	gtest continued $? "No gnap-${GNAPVERSION}-${STAMP}.iso file to convert !"
-	test -d "${storedir}/tmp/gnap/livecd-stage1-${SUBARCH}-${STAMP}"
+	test -e "gnap-${VERSION}-${GNAP_STAMP}.iso"
+	gtest continued $? "No gnap-${VERSION}-${GNAP_STAMP}.iso file to convert !"
+	test -d "${storedir}/tmp/gnap/livecd-stage1-${SUBARCH}-${GNAP_STAMP}"
 	gtest $? 'Missing livecd-stage2 results'
 
 	gbegin '  Creating core component'
@@ -314,7 +320,7 @@
 	TEMPISODIR="${TEMPDIR}/iso"
 	gmkdir "${TEMPISODIR}"
 
-	mount -o loop "gnap-${GNAPVERSION}-${STAMP}.iso" ${TEMPMNTDIR} && \
+	mount -o loop "gnap-${VERSION}-${GNAP_STAMP}.iso" ${TEMPMNTDIR} && \
 		cp -r ${TEMPMNTDIR}/* ${TEMPISODIR}
 	gtest continued $? 'Failed to mount ISO and copy files'
 	umount "${TEMPMNTDIR}"
@@ -324,23 +330,23 @@
 	cp "${SPECDIR}/isolinux/syslinux.cfg" ${TEMPISODIR}/
 	cp "${SPECDIR}/isolinux/boot.msg" ${TEMPISODIR}/isolinux/
 	DATE=$(date --utc)
-	echo "GNAP-${GNAPVERSION}-${STAMP} built on ${DATE}" \
+	echo "GNAP-${VERSION}-${GNAP_STAMP} built on ${DATE}" \
 		>> "${TEMPISODIR}/isolinux/boot.msg"
 
-	tar cf "gnap-${GNAPVERSION}-${STAMP}.tar" -C "${TEMPISODIR}" .
+	tar cf "gnap-${VERSION}-${GNAP_STAMP}.tar" -C "${TEMPISODIR}" .
 	gtest $? 'Failed to create tarball'
-	rm "gnap-${GNAPVERSION}-${STAMP}.iso"
+	rm "gnap-${VERSION}-${GNAP_STAMP}.iso"
 
 	gbegin '  Creating basefs component'
-	tar jcf "gnap-basefs-${GNAPVERSION}-${STAMP}.tar.bz2" \
-		-C "${storedir}/tmp/gnap/livecd-stage2-${SUBARCH}-${STAMP}" .
+	tar jcf "gnap-basefs-${VERSION}-${GNAP_STAMP}.tar.bz2" \
+		-C "${storedir}/tmp/gnap/livecd-stage2-${SUBARCH}-${GNAP_STAMP}" .
 	gtest $? 'Unable to create basefs tarball'
 fi
 
 # EXTENSIONS phase
-if [[ "${MODULES}" -eq 1 ]]; then
+if [[ "${GNAP_MODULES}" -eq 1 ]]; then
 	gbegin "${G}[extensions]${N} stage start"
-	GRP_PREFIX="${storedir}/builds/${RELTYPE}/grp-${SUBARCH}-${STAMP}"
+	GRP_PREFIX="${storedir}/builds/${RELTYPE}/grp-${SUBARCH}-${GNAP_STAMP}"
 	SPECMODULE="${SPECDIR}/extensions.conf"
 	mod_list=$(grep '^extensions:' "${SPECMODULE}" 2>/dev/null);
 	mod_list="${mod_list/extensions:/}"
@@ -362,25 +368,25 @@
 ${DISTCCSPEC}
 subarch: ${SUBARCH}
 rel_type: ${RELTYPE}
-snapshot: ${STAMP}
-version_stamp: ${STAMP}
+snapshot: ${GNAP_STAMP}
+version_stamp: ${GNAP_STAMP}
 profile: ${PROFILE}
-source_subpath: ${RELTYPE}/stage3-${SUBARCH}-${STAMP}
+source_subpath: ${RELTYPE}/stage3-${SUBARCH}-${GNAP_STAMP}
 grp: ${mod_name}
 grp/use: ${mod_useflags}
 grp/${mod_name}/type: pkgset
 grp/${mod_name}/packages: ${mod_packlist}
 EOF
 
-		$CATALYST_BIN -c "${CATALYST_CONF}" -f "${TEMPCONF}" \
-			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+		$GNAP_CATALYST_BIN -c "${GNAP_CATALYST_CONF}" -f "${TEMPCONF}" \
+			>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 		gtest continued $? "Extension build failed, ${SEELOGFILES}"
 
 		TEMPMODULEDIR="${TEMPDIR}/module_${mod_name}"
 		gmkdir "${TEMPMODULEDIR}"
 		for pkg in $( ls ${GRP_PREFIX}/${mod_name}/All/*.tbz2 ); do
 			tar jxf $pkg -C "${TEMPMODULEDIR}" -p \
-				>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+				>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 		done
 		gtest continued $? 'Failed to unpack extension packages'
 
@@ -392,9 +398,9 @@
 		rm -rf ${mod_rmlist}
 		gtest continued $? 'Failed to apply extension cleanup instructions'
 
-		tar jcf "gnapext_${mod_name}-${STAMP}.tbz2" \
+		tar jcf "gnapext_${mod_name}-${GNAP_STAMP}.tbz2" \
 			-C "${TEMPMODULEDIR}" . \
-			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"
+			>> "${GNAP_LOGPREFIX}.out" 2>> "${GNAP_LOGPREFIX}.err"
 		gtest $? 'Failed to build extension file'
 	done
 fi
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup+split/tools/gnap_overlay gnap-2.0+cleanup+split+namespace/tools/gnap_overlay
--- gnap-2.0+cleanup+split/tools/gnap_overlay	2007-07-27 16:00:56.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace/tools/gnap_overlay	2007-07-27 16:00:02.000000000 +0300
@@ -1,17 +1,15 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAPLIBDIR='/usr/lib/gnap'
-source ${GNAPLIBDIR}/gnap_shared.sh
-echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
-
-IMG_SIZE=15
+GNAP_LIBDIR='/usr/lib/gnap'
+source ${GNAP_LIBDIR}/gnap_shared.sh
+echo "GNAP overlay tool ${NAME} ${VERSION}"
 
 usage() {
 	echo
     echo 'Usage:'
-    echo "  ${GNAPNAME} -i isoname -o overlay [ options ]"
-    echo "  ${GNAPNAME} -d hostdisk -r rootdev -o overlay [ options ]"
+    echo "  ${NAME} -i isoname -o overlay [ options ]"
+    echo "  ${NAME} -d hostdisk -r rootdev -o overlay [ options ]"
     echo
     echo 'Common options:'
     echo '  -o overlay    Overlay directory or tbz2 file'
@@ -36,7 +34,7 @@
     echo '  -S size       Size of image file in megabyte'
     echo '  The disk target options also apply, except -d.'
     echo
-    echo "Please use man ${GNAPNAME} for more details."
+    echo "Please use man ${NAME} for more details."
 }
 
 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
@@ -47,105 +45,106 @@
 gbegin 'Checking parameters'
 
 # Read options
-NOLOGO=0
-FORCEYES=0
-OUTPUT=''
-TYPE=''
-CREATE='n'
-TARGETROOT=''
-CACHE=''
-SERIAL=''
-BAUDRATE=''
+GNAP_NOLOGO=0
+GNAP_FORCEYES=0
+GNAP_OUTPUT=''
+GNAP_TYPE=''
+GNAP_CREATE='n'
+GNAP_IMG_SIZE=15
+GNAP_TARGETROOT=''
+GNAP_CACHE=''
+GNAP_SERIAL=''
+GNAP_BAUDRATE=''
 while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' option; do
 	case ${option} in
 		h ) usage
 			exit 0;;
-		g ) GNAPCORE="${OPTARG}";;
-		o ) OVERLAYS="${OVERLAYS} ${OPTARG}";;
-		c ) OVERLAYCONF="${OPTARG}";;
-		n ) NOLOGO=1;;
-		f ) FORCEYES=1;;
-		i ) OUTPUT="${OPTARG}"
-			TYPE='iso';;
-		d ) OUTPUT="${OPTARG}"
-			TYPE='disk';;
-		l ) OUTPUT="${OPTARG}"
-			TYPE='image'
-			CREATE='n';;
-		L ) OUTPUT="${OPTARG}"
-			TYPE='image'
-			CREATE='y';;
-		S ) IMG_SIZE="${OPTARG}";;
-		r ) TARGETROOT="${OPTARG}";;
-		m ) CACHE='docache ';;
-		s ) SERIAL="console=ttyS0,${OPTARG}n81"
-			BAUDRATE="${OPTARG}";;
+		g ) GNAP_CORE="${OPTARG}";;
+		o ) GNAP_OVERLAYS="${GNAP_OVERLAYS} ${OPTARG}";;
+		c ) GNAP_OVERLAY_CONF="${OPTARG}";;
+		n ) GNAP_NOLOGO=1;;
+		f ) GNAP_FORCEYES=1;;
+		i ) GNAP_OUTPUT="${OPTARG}"
+			GNAP_TYPE='iso';;
+		d ) GNAP_OUTPUT="${OPTARG}"
+			GNAP_TYPE='disk';;
+		l ) GNAP_OUTPUT="${OPTARG}"
+			GNAP_TYPE='image'
+			GNAP_CREATE='n';;
+		L ) GNAP_OUTPUT="${OPTARG}"
+			GNAP_TYPE='image'
+			GNAP_CREATE='y';;
+		S ) GNAP_IMG_SIZE="${OPTARG}";;
+		r ) GNAP_TARGETROOT="${OPTARG}";;
+		m ) GNAP_CACHE='docache ';;
+		s ) GNAP_SERIAL="console=ttyS0,${OPTARG}n81"
+			GNAP_BAUDRATE="${OPTARG}";;
 		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
 # Target type (-i or -d) is needed
-test -n "${TYPE}"
+test -n "${GNAP_TYPE}"
 gtest continued $? 'Please specify a target (-i or -d option)'
 
 # Core file is required
-test -f "${GNAPCORE}"
+test -f "${GNAP_CORE}"
 gtest continued $? 'Please specify a valid GNAP core file (-g option)'
 
-case "${TYPE}" in
+case "${GNAP_TYPE}" in
 	disk)
 		# if disk type, doublecheck everything is ok
-		PARENTDEV="${OUTPUT:0:$((${#OUTPUT}-1))}"
+		PARENTDEV="${GNAP_OUTPUT:0:$((${#GNAP_OUTPUT}-1))}"
 		test -b "${PARENTDEV}"
 		gtest continued $? "${PARENTDEV} device does not exist on this system"
-		test -b "${OUTPUT}"
-		gtest continued $? "${OUTPUT} partition does not exist on this system"
+		test -b "${GNAP_OUTPUT}"
+		gtest continued $? "${GNAP_OUTPUT} partition does not exist on this system"
 	;;
 	image)
-		if [[ "${CREATE}" != 'y' ]]; then
+		if [[ "${GNAP_CREATE}" != 'y' ]]; then
 			# Check whether image file exists
-			test -f "${OUTPUT}"
-			gtest continued $? "Image file ${OUTPUT} does not exist."
+			test -f "${GNAP_OUTPUT}"
+			gtest continued $? "Image file ${GNAP_OUTPUT} does not exist."
 		fi
 	;;
 esac
 
 # At least one overlay is required
-test -n "${OVERLAYS}${OVERLAYCONF}"
+test -n "${GNAP_OVERLAYS}${GNAP_OVERLAY_CONF}"
 gtest $? 'Please specify at least an overlay (-o) or config file (-c)'
 
 # Warning for disk type targets
-if [[ "${TYPE}" == 'disk' ]]; then
+if [[ "${GNAP_TYPE}" == 'disk' ]]; then
 	gwarn 'Warning : you have selected disk install'
-	gwarn "Make sure you are root or have full access to ${OUTPUT}"
+	gwarn "Make sure you are root or have full access to ${GNAP_OUTPUT}"
 	gwarn "${PARENTDEV} must have an MBR installed, run:"
-	gwarn "${W}dd if=${GNAPMBR} of=${PARENTDEV} bs=512 count=1${N} if needed"
-	gwarn "${OUTPUT} must contain an active partition:"
+	gwarn "${W}dd if=${GNAP_MBR} of=${PARENTDEV} bs=512 count=1${N} if needed"
+	gwarn "${GNAP_OUTPUT} must contain an active partition:"
 	gwarn " use ${W}fdisk ${PARENTDEV}${N} if needed"
-	gwarn "Current data on ${OUTPUT} will be ${B}destroyed${N}!"
+	gwarn "Current data on ${GNAP_OUTPUT} will be ${B}destroyed${N}!"
 	gconfirm 'Are you sure you want to continue ?'
 fi
 
 # Common actions
-gbegin "Expanding ${GNAPCORE} core"
+gbegin "Expanding ${GNAP_CORE} core"
 TEMPDIR=$(mktemp -d -t gnap_overlay.XXXXXX)
 gtest continued $? 'Failed to create temporary directory'
 TEMPCOREDIR="${TEMPDIR}/core"
 gmkdir "${TEMPCOREDIR}"
-tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}"
+tar x -C "${TEMPCOREDIR}" -f "${GNAP_CORE}"
 gtest $? 'Failed to extract core'
 
 gbegin 'Preparing overlay'
 TEMPOVERDIR="${TEMPDIR}/overlay"
 gmkdir "${TEMPOVERDIR}"
 
-if [[ -n "${BAUDRATE}" ]]; then
+if [[ -n "${GNAP_BAUDRATE}" ]]; then
 	gbegin 'Adding baudrate for serial console'
 	gmkdir -p "${TEMPOVERDIR}/etc/gnap"
-	echo -n "${BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
+	echo -n "${GNAP_BAUDRATE}" > "${TEMPOVERDIR}/etc/gnap/baudrate"
 	gtest $? 'Failed to create /etc/gnap/baudrate'
 fi
-for overlay in ${OVERLAYS} ; do
+for overlay in ${GNAP_OVERLAYS} ; do
 	if [[ -d "${overlay}" ]]; then
 		gbegin "Adding ${overlay} (directory overlay)"
 		cp -rp "${overlay}"/* "${TEMPOVERDIR}"
@@ -156,13 +155,13 @@
 		gtest $? "${overlay} is not a valid conflet file (tbz2 format)"
 	fi
 done
-if [[ -n "${OVERLAYCONF}" ]]; then
-	gbegin "Adding ${OVERLAYCONF} (overlay.conf file)"
+if [[ -n "${GNAP_OVERLAY_CONF}" ]]; then
+	gbegin "Adding ${GNAP_OVERLAY_CONF} (overlay.conf file)"
 	if [[ ! -d "${TEMPOVERDIR}/etc" ]]; then
 		gmkdir "${TEMPOVERDIR}/etc"
 	fi
-	cp "${OVERLAYCONF}" "${TEMPOVERDIR}/etc/overlay.conf"
-	gtest $? "Failed to copy ${OVERLAYCONF}"
+	cp "${GNAP_OVERLAY_CONF}" "${TEMPOVERDIR}/etc/overlay.conf"
+	gtest $? "Failed to copy ${GNAP_OVERLAY_CONF}"
 fi
 gbegin 'Creating overlay tarball'
 test -f "${TEMPOVERDIR}/etc/overlay.conf"
@@ -172,28 +171,28 @@
 gtest $? 'Failed to create overlay tarball'
 
 DATE=$(date --utc)
-if [[ "${NOLOGO}" -eq 1 ]]; then
+if [[ "${GNAP_NOLOGO}" -eq 1 ]]; then
 	echo "GNAP ${VERSION}" > "${TEMPCOREDIR}/isolinux/boot.msg"
 fi
-if [[ -n "${OVERLAYS}" ]]; then
-	echo "Overlaid with ${OVERLAYS} on ${DATE}" \
+if [[ -n "${GNAP_OVERLAYS}" ]]; then
+	echo "Overlaid with ${GNAP_OVERLAYS} on ${DATE}" \
 		>> "${TEMPCOREDIR}/isolinux/boot.msg"
 fi
 
 # Target specific actions
-if [[ "${TYPE}" == 'iso' ]]; then
-	if [[ -f "${OUTPUT}" ]]; then
-		gconfirm "File ${OUTPUT} already exists, overwrite?"
+if [[ "${GNAP_TYPE}" == 'iso' ]]; then
+	if [[ -f "${GNAP_OUTPUT}" ]]; then
+		gconfirm "File ${GNAP_OUTPUT} already exists, overwrite?"
 	fi
 	rm "${TEMPCOREDIR}/syslinux.cfg"
-	gbegin "Building ${OUTPUT} ISO file"
-	mkisofs -quiet -J -r -l -x "${TEMPCOREDIR}/.." -o "${OUTPUT}" \
+	gbegin "Building ${GNAP_OUTPUT} ISO file"
+	mkisofs -quiet -J -r -l -x "${TEMPCOREDIR}/.." -o "${GNAP_OUTPUT}" \
 		-b isolinux/isolinux.bin -c isolinux/boot.cat \
 		-no-emul-boot -boot-load-size 4 -boot-info-table "${TEMPCOREDIR}"
 	gtest $?
 
 else
-	if [[ "${TYPE}" == 'image' ]]; then
+	if [[ "${GNAP_TYPE}" == 'image' ]]; then
 		gbegin 'Looking for free loop device'
 		LOOP=''
 		for i in /dev/loop/?* /dev/loop?*; do
@@ -210,25 +209,25 @@
 
 		ginfo "Using loop device ${LOOP}"
 
-		if [[ "${CREATE}"  == y ]]; then
-			if [[ -f "${OUTPUT}" ]]; then
-				gconfirm "File ${OUTPUT} already exists, overwrite?"
+		if [[ "${GNAP_CREATE}"  == y ]]; then
+			if [[ -f "${GNAP_OUTPUT}" ]]; then
+				gconfirm "File ${GNAP_OUTPUT} already exists, overwrite?"
 			fi
 
 			gbegin 'Creating image file'
 			# 1048576 = 1 MiB
-			dd if=/dev/zero of="${OUTPUT}" bs=1048576 count="${IMG_SIZE}" \
+			dd if=/dev/zero of="${GNAP_OUTPUT}" bs=1048576 count="${GNAP_IMG_SIZE}" \
 				>/dev/null 2>&1
 			gtest $?
 
 			gbegin 'Creating partition table'
 			# Create one partition of the full size
-			echo '0;;6;*' | sfdisk -D -H 64 -S 32 "${OUTPUT}" >/dev/null 2>&1
+			echo '0;;6;*' | sfdisk -D -H 64 -S 32 "${GNAP_OUTPUT}" >/dev/null 2>&1
 			gtest $?
 		fi
 
 		gbegin 'Reading Cylinder/Heads/Sectors'
-		CHS=$(sfdisk -G "${OUTPUT}" 2>/dev/null)
+		CHS=$(sfdisk -G "${GNAP_OUTPUT}" 2>/dev/null)
 		gtest $?
 
 		set -- ${CHS/*:/}
@@ -241,22 +240,22 @@
 
 		ginfo "Offset is ${offset}"
 
-		gbegin "Mounting ${OUTPUT} to ${LOOP}"
-		losetup -o "${offset}" "${LOOP}" "${OUTPUT}"
+		gbegin "Mounting ${GNAP_OUTPUT} to ${LOOP}"
+		losetup -o "${offset}" "${LOOP}" "${GNAP_OUTPUT}"
 		gtest $?
 
-		ORIG_OUTPUT="${OUTPUT}"
-		OUTPUT="${LOOP}"
+		ORIG_OUTPUT="${GNAP_OUTPUT}"
+		GNAP_OUTPUT="${LOOP}"
 	fi
 
-	gbegin "Formatting ${OUTPUT}"
-	mkfs.msdos "${OUTPUT}" > /dev/null 2>&1
+	gbegin "Formatting ${GNAP_OUTPUT}"
+	mkfs.msdos "${GNAP_OUTPUT}" > /dev/null 2>&1
 	gtest $?
 
-	gbegin "Mounting ${OUTPUT}"
+	gbegin "Mounting ${GNAP_OUTPUT}"
 	TEMPMOUNTDIR="${TEMPDIR}/mount"
 	gmkdir "${TEMPMOUNTDIR}"
-	mount -t msdos "${OUTPUT}" "${TEMPMOUNTDIR}"
+	mount -t msdos "${GNAP_OUTPUT}" "${TEMPMOUNTDIR}"
 	gtest $?
 
 	gbegin 'Copying files'
@@ -268,31 +267,31 @@
 	cp ${TEMPCOREDIR}/overlay.tgz			${TEMPMOUNTDIR}/			&&\
 	cp ${TEMPCOREDIR}/image.squashfs		${TEMPMOUNTDIR}/image.sfs	&&\
 	sed -i \
-		"s:cdroot:cdroot=/dev/${TARGETROOT} ${CACHE}${SERIAL}:" \
+		"s:cdroot:cdroot=/dev/${GNAP_TARGETROOT} ${GNAP_CACHE}${GNAP_SERIAL}:" \
 		"${TEMPMOUNTDIR}/syslinux.cfg"
 	gtest $?
 
-	gbegin "Unmounting ${OUTPUT}"
+	gbegin "Unmounting ${GNAP_OUTPUT}"
 	umount "${TEMPMOUNTDIR}"
 	gtest $?
 
 	# Is autocleaned so maybe not useful
-	if [[ "${TYPE}" == 'image' ]]; then
+	if [[ "${GNAP_TYPE}" == 'image' ]]; then
 		losetup -d "${LOOP}"
 		LOOP=
 	fi
 
 	export MTOOLS_SKIP_CHECK=1
-	case "${TYPE}" in
+	case "${GNAP_TYPE}" in
 		disk)
 			gbegin 'Syslinuxing'
-			syslinux "${OUTPUT}"
+			syslinux "${GNAP_OUTPUT}"
 			gtest $?
 		;;
 		image)
 			gbegin 'Preparing disk for boot'
 			syslinux -o "${offset}" "${ORIG_OUTPUT}" && \
-			dd if="${GNAPMBR}" of="${ORIG_OUTPUT}" bs=512 count=1 \
+			dd if="${GNAP_MBR}" of="${ORIG_OUTPUT}" bs=512 count=1 \
 				conv=notrunc >/dev/null 2>&1
 			gtest $?
 		;;
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup+split/tools/gnap_remaster gnap-2.0+cleanup+split+namespace/tools/gnap_remaster
--- gnap-2.0+cleanup+split/tools/gnap_remaster	2007-07-27 16:10:54.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace/tools/gnap_remaster	2007-07-27 16:17:48.000000000 +0300
@@ -1,16 +1,16 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAPLIBDIR='/usr/lib/gnap'
-source ${GNAPLIBDIR}/gnap_shared.sh
-echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
+GNAP_LIBDIR='/usr/lib/gnap'
+source ${GNAP_LIBDIR}/gnap_shared.sh
+echo "GNAP remastering tool ${NAME} ${VERSION}"
 
-OUTPUT='mygnap-core.tar'
+GNAP_OUTPUT='mygnap-core.tar'
 
 usage() {
 	echo
 	echo 'Usage:'
-	echo "  ${GNAPNAME} [ options ]"
+	echo "  ${NAME} [ options ]"
 	echo
 	echo 'Options:'
 	echo '  -e extension    Extension to include in core file'
@@ -22,7 +22,7 @@
 	echo '  -d extdir       Directory where to find extensions'
 	echo '  -f              Force all answers to yes (dangerous!)'
 	echo
-	echo "Please use man ${GNAPNAME} for more details."
+	echo "Please use man ${NAME} for more details."
 }
 
 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
@@ -33,64 +33,64 @@
 gbegin 'Checking parameters'
 
 # Read options
-EXTENSIONS=''
-KERNEXT=''
-MODEXT=''
-GNAPBASEFS=''
-GNAPEXTDIR=''
-FORCEYES=0
+GNAP_EXTENSIONS=''
+GNAP_KERNEXT=''
+GNAP_MODEXT=''
+GNAP_BASEFS=''
+GNAP_EXTDIR=''
+GNAP_FORCEYES=0
 while getopts ':he:k:m:o:g:b:d:f' option; do
 	case ${option} in
 		h ) usage
 			exit 0;;
-		e ) EXTENSIONS="${EXTENSIONS} ${OPTARG}";;
-		k ) KERNEXT="${OPTARG}";;
-		m ) MODEXT="${OPTARG}";;
-		o ) OUTPUT="${OPTARG}";;
-		g ) GNAPCORE="${OPTARG}";;
-		b ) GNAPBASEFS="${OPTARG}";;
-		d ) GNAPEXTDIR="${OPTARG}";;
-		f ) FORCEYES=1;;
+		e ) GNAP_EXTENSIONS="${GNAP_EXTENSIONS} ${OPTARG}";;
+		k ) GNAP_KERNEXT="${OPTARG}";;
+		m ) GNAP_MODEXT="${OPTARG}";;
+		o ) GNAP_OUTPUT="${OPTARG}";;
+		g ) GNAP_CORE="${OPTARG}";;
+		b ) GNAP_BASEFS="${OPTARG}";;
+		d ) GNAP_EXTDIR="${OPTARG}";;
+		f ) GNAP_FORCEYES=1;;
 		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
 # Root is needed
 test "${EUID}" -eq 0
-gtest continued $? "You need to be root to run ${GNAPNAME}"
+gtest continued $? "You need to be root to run ${NAME}"
 
 # basefs file is required
-test -f "${GNAPBASEFS}"
+test -f "${GNAP_BASEFS}"
 gtest continued $? 'Please specify a valid GNAP basefs file (-b option)'
 
 # core file is required
-test -f "${GNAPCORE}"
+test -f "${GNAP_CORE}"
 gtest continued $? 'Please specify a valid GNAP core file (-g option)'
 
 # At least one operation is required
-test -n "${EXTENSIONS}" -o -n "${KERNEXT}" -o -n "${MODEXT}"
+test -n "${GNAP_EXTENSIONS}" -o -n "${GNAP_KERNEXT}" -o -n "${GNAP_MODEXT}"
 gtest $? 'Please specify at least one operation (-e, -k, -m) to perform'
 
 # Confirm tarball overwrite
-if [[ -e "${OUTPUT}" ]]; then
-	gconfirm "${OUTPUT} already exists, overwrite"
+if [[ -e "${GNAP_OUTPUT}" ]]; then
+	gconfirm "${GNAP_OUTPUT} already exists, overwrite"
 fi
 
 # Preparing new FS
-gbegin "Unpacking ${GNAPBASEFS} basefs"
+gbegin "Unpacking ${GNAP_BASEFS} basefs"
 TEMPDIR=$(mktemp -d -t gnap_remaster.XXXXXX)
 gtest continued $? 'Failed to create temporary directory'
 TEMPOVERDIR="${TEMPDIR}/basefs"
 gmkdir "${TEMPOVERDIR}"
 
-tar jx -C "${TEMPOVERDIR}" -f "${GNAPBASEFS}"
+tar jx -C "${TEMPOVERDIR}" -f "${GNAP_BASEFS}"
 gtest $? 'Failed to unpack basefs'
 
-for overlay in ${EXTENSIONS} ; do
+for overlay in ${GNAP_EXTENSIONS} ; do
 	gbegin "Adding ${overlay} extension"
-	test -f "${GNAPEXTDIR}/gnapext_${overlay}.tbz2"
-	gtest continued $? "${GNAPEXTDIR}/gnapext_${overlay}.tbz2 does not exist"
-	tar jxf "${GNAPEXTDIR}/gnapext_${overlay}.tbz2" -C "${TEMPOVERDIR}"
+	test -f "${GNAP_EXTDIR}/gnapext_${overlay}.tbz2"
+	gtest continued $? "${GNAP_EXTDIR}/gnapext_${overlay}.tbz2 does not exist"
+	tar jxf "${GNAP_EXTDIR}/gnapext_${overlay}.tbz2" -C "${TEMPOVERDIR}"
 	gtest $? "${overlay} is not a valid extension (tbz2 format)"
 done
 
@@ -99,31 +99,31 @@
 TEMPCOREDIR="${TEMPDIR}/core"
 gmkdir "${TEMPCOREDIR}"
 
-tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}" --exclude image.squashfs
+tar x -C "${TEMPCOREDIR}" -f "${GNAP_CORE}" --exclude image.squashfs
 gtest $? 'Failed to extract core'
 
-if [[ -f "${KERNEXT}" ]]; then
-	gbegin "Replacing kernel and initrd using ${KERNEXT}"
+if [[ -f "${GNAP_KERNEXT}" ]]; then
+	gbegin "Replacing kernel and initrd using ${GNAP_KERNEXT}"
 	TEMPKERNDIR="${TEMPDIR}/kernel"
 	gmkdir "${TEMPKERNDIR}"
 
-	tar jx -C "${TEMPKERNDIR}" -f "${KERNEXT}"
+	tar jx -C "${TEMPKERNDIR}" -f "${GNAP_KERNEXT}"
 	gtest continued $? 'Failed to extract kernpackage'
 	cp ${TEMPKERNDIR}/kernel* "${TEMPCOREDIR}/isolinux/gentoo" && \
 		cp ${TEMPKERNDIR}/initr* "${TEMPCOREDIR}/isolinux/gentoo.igz"
 	gtest $? 'Failed to copy kernel and initrd'
 
-elif [[ -n "${KERNEXT}" ]]; then
-	gwarn "${KERNEXT} does not exist, ignoring..."
+elif [[ -n "${GNAP_KERNEXT}" ]]; then
+	gwarn "${GNAP_KERNEXT} does not exist, ignoring..."
 fi
 
-if [[ -f "${MODEXT}" ]]; then
-	gbegin "Replacing modules using ${MODEXT}"
+if [[ -f "${GNAP_MODEXT}" ]]; then
+	gbegin "Replacing modules using ${GNAP_MODEXT}"
 	rm -rf "${TEMPOVERDIR}/lib/modules" &&
-		tar jx -C "${TEMPOVERDIR}" -f "${MODEXT}"
+		tar jx -C "${TEMPOVERDIR}" -f "${GNAP_MODEXT}"
 	gtest $? 'Failed to replace modules'
-elif [[ -n "${MODEXT}" ]]; then
-	gwarn "${MODEXT} does not exist, ignoring..."
+elif [[ -n "${GNAP_MODEXT}" ]]; then
+	gwarn "${GNAP_MODEXT} does not exist, ignoring..."
 fi
 
 gbegin 'Creating new squashfs filesystem'
@@ -131,8 +131,8 @@
 	> /dev/null 2>/dev/null
 gtest $? 'Failed to create squashfs'
 
-gbegin "Creating ${OUTPUT} core file"
-tar cf "${OUTPUT}" -C "${TEMPCOREDIR}" .
+gbegin "Creating ${GNAP_OUTPUT} core file"
+tar cf "${GNAP_OUTPUT}" -C "${TEMPCOREDIR}" .
 gtest $? 'Failed to create new core tarball'
 
 # Successful finish
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup+split/tools/gnap_shared.sh gnap-2.0+cleanup+split+namespace/tools/gnap_shared.sh
--- gnap-2.0+cleanup+split/tools/gnap_shared.sh	2007-08-02 15:54:46.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace/tools/gnap_shared.sh	2007-08-02 15:51:30.000000000 +0300
@@ -1,22 +1,22 @@
-GNAPNAME=$(basename "$0")
+NAME=$(basename "$0")
 
-case ${GNAPNAME} in
+case ${NAME} in
 	gnap_make )     GNAP_PRODUCT="Build";;
  	gnap_overlay )  GNAP_PRODUCT="Overlay";;
  	gnap_remaster ) GNAP_PRODUCT="Remaster";;
  	* )             GNAP_PRODUCT="Something";;
 esac
-STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
-SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
-SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
-GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
-GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"
-GNAPEXTDIR="${GNAPLIBDIR}/extensions"
-GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"
+GNAP_STAGE3FILE="${GNAP_LIBDIR}/gnap-stage3seed.tar.bz2"
+GNAP_SNAPSHOTFILE="${GNAP_LIBDIR}/gnap-portagesnapshot.tar.bz2"
+GNAP_SPECS="${GNAP_LIBDIR}/gnap-specs.tar.bz2"
+GNAP_CORE="${GNAP_LIBDIR}/gnap-core.tar"
+GNAP_MBR="${GNAP_LIBDIR}/mbr/mbr.bin"
+GNAP_EXTDIR="${GNAP_LIBDIR}/extensions"
+GNAP_BASEFS="${GNAP_LIBDIR}/gnap-basefs.tar.bz2"
 
+GNAP_FORCEYES=0
 TEMPDIR=''
 LOOP=''
-FORCEYES=0
 
 G=$'\e[32;01m'
 B=$'\e[31;01m'
@@ -40,7 +40,7 @@
 }
 
 gconfirm() {
-	if [[ "${FORCEYES}" -eq 1 ]]; then
+	if [[ "${GNAP_FORCEYES}" -eq 1 ]]; then
 		gwarn "${*} forced to yes"
 	else
 		read -ep " ${W}*${N} ${*} [N]: " answer
@@ -79,7 +79,7 @@
 		if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
 			cleanup
 		fi
-		echo " ${GNAP_PRODUCT} failed, try ${GNAPNAME} -h for more help"
+		echo " ${GNAP_PRODUCT} failed, try ${NAME} -h for more help"
 		exit 1
 	fi
 }

[-- Attachment #5: 04-gnap-environment.patch --]
[-- Type: text/x-patch, Size: 10051 bytes --]

diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup+split+namespace/src/gnap_make gnap-2.0+cleanup+split+namespace+environment/src/gnap_make
--- gnap-2.0+cleanup+split+namespace/src/gnap_make	2007-08-02 15:50:45.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace+environment/src/gnap_make	2007-08-02 15:46:54.000000000 +0300
@@ -1,7 +1,7 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAP_LIBDIR='/usr/lib/gnap'
+GNAP_LIBDIR=${GNAP_LIBDIR:-'/usr/lib/gnap'}
 source ${GNAP_LIBDIR}/gnap_shared.sh
 echo "GNAP Core Building tool ${NAME} version ${VERSION}"
 
@@ -25,65 +25,31 @@
 	exit 0
 fi
 
-gbegin 'Checking parameters'
-
 # Catalyst executable and config file
-GNAP_CATALYST_BIN="/usr/bin/catalyst"
-GNAP_CATALYST_CONF="/etc/catalyst/catalyst.conf"
+GNAP_CATALYST_BIN=${GNAP_CATALYST_BIN:-"/usr/bin/catalyst"}
+GNAP_CATALYST_CONF=${GNAP_CATALYST_CONF:-"/etc/catalyst/catalyst.conf"}
 
-# Read options
-GNAP_STAGE3=0
-GNAP_LIVECD1=0
-GNAP_LIVECD2=0
-GNAP_TARBALL=0
-GNAP_MODULES=0
-GNAP_STAMP=$(date +%Y%m%d)
-NOTARGET=1
-NEEDS_SNAPSHOT=0
+# Default options
+GNAP_STAMP=${GNAP_STAMP:-$(date +%Y%m%d)}
+
+# Read options (phase 1)
+gbegin 'Checking parameters'
+
+OPTIND=0
 while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
 	case ${option} in
-		h )
+		h ) 
+			gtest
 			usage
 			exit 0;;
-		s ) GNAP_STAGE3FILE="${OPTARG}";;
-		p ) GNAP_SNAPSHOTFILE="${OPTARG}";;
-		o ) GNAP_PORTAGE_OVERLAYS="${GNAP_PORTAGE_OVERLAYS} ${OPTARG}";;
-		v ) GNAP_STAMP="${OPTARG}";;
-		t )
-			case "${OPTARG}" in
-				all )
-					GNAP_STAGE3=1
-					GNAP_LIVECD1=1
-					GNAP_LIVECD2=1
-					GNAP_TARBALL=1
-					GNAP_MODULES=1
-					NEEDS_SNAPSHOT=1;;
-				stage3 )
-					GNAP_STAGE3=1
-					NEEDS_SNAPSHOT=1;;
-				livecd-stage1 )
-					GNAP_LIVECD1=1
-					NEEDS_SNAPSHOT=1;;
-				livecd-stage2 )
-					GNAP_LIVECD2=1
-					NEEDS_SNAPSHOT=1;;
-				tarball )
-					GNAP_TARBALL=1;;
-				extensions )
-					GNAP_MODULES=1
-					NEEDS_SNAPSHOT=1;;
-				* ) gtest 1 'Specified stage is unknown!';;
-			esac
-			NOTARGET=0;;
-		f ) GNAP_FORCEYES=1;;
-		l ) GNAP_LOGPREFIX="${OPTARG}";;
-		c ) GNAP_CATALYST_CONF="${OPTARG}";;
 		e ) GNAP_SPECS="${OPTARG}";;
+		s|p|o|v|t|f|l|c ) :;;
 		* ) gtest 1 'Specified options are incomplete or unknown!';;
 	esac
 done
 
 # Root is needed
+# * non-root can only use "gnap_make -h"
 test "${EUID}" -eq 0
 gtest continued $? "You need to be root to run ${NAME}"
 
@@ -113,15 +79,71 @@
 	DISTCCSPEC="distcc_hosts: ${DISTCC_HOSTS}"
 fi
 
+
+# Read options (phase 2)
+OPTIND=0
+while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
+	case ${option} in
+		c ) GNAP_CATALYST_CONF="${OPTARG}";;
+		s|p|o|v|t|f|l|e|h ) :;;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
+	esac
+done
+
 # catalyst.conf file
 test -f "${GNAP_CATALYST_CONF}"
 gtest continued $? "${GNAP_CATALYST_CONF} file not found!"
 source "${GNAP_CATALYST_CONF}"
 
+# Read options (phase 3)
+OPTIND=0
+while getopts ':hs:p:m:o:v:t:fl:c:e:' option; do
+	case ${option} in
+		s ) GNAP_STAGE3FILE="${OPTARG}";;
+		p ) GNAP_SNAPSHOTFILE="${OPTARG}";;
+		o ) GNAP_PORTAGE_OVERLAYS="${GNAP_PORTAGE_OVERLAYS} ${OPTARG}";;
+		v ) GNAP_STAMP="${OPTARG}";;
+		t )
+			case "${OPTARG}" in
+				all )
+					GNAP_STAGE3=1
+					GNAP_LIVECD1=1
+					GNAP_LIVECD2=1
+					GNAP_TARBALL=1
+					GNAP_MODULES=1;;
+				stage3 ) GNAP_STAGE3=1;;
+				livecd-stage1 ) GNAP_LIVECD1=1;;
+				livecd-stage2 ) GNAP_LIVECD2=1;;
+				tarball ) GNAP_TARBALL=1;;
+				extensions ) GNAP_MODULES=1;;
+				* ) gtest 1 'Specified stage is unknown!';;
+			esac;;
+		f ) GNAP_FORCEYES=1;;
+		l ) GNAP_LOGPREFIX="${OPTARG}";;
+		c|e|h ) :;;
+		* ) gtest 1 'Specified options are incomplete or unknown!';;
+	esac
+done
+
 # At least one target is needed
-test "${NOTARGET}" -eq 0
-gtest continued $? \
+test "${GNAP_STAGE3}" -eq 0 &&
+test "${GNAP_LIVECD1}" -eq 0 &&
+test "${GNAP_LIVECD2}" -eq 0 &&
+test "${GNAP_TARBALL}" -eq 0 &&
+test "${GNAP_MODULES}" -eq 0
+if [[ $? -eq 0 ]]; then
+	gtest continued 1 \
 	'No target specified. You should provide at least one -t option.'
+fi
+
+NEEDS_SNAPSHOT=0
+test "${GNAP_STAGE3}" -eq 1 ||
+test "${GNAP_LIVECD1}" -eq 1 ||
+test "${GNAP_LIVECD2}" -eq 1 ||
+test "${GNAP_MODULES}" -eq 1
+if [[ $? -eq 0 ]]; then
+	NEEDS_SNAPSHOT=1
+fi
 
 # storedir must exist
 gmkdir "${storedir}"
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup+split+namespace/tools/gnap_overlay gnap-2.0+cleanup+split+namespace+environment/tools/gnap_overlay
--- gnap-2.0+cleanup+split+namespace/tools/gnap_overlay	2007-07-27 16:00:02.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace+environment/tools/gnap_overlay	2007-07-31 23:22:33.000000000 +0300
@@ -1,7 +1,7 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAP_LIBDIR='/usr/lib/gnap'
+GNAP_LIBDIR=${GNAP_LIBDIR:-'/usr/lib/gnap'}
 source ${GNAP_LIBDIR}/gnap_shared.sh
 echo "GNAP overlay tool ${NAME} ${VERSION}"
 
@@ -42,19 +42,14 @@
 	exit 0
 fi
 
-gbegin 'Checking parameters'
+# Default settings
+GNAP_NOLOGO=${GNAP_NOLOGO:-0}
+GNAP_CREATE=${GNAP_CREATE:-'n'}
+GNAP_IMG_SIZE=${GNAP_IMG_SIZE:-15}
 
 # Read options
-GNAP_NOLOGO=0
-GNAP_FORCEYES=0
-GNAP_OUTPUT=''
-GNAP_TYPE=''
-GNAP_CREATE='n'
-GNAP_IMG_SIZE=15
-GNAP_TARGETROOT=''
-GNAP_CACHE=''
-GNAP_SERIAL=''
-GNAP_BAUDRATE=''
+gbegin 'Checking parameters'
+
 while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' option; do
 	case ${option} in
 		h ) usage
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup+split+namespace/tools/gnap_remaster gnap-2.0+cleanup+split+namespace+environment/tools/gnap_remaster
--- gnap-2.0+cleanup+split+namespace/tools/gnap_remaster	2007-07-27 16:17:48.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace+environment/tools/gnap_remaster	2007-07-31 23:29:03.000000000 +0300
@@ -1,12 +1,10 @@
 #!/bin/bash
 VERSION='2.0'
 
-GNAP_LIBDIR='/usr/lib/gnap'
+GNAP_LIBDIR=${GNAP_LIBDIR:-'/usr/lib/gnap'}
 source ${GNAP_LIBDIR}/gnap_shared.sh
 echo "GNAP remastering tool ${NAME} ${VERSION}"
 
-GNAP_OUTPUT='mygnap-core.tar'
-
 usage() {
 	echo
 	echo 'Usage:'
@@ -33,12 +31,8 @@
 gbegin 'Checking parameters'
 
 # Read options
-GNAP_EXTENSIONS=''
-GNAP_KERNEXT=''
-GNAP_MODEXT=''
-GNAP_BASEFS=''
-GNAP_EXTDIR=''
-GNAP_FORCEYES=0
+GNAP_OUTPUT=${GNAP_OUTPUT:-'mygnap-core.tar'}
+
 while getopts ':he:k:m:o:g:b:d:f' option; do
 	case ${option} in
 		h ) usage
diff -ur --exclude .svn --exclude upload.sh --exclude diff.sh gnap-2.0+cleanup+split+namespace/tools/gnap_shared.sh gnap-2.0+cleanup+split+namespace+environment/tools/gnap_shared.sh
--- gnap-2.0+cleanup+split+namespace/tools/gnap_shared.sh	2007-08-02 15:51:30.000000000 +0300
+++ gnap-2.0+cleanup+split+namespace+environment/tools/gnap_shared.sh	2007-08-02 15:46:44.000000000 +0300
@@ -6,34 +6,44 @@
  	gnap_remaster ) GNAP_PRODUCT="Remaster";;
  	* )             GNAP_PRODUCT="Something";;
 esac
-GNAP_STAGE3FILE="${GNAP_LIBDIR}/gnap-stage3seed.tar.bz2"
-GNAP_SNAPSHOTFILE="${GNAP_LIBDIR}/gnap-portagesnapshot.tar.bz2"
-GNAP_SPECS="${GNAP_LIBDIR}/gnap-specs.tar.bz2"
-GNAP_CORE="${GNAP_LIBDIR}/gnap-core.tar"
-GNAP_MBR="${GNAP_LIBDIR}/mbr/mbr.bin"
-GNAP_EXTDIR="${GNAP_LIBDIR}/extensions"
-GNAP_BASEFS="${GNAP_LIBDIR}/gnap-basefs.tar.bz2"
 
-GNAP_FORCEYES=0
+GNAP_STAGE3FILE=${GNAP_STAGE3FILE:-"${GNAP_LIBDIR}/gnap-stage3seed.tar.bz2"}
+GNAP_SNAPSHOTFILE=${GNAP_SNAPSHOTFILE:-"${GNAP_LIBDIR}/gnap-portagesnapshot.tar.bz2"}
+GNAP_SPECS=${GNAP_SPECS:-"${GNAP_LIBDIR}/gnap-specs.tar.bz2"}
+GNAP_CORE=${GNAP_CORE:-"${GNAP_LIBDIR}/gnap-core.tar"}
+GNAP_MBR=${GNAP_MBR:-"${GNAP_LIBDIR}/mbr/mbr.bin"}
+GNAP_EXTDIR=${GNAP_EXTDIR:-"${GNAP_LIBDIR}/extensions"}
+GNAP_BASEFS=${GNAP_BASEFS:-"${GNAP_LIBDIR}/gnap-basefs.tar.bz2"}
+
+GNAP_FORCEYES=${GNAP_FORCEYES:-0}
+
+#CONTINUED=0
 TEMPDIR=''
 LOOP=''
 
-G=$'\e[32;01m'
-B=$'\e[31;01m'
-N=$'\e[0m'
-W=$'\e[33;01m'
-K=$'\e[34;01m'
-C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]"
-E=$'\e['${C}'G'
+G=$'\e[32;01m' # green
+B=$'\e[31;01m' # red
+N=$'\e[0m'     # neutral
+W=$'\e[33;01m' # yellow
+K=$'\e[34;01m' # blue
+C="$[$(set -- $(stty size 2>/dev/null); echo ${2}) - 7]" # end of line helper
+E=$'\e['${C}'G' # end of line
+
+ginfo() {
+	echo -e " ${G}*${N} ${*}"
+}
 
 gwarn() {
 	echo -e " ${W}*${N} ${*}"
 }
 
-ginfo() {
-	echo -e " ${G}*${N} ${*}"
+gdie() {
+	echo -e " ${B}*${N} ${*}"
+	cleanup
+	exit 1
 }
 
+
 gmkdir() {
 	mkdir -p "$1"
 	gtest continued $? "Failed to create \"$1\"."
@@ -44,29 +54,31 @@
 		gwarn "${*} forced to yes"
 	else
 		read -ep " ${W}*${N} ${*} [N]: " answer
-		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
-				cleanup
-			fi
-			echo '${GNAP_PRODUCT} aborted!'
-			exit 2
-		fi
+		[[ "${answer}" != 'y' && "${answer}" != 'Y' ]] && \
+			gdie "${GNAP_PRODUCT} aborted!"
 	fi
 }
 
 gbegin() {
+#	[[ "${CONTINUED}" -eq 1 ]] && gdie "BUG triggered by gbegin()"
+
 	echo -ne " ${G}*${N} ${*}..."
+#	CONTINUED=1
 }
 
 gtest() {
-	continued=0
+#	# TODO: Remove this after removing all "gtest continued"
+#	if [[ "${#}" -gt 0 && "${1}" == 'continued' ]]; then
+#		shift
+#	fi
+	CONTINUED=0
 	if [[ "${#}" -gt 0 && "${1}" == 'continued' ]]; then
+		CONTINUED=1
 		shift
-		continued=1
 	fi
 
 	if [[ "${#}" -eq 0 || "${1}" -eq 0 ]]; then
-		if [[ "${continued}" -eq 0 ]]; then
+		if [[ "${CONTINUED}" -eq 0 ]]; then
 			echo -e "${E}  ${K}[ ${G}ok${K} ]${N}"
 		fi
 	else
@@ -76,11 +88,7 @@
 			echo -en " ${B}*${N} ${*}"
 			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
 		fi
-		if [[ -n "${TEMPDIR}" || -n "${LOOP}" ]]; then
-			cleanup
-		fi
-		echo " ${GNAP_PRODUCT} failed, try ${NAME} -h for more help"
-		exit 1
+		gdie "${GNAP_PRODUCT} failed, try man ${NAME} for more help"
 	fi
 }
 
@@ -90,13 +98,10 @@
 		umount "${LOOP}" && losetup -d "${LOOP}"
 		gtest $? "Failed to unmount ${LOOP}"
 	fi
-	gbegin 'Cleaning temporary directories'
 	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
-		rm -rf "${DIRTOREMOVE}"
+		gbegin 'Cleaning temporary directories'
+		rm -rf "${TEMPDIR}"
 		gtest $? "Failed to remove ${DIRTOREMOVE}"
-	else
-		gtest 0
+		TEMPDIR=''
 	fi
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-08-03 14:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
2007-08-03 13:26 ` [gnap-dev] [PATCH 1/4] GNAP cleanup Philipp Riegger
2007-08-03 13:32 ` [gnap-dev] [PATCH 2/4] GNAP split Philipp Riegger
2007-08-03 13:37 ` [gnap-dev] [PATCH 3/4] GNAP namespace Philipp Riegger
2007-08-03 13:53 ` [gnap-dev] [PATCH 4/4] GNAP environment Philipp Riegger
2007-08-03 13:57 ` [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
2007-08-03 14:01 ` Philipp Riegger
2007-08-03 14:02 ` Philipp Riegger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox