public inbox for gnap-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gnap-dev] Some patches for gnap
@ 2007-07-05 12:53 Philipp Riegger
  2007-07-05 13:03 ` [gnap-dev] 01-split-gnap_make.patch Philipp Riegger
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 12:53 UTC (permalink / raw
  To: gnap-dev

Hi!

I wanted to send the patches for gnap i made so far. I don't know what i
screwed up, but somehow they do not apply cleanly. I send them anyway for
review, if anybody wants i can send my current gnap_* scripts or recreate
working patches.

I will send the patcehs as replies to this email (since they are mostly
for review).

01-split-gnap_make.patch
02-split-gnap_overlay.patch
03-split-gnap_remaster.patch

Theese first 3 patches take the common stuff (functions, constants) from
the gnap_* scripts and put it into gnap_shared.sh

Note:
1) There are 2 gnap_shared.sh so far, one in the src and one in the toos
directory of the gnap svn tree. This should maybe be changed...
2) The gnap_* scripts do 'source "gnap_shared.sh"', which is probably not
good. In which directory will we put gnap_shared.sh?

04-feature-gnap_make-T.patch
05-festure-gnap_overlay-T.patch
06-feature-gnap_remaster-T.patch
07-split-make_tempdir.patch

After i created the first patch (with which it is possible to specify a
temp directory for gnap_make) i did the same for the other scripts and put
the logic in gnap_shared.sh finally. For the moment this is to prevent
using too small temp directories, later i want to create an option to
prevent deleting special files that they can be used after a gnap run. I
already talked about this.

08-namespace-gnap_shared.patch

This cleanes up the namespace, all variables that are used as input
parameters in gnap_shared.sh are prefixed with GNAP_ to get a clean usage
of the namespace. More to that later.

09-cleanup-gnap_make.patch

Some small fixes for gnap_make.


Ok, so far, so good. What's next?

1) Configuring gnap

At the moment configuring gnap_make (at which i concentrate so far) is
quite a mess. We have default parameters (in gnap_shared.sh), we have
catalyst.conf and commons.conf which we simply source, we have command
line options. At the moment this means the following:

Default options are set first, then they are overwritten by command line
options, which are overwritten by common.conf, ehich are overwritten by
catalyst.conf.

This is not really clean. For example, we use CATALYST_TEMP_DIR in
common.conf, catalyst uses store_dir in catalyst.conf. This is redundant
and does not make it clean. The default common.conf also defines
CATALYST_CONF (which might be broken because i renamed it, i have to
check), but that means that the command line option for specifying
catalyst.conf does not work if this is not commented out.

So... do we want to change this? I would like something like:

We can use variables from the environment. This will only be valid for
GNAP_* variables, so we have a clear namespace and it enables people to
set default variables. I'm not sure, how much this will be needed/used,
but it sounds like an interesting feature. The catalyst.conf is only used
for catalyst configuration (interaction between gnap and catalyst),
therefore it does never make sense to overwrite information given there.

Default options < environment < common.conf < command line options.

This would be my prefered way of configuring gnap, where variables from
sources more right overwrite variables from sources more left.

2) gnap_make feature: pretend

I'd like a --pretend feature for gnap_make which lets it just create the
configuration files for catalyst and the source files (portage tree, from
tree snapsht and overlays). This might be useful for test runs,
development and usage of catalyst features gnap does not support. This
could be implemented by simply overwriting CATALYST_BIN with "echo
$CATALYSY_BIN", if 1) from above is clear.

3) gnap_make feature: improved overlay handling

The overlay handling of gnap_make is some kind of bug, i think. If you
don't take care, Manifests are broken. Therefore i want to change it that
packages (directories in which ebuilds are) are first deleted from the
tree and metadata/cache if they exist, before new ones from overlays are
added. This should be easy to understand, since people usually don't need
stuff from the tree anymore if they use an overlay for a specific package.

4) some small stuff

At the moment, if there is a choice (Overwrite/Append, Yes/No) only one
possibility is checked and the other is assumed, if the one is not given.
I'd like to change this to something like "It is asked in a loop until a
valid option is given."

There is a function gwarn, writes to stderr. It is used in some places
where ginfo would make more sence, if it would exist. I'd like to
implement and use this.



That's all i wanted to say about the gnap_scripts at the moment.

Philipp
-- 
gnap-dev@gentoo.org mailing list



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

* [gnap-dev] 01-split-gnap_make.patch
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
@ 2007-07-05 13:03 ` Philipp Riegger
  2007-07-05 13:05 ` [gnap-dev] 03-split-gnap_remaster.patch Philipp Riegger
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 13:03 UTC (permalink / raw
  To: gnap-dev

Index: tools/gnap_shared.sh
===================================================================
--- tools/gnap_shared.sh	(revision 0)
+++ tools/gnap_shared.sh	(revision 0)
@@ -0,0 +1,79 @@
+GNAPNAME=$(basename "$0")
+
+case ${GNAPNAME} in
+	gnap_make ) GNAPPRODUCT="Build";;
+	* )         GNAPPRODUCT="Something";;
+esac
+
+GNAPLIBDIR='/usr/lib/gnap'
+STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
+SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
+SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
+
+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} ${*}"
+}
+
+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 "${GNAPPRODUCT} 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 "${GNAPPRODUCT} failed, try ${GNAPNAME} -h for more help"
+		exit 1
+	fi
+}
+
+cleanup() {
+	gbegin 'Cleaning temporary directories'
+	if [[ -d "${TEMPDIR}" ]]; then
+		DIRTOREMOVE="${TEMPDIR}"
+		TEMPDIR=''
+		rm -rf "${DIRTOREMOVE}"
+		gtest $? "Failed to remove ${DIRTOREMOVE}"
+	else
+		gtest 0
+	fi
+}
Index: src/gnap_make
===================================================================
--- src/gnap_make	(revision 52)
+++ src/gnap_make	(working copy)
@@ -1,70 +1,9 @@
 #!/bin/bash
 GNAPVERSION='2.0'

-GNAPNAME=$(basename "$0")
+source "gnap_shared.sh"
 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} ${*}"
-}
-
-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
-}
-
 usage() {
 	echo 'Options:'
 	echo '    -t stage             Build stage to execute (or "all")'
@@ -80,18 +19,6 @@
 	echo "Please 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
Index: src/gnap_shared.sh
===================================================================
--- src/gnap_shared.sh	(revision 0)
+++ src/gnap_shared.sh	(revision 0)
@@ -0,0 +1,79 @@
+GNAPNAME=$(basename "$0")
+
+case ${GNAPNAME} in
+	gnap_make ) GNAPPRODUCT="Build";;
+	* )         GNAPPRODUCT="Something";;
+esac
+
+GNAPLIBDIR='/usr/lib/gnap'
+STAGE3FILE="${GNAPLIBDIR}/gnap-stage3seed.tar.bz2"
+SNAPSHOTFILE="${GNAPLIBDIR}/gnap-portagesnapshot.tar.bz2"
+SPECS="${GNAPLIBDIR}/gnap-specs.tar.bz2"
+
+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} ${*}"
+}
+
+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 "${GNAPPRODUCT} 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 "${GNAPPRODUCT} failed, try ${GNAPNAME} -h for more help"
+		exit 1
+	fi
+}
+
+cleanup() {
+	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] 13+ messages in thread

* [gnap-dev] 03-split-gnap_remaster.patch
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
  2007-07-05 13:03 ` [gnap-dev] 01-split-gnap_make.patch Philipp Riegger
@ 2007-07-05 13:05 ` Philipp Riegger
  2007-07-05 13:06 ` [gnap-dev] 04-feature-gnap_make-T.patch Philipp Riegger
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 13:05 UTC (permalink / raw
  To: gnap-dev

Index: tools/gnap_shared.sh
===================================================================
--- tools/gnap_shared.sh	(revision 54)
+++ tools/gnap_shared.sh	(working copy)
@@ -1,9 +1,10 @@
 GNAPNAME=$(basename "$0")

 case ${GNAPNAME} in
-	gnap_make )    GNAPPRODUCT="Build";;
-	gnap_overlay ) GNAPPRODUCT="Overlay";;
-	* )            GNAPPRODUCT="Something";;
+	gnap_make )     GNAPPRODUCT="Build";;
+	gnap_overlay )  GNAPPRODUCT="Overlay";;
+	gnap_remaster ) GNAPPRODUCT="Remaster";;
+	* )             GNAPPRODUCT="Something";;
 esac

 GNAPLIBDIR='/usr/lib/gnap'
@@ -12,6 +13,8 @@
 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"

 LOOP=''

Index: tools/gnap_remaster
===================================================================
--- tools/gnap_remaster	(revision 52)
+++ tools/gnap_remaster	(working copy)
@@ -1,72 +1,11 @@
 #!/bin/bash
 VERSION='2.0'

-GNAPNAME=$(basename "$0")
+source "gnap_shared.sh"
 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} ${*}"
-}
-
-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} ${*}..."
-}
-
-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
-}
-
 usage() {
 	echo
 	echo 'Usage:'
@@ -85,18 +24,6 @@
 	echo "Please 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
Index: src/gnap_shared.sh
===================================================================
--- src/gnap_shared.sh	(revision 54)
+++ src/gnap_shared.sh	(working copy)
@@ -1,9 +1,10 @@
 GNAPNAME=$(basename "$0")

 case ${GNAPNAME} in
-	gnap_make )    GNAPPRODUCT="Build";;
-	gnap_overlay ) GNAPPRODUCT="Overlay";;
-	* )            GNAPPRODUCT="Something";;
+	gnap_make )     GNAPPRODUCT="Build";;
+	gnap_overlay )  GNAPPRODUCT="Overlay";;
+	gnap_remaster ) GNAPPRODUCT="Remaster";;
+	* )             GNAPPRODUCT="Something";;
 esac

 GNAPLIBDIR='/usr/lib/gnap'
@@ -12,6 +13,8 @@
 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"

 LOOP=''


-- 
gnap-dev@gentoo.org mailing list



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

* [gnap-dev] 04-feature-gnap_make-T.patch
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
  2007-07-05 13:03 ` [gnap-dev] 01-split-gnap_make.patch Philipp Riegger
  2007-07-05 13:05 ` [gnap-dev] 03-split-gnap_remaster.patch Philipp Riegger
@ 2007-07-05 13:06 ` Philipp Riegger
  2007-07-05 13:07 ` [gnap-dev] 05-festure-gnap_overlay-T.patch Philipp Riegger
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 13:06 UTC (permalink / raw
  To: gnap-dev

Index: src/gnap_make
===================================================================
--- src/gnap_make	(revision 55)
+++ src/gnap_make	(revision 57)
@@ -15,6 +15,7 @@
 	echo '    -l logfile           Use specific log file prefix'
 	echo '    -c catalyst.conf     Use specific catalyst.conf file'
 	echo '    -e specs             Specs directory or tar.bz2 file'
+	echo '    -T gnap_tempdir      Use given temp dir'
 	echo
 	echo "Please man ${GNAPNAME} for more details."
 }
@@ -29,7 +30,8 @@
 # Read options
 NOTARGET=1
 STAMP=$(date +%Y%m%d)
-while getopts ':hs:p:m:o:v:t:fl:c:e:' options; do
+TEMPDIR=''
+while getopts ':hs:p:m:o:v:t:fl:c:e:T:' options; do
 	case ${options} in
 		h ) usage
 			exit 0;;
@@ -59,6 +61,7 @@
 		l ) GNAPLOGPREFIX="${OPTARG}";;
 		c ) CATALYST_CONF="${OPTARG}";;
 		e ) SPECS="${OPTARG}";;
+		T ) TEMPDIR="${OPTARG}";;
 		* ) gtest 1 'Specified options are incomplete or unknown !';;
 	esac
 done
@@ -68,8 +71,15 @@
 gtest continued $? "You need to be root to run ${GNAPNAME}"

 # Setting up temporary directory
-TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
-gtest continued $? 'Failed to create temporary directory'
+if [[ "${TEMPDIR}" = "" ]]; then
+	TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
+	gtest continued $? 'Failed to create temporary directory'
+elif [[ -d "${TEMPDIR}" ]]
+	gconfirm "${TEMPDIR} already exists. Continue?"
+else
+	mkdir -p "${TEMPDIR}"
+	gtest continued $? "Failed to create ${TEMPDIR}"
+fi

 # Prepare specs dir and check common.conf file
 SPECDIR="${TEMPDIR}/specs"

-- 
gnap-dev@gentoo.org mailing list



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

* [gnap-dev] 05-festure-gnap_overlay-T.patch
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
                   ` (2 preceding siblings ...)
  2007-07-05 13:06 ` [gnap-dev] 04-feature-gnap_make-T.patch Philipp Riegger
@ 2007-07-05 13:07 ` Philipp Riegger
  2007-07-05 13:08 ` [gnap-dev] 06-feature-gnap_remaster-T.patch Philipp Riegger
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 13:07 UTC (permalink / raw
  To: gnap-dev

Index: tools/gnap_overlay
===================================================================
--- tools/gnap_overlay	(revision 58)
+++ tools/gnap_overlay	(revision 60)
@@ -13,26 +13,27 @@
     echo "  ${GNAPNAME} -d hostdisk -r rootdev -o overlay [ options ]"
     echo
     echo 'Common options:'
-    echo '  -o overlay    Overlay directory or tbz2 file'
-    echo '  -c conf       overlay.conf file to use (if not in overlays)'
-    echo '  -g gnap_core  Use specific GNAP core tarball file'
-    echo '  -n            Do not use the GNAP castle logo'
-    echo '  -f            Force all answers to yes (dangerous!)'
+    echo '  -o overlay       Overlay directory or tbz2 file'
+    echo '  -c conf          overlay.conf file to use (if not in overlays)'
+    echo '  -g gnap_core     Use specific GNAP core tarball file'
+    echo '  -n               Do not use the GNAP castle logo'
+    echo '  -f               Force all answers to yes (dangerous!)'
+	echo '  -T gnap_tempdir  Use given temp dir'
     echo
     echo 'Options for ISO target (create an ISO containing bootable CD):'
-    echo '  -i isoname    Customized LiveCD ISO output file name'
+    echo '  -i isoname       Customized LiveCD ISO output file name'
     echo
     echo 'Options for disk target (install to a disk plugged in system):'
-    echo '  -d hostdisk   Disk to install to, as seen on current host'
-    echo '  -r rootdev    Boot device name as seen from target system'
-    echo '  -m            Cache filesystem in memory to reduce media wear'
-    echo '  -s            Use serial console on ttyS0'
+    echo '  -d hostdisk      Disk to install to, as seen on current host'
+    echo '  -r rootdev       Boot device name as seen from target system'
+    echo '  -m               Cache filesystem in memory to reduce media
wear'
+    echo '  -s               Use serial console on ttyS0'
     echo
     echo 'Options for image target (install into a disk image):'
-    echo '  -l image      Use existing image file as output'
-    echo '                Warning: only one partition is supported!'
-    echo '  -L image      Create image file and use it as output'
-    echo '  -S size       Size of image file in megabyte'
+    echo '  -l image         Use existing image file as output'
+    echo '                   Warning: only one partition is supported!'
+    echo '  -L image         Create image file and use it as output'
+    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."
@@ -46,7 +47,8 @@
 gbegin 'Checking parameters'

 # Read options
-while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:' options; do
+TEMPDIR=''
+while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:T:' options; do
 	case ${options} in
 		h ) usage
 			exit 0;;
@@ -70,6 +72,7 @@
 		m ) CACHE='docache ';;
 		s ) SERIAL="console=ttyS0,${OPTARG}n81"
 			BAUDRATE="${OPTARG}";;
+		T ) TEMPDIR="${OPTARG}";;
 		* ) gtest 1 'Specified options are incomplete or unknown !';;
 	esac
 done
@@ -116,10 +119,19 @@
 	gconfirm 'Are you sure you want to continue ?'
 fi

+# Setting up temporary directory
+if [[ "${TEMPDIR}" = "" ]]; then
+	TEMPDIR=$(mktemp -d -t gnap_overlay.XXXXXX)
+	gtest continued $? 'Failed to create temporary directory'
+elif [[ -d "${TEMPDIR}" ]]
+	gconfirm "${TEMPDIR} already exists. Continue?"
+else
+	mkdir -p "${TEMPDIR}"
+	gtest continued $? "Failed to create ${TEMPDIR}"
+fi
+
 # Common actions
 gbegin "Expanding ${GNAPCORE} core"
-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'

-- 
gnap-dev@gentoo.org mailing list



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

* [gnap-dev] 06-feature-gnap_remaster-T.patch
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
                   ` (3 preceding siblings ...)
  2007-07-05 13:07 ` [gnap-dev] 05-festure-gnap_overlay-T.patch Philipp Riegger
@ 2007-07-05 13:08 ` Philipp Riegger
  2007-07-05 13:09 ` [gnap-dev] 07-split-make_tempdir.patch Philipp Riegger
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 13:08 UTC (permalink / raw
  To: gnap-dev

Index: tools/gnap_remaster
===================================================================
--- tools/gnap_remaster	(revision 55)
+++ tools/gnap_remaster	(working copy)
@@ -20,6 +20,7 @@
 	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 '  -T gnap_tempdir Use given temp dir'
 	echo
 	echo "Please man ${GNAPNAME} for more details."
 }
@@ -32,7 +33,8 @@
 gbegin 'Checking parameters'

 # Read options
-while getopts ':he:k:m:o:g:b:d:f' options; do
+TEMPDIR=''
+while getopts ':he:k:m:o:g:b:d:fT:' options; do
 	case ${options} in
 		h ) usage
 			exit 0;;
@@ -44,6 +46,7 @@
 		b ) GNAPBASEFS="${OPTARG}";;
 		d ) GNAPEXTDIR="${OPTARG}";;
 		f ) FORCEYES=1;;
+		T ) TEMPDIR="${OPTARG}";;
 		* ) gtest 1 'Specified options are incomplete or unknown !';;
 	esac
 done
@@ -69,10 +72,19 @@
 	gconfirm "${OUTPUT} already exists, overwrite"
 fi

+# Setting up temporary directory
+if [[ "${TEMPDIR}" = "" ]]; then
+	TEMPDIR=$(mktemp -d -t gnap_remaster.XXXXXX)
+	gtest continued $? 'Failed to create temporary directory'
+elif [[ -d "${TEMPDIR}" ]]
+	gconfirm "${TEMPDIR} already exists. Continue?"
+else
+	mkdir -p "${TEMPDIR}"
+	gtest continued $? "Failed to create ${TEMPDIR}"
+fi
+
 # Preparing new FS
 gbegin "Unpacking ${GNAPBASEFS} basefs"
-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'

-- 
gnap-dev@gentoo.org mailing list



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

* [gnap-dev]  07-split-make_tempdir.patch
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
                   ` (4 preceding siblings ...)
  2007-07-05 13:08 ` [gnap-dev] 06-feature-gnap_remaster-T.patch Philipp Riegger
@ 2007-07-05 13:09 ` Philipp Riegger
  2007-07-05 13:10 ` [gnap-dev] 08-namespace-gnap_shared.patch Philipp Riegger
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 13:09 UTC (permalink / raw
  To: gnap-dev

Index: tools/gnap_shared.sh
===================================================================
--- tools/gnap_shared.sh	(revision 55)
+++ tools/gnap_shared.sh	(working copy)
@@ -16,6 +16,7 @@
 GNAPEXTDIR="${GNAPLIBDIR}/extensions"
 GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"

+TEMPDIR=''
 LOOP=''

 G=$'\e[32;01m'
@@ -90,3 +91,15 @@
 		gtest 0
 	fi
 }
+
+make_tempdir() {
+	if [[ "${TEMPDIR}" = "" ]]; then
+		TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
+		gtest continued $? 'Failed to create temporary directory'
+	elif [[ -d "${TEMPDIR}" ]]
+		gconfirm "${TEMPDIR} already exists. Continue?"
+	else
+		mkdir -p "${TEMPDIR}"
+		gtest continued $? "Failed to create ${TEMPDIR}"
+	fi
+}
Index: tools/gnap_overlay
===================================================================
--- tools/gnap_overlay	(revision 60)
+++ tools/gnap_overlay	(working copy)
@@ -47,7 +47,6 @@
 gbegin 'Checking parameters'

 # Read options
-TEMPDIR=''
 while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:T:' options; do
 	case ${options} in
 		h ) usage
@@ -120,15 +119,7 @@
 fi

 # Setting up temporary directory
-if [[ "${TEMPDIR}" = "" ]]; then
-	TEMPDIR=$(mktemp -d -t gnap_overlay.XXXXXX)
-	gtest continued $? 'Failed to create temporary directory'
-elif [[ -d "${TEMPDIR}" ]]
-	gconfirm "${TEMPDIR} already exists. Continue?"
-else
-	mkdir -p "${TEMPDIR}"
-	gtest continued $? "Failed to create ${TEMPDIR}"
-fi
+make_tempdir

 # Common actions
 gbegin "Expanding ${GNAPCORE} core"
Index: tools/gnap_remaster
===================================================================
--- tools/gnap_remaster	(revision 61)
+++ tools/gnap_remaster	(working copy)
@@ -33,7 +33,6 @@
 gbegin 'Checking parameters'

 # Read options
-TEMPDIR=''
 while getopts ':he:k:m:o:g:b:d:fT:' options; do
 	case ${options} in
 		h ) usage
@@ -73,15 +72,7 @@
 fi

 # Setting up temporary directory
-if [[ "${TEMPDIR}" = "" ]]; then
-	TEMPDIR=$(mktemp -d -t gnap_remaster.XXXXXX)
-	gtest continued $? 'Failed to create temporary directory'
-elif [[ -d "${TEMPDIR}" ]]
-	gconfirm "${TEMPDIR} already exists. Continue?"
-else
-	mkdir -p "${TEMPDIR}"
-	gtest continued $? "Failed to create ${TEMPDIR}"
-fi
+make_tempdir

 # Preparing new FS
 gbegin "Unpacking ${GNAPBASEFS} basefs"
Index: src/gnap_make
===================================================================
--- src/gnap_make	(revision 58)
+++ src/gnap_make	(working copy)
@@ -30,7 +30,6 @@
 # Read options
 NOTARGET=1
 STAMP=$(date +%Y%m%d)
-TEMPDIR=''
 while getopts ':hs:p:m:o:v:t:fl:c:e:T:' options; do
 	case ${options} in
 		h ) usage
@@ -71,15 +70,7 @@
 gtest continued $? "You need to be root to run ${GNAPNAME}"

 # Setting up temporary directory
-if [[ "${TEMPDIR}" = "" ]]; then
-	TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
-	gtest continued $? 'Failed to create temporary directory'
-elif [[ -d "${TEMPDIR}" ]]
-	gconfirm "${TEMPDIR} already exists. Continue?"
-else
-	mkdir -p "${TEMPDIR}"
-	gtest continued $? "Failed to create ${TEMPDIR}"
-fi
+make_tempdir

 # Prepare specs dir and check common.conf file
 SPECDIR="${TEMPDIR}/specs"
Index: src/gnap_shared.sh
===================================================================
--- src/gnap_shared.sh	(revision 55)
+++ src/gnap_shared.sh	(working copy)
@@ -16,6 +16,7 @@
 GNAPEXTDIR="${GNAPLIBDIR}/extensions"
 GNAPBASEFS="${GNAPLIBDIR}/gnap-basefs.tar.bz2"

+TEMPDIR=''
 LOOP=''

 G=$'\e[32;01m'
@@ -90,3 +91,15 @@
 		gtest 0
 	fi
 }
+
+make_tempdir() {
+	if [[ "${TEMPDIR}" = "" ]]; then
+		TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
+		gtest continued $? 'Failed to create temporary directory'
+	elif [[ -d "${TEMPDIR}" ]]
+		gconfirm "${TEMPDIR} already exists. Continue?"
+	else
+		mkdir -p "${TEMPDIR}"
+		gtest continued $? "Failed to create ${TEMPDIR}"
+	fi
+}

-- 
gnap-dev@gentoo.org mailing list



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

* [gnap-dev] 08-namespace-gnap_shared.patch
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
                   ` (5 preceding siblings ...)
  2007-07-05 13:09 ` [gnap-dev] 07-split-make_tempdir.patch Philipp Riegger
@ 2007-07-05 13:10 ` Philipp Riegger
  2007-07-05 13:11 ` [gnap-dev] 09-cleanup-gnap_make.patch Philipp Riegger
  2007-07-06  7:40 ` [gnap-dev] Some patches for gnap josé Alberto Suárez López
  8 siblings, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 13:10 UTC (permalink / raw
  To: gnap-dev

Index: tools/gnap_shared.sh
===================================================================
--- tools/gnap_shared.sh	(revision 73)
+++ tools/gnap_shared.sh	(working copy)
@@ -1,23 +1,24 @@
-GNAPNAME=$(basename "$0")
+GNAP_NAME=$(basename "$0")

-case ${GNAPNAME} in
-	gnap_make )     GNAPPRODUCT="Build";;
-	gnap_overlay )  GNAPPRODUCT="Overlay";;
-	gnap_remaster ) GNAPPRODUCT="Remaster";;
-	* )             GNAPPRODUCT="Something";;
+case ${GNAP_NAME} in
+	gnap_make )     GNAP_PRODUCT="Build";;
+	gnap_overlay )  GNAP_PRODUCT="Overlay";;
+	gnap_remaster ) GNAP_PRODUCT="Remaster";;
+	* )             GNAP_PRODUCT="Something";;
 esac

-GNAPLIBDIR='/usr/lib/gnap'
-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_LIBDIR='/usr/lib/gnap'
+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_TEMPDIR=''

-TEMPDIR=''
 LOOP=''
+FORCEYES=0

 G=$'\e[32;01m'
 B=$'\e[31;01m'
@@ -37,10 +38,10 @@
 	else
 		read -ep " ${W}*${N} ${*} [N]: " answer
 		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" ]]; then
+			if [[ -n "${GNAP_TEMPDIR}" ]]; then
 				cleanup
 			fi
-			echo "${GNAPPRODUCT} aborted !"
+			echo "${GNAP_PRODUCT} aborted !"
 			exit 2
 		fi
 	fi
@@ -67,10 +68,10 @@
 			echo -en " ${B}*${N} ${*}"
 			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
 		fi
-		if [[ -n "${TEMPDIR}" ]]; then
+		if [[ -n "${GNAP_TEMPDIR}" ]]; then
 			cleanup
 		fi
-		echo "${GNAPPRODUCT} failed, try ${GNAPNAME} -h for more help"
+		echo "${GNAP_PRODUCT} failed, try ${GNAP_NAME} -h for help"
 		exit 1
 	fi
 }
@@ -82,9 +83,9 @@
 		gtest $? "Failed to unmount ${LOOP}"
 	fi
 	gbegin 'Cleaning temporary directories'
-	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
+	if [[ -d "${GNAP_TEMPDIR}" ]]; then
+		DIRTOREMOVE="${GNAP_TEMPDIR}"
+		GNAP_TEMPDIR=''
 		rm -rf "${DIRTOREMOVE}"
 		gtest $? "Failed to remove ${DIRTOREMOVE}"
 	else
@@ -93,13 +94,13 @@
 }

 make_tempdir() {
-	if [[ "${TEMPDIR}" = "" ]]; then
-		TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
+	if [[ "${GNAP_TEMPDIR}" = "" ]]; then
+		GNAP_TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
 		gtest continued $? 'Failed to create temporary directory'
-	elif [[ -d "${TEMPDIR}" ]]
-		gconfirm "${TEMPDIR} already exists. Continue?"
+	elif [[ -d "${GNAP_TEMPDIR}" ]]
+		gconfirm "${GNAP_TEMPDIR} already exists. Continue?"
 	else
-		mkdir -p "${TEMPDIR}"
-		gtest continued $? "Failed to create ${TEMPDIR}"
+		mkdir -p "${GNAP_TEMPDIR}"
+		gtest continued $? "Failed to create ${GNAP_TEMPDIR}"
 	fi
 }
Index: tools/gnap_overlay
===================================================================
--- tools/gnap_overlay	(revision 73)
+++ tools/gnap_overlay	(working copy)
@@ -2,15 +2,15 @@
 VERSION='2.0'

 source "gnap_shared.sh"
-echo "GNAP overlay tool ${GNAPNAME} ${VERSION}"
+echo "GNAP overlay tool ${GNAP_NAME} ${VERSION}"

 IMG_SIZE=15

 usage() {
 	echo
     echo 'Usage:'
-    echo "  ${GNAPNAME} -i isoname -o overlay [ options ]"
-    echo "  ${GNAPNAME} -d hostdisk -r rootdev -o overlay [ options ]"
+    echo "  ${GNAP_NAME} -i isoname -o overlay [ options ]"
+    echo "  ${GNAP_NAME} -d hostdisk -r rootdev -o overlay [ options ]"
     echo
     echo 'Common options:'
     echo '  -o overlay       Overlay directory or tbz2 file'
@@ -36,7 +36,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 "Run man ${GNAP_NAME} for more details."
 }

 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
@@ -47,11 +47,21 @@
 gbegin 'Checking parameters'

 # Read options
+OVERLAYS=''
+OVERLAYCONF=''
+NOLOGO=0
+OUTPUT=''
+TYPE=''
+CREATE=''
+TARGETROOT=''
+CACHE=''
+SERIAL=''
+BAUDRATE=''
 while getopts ':hg:o:c:nfi:d:l:r:ms:S:L:T:' options; do
 	case ${options} in
 		h ) usage
 			exit 0;;
-		g ) GNAPCORE="${OPTARG}";;
+		g ) GNAP_CORE="${OPTARG}";;
 		o ) OVERLAYS="${OVERLAYS} ${OPTARG}";;
 		c ) OVERLAYCONF="${OPTARG}";;
 		n ) NOLOGO=1;;
@@ -71,7 +81,7 @@
 		m ) CACHE='docache ';;
 		s ) SERIAL="console=ttyS0,${OPTARG}n81"
 			BAUDRATE="${OPTARG}";;
-		T ) TEMPDIR="${OPTARG}";;
+		T ) GNAP_TEMPDIR="${OPTARG}";;
 		* ) gtest 1 'Specified options are incomplete or unknown !';;
 	esac
 done
@@ -81,7 +91,7 @@
 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
@@ -111,7 +121,7 @@
 	gwarn 'Warning : you have selected disk install'
 	gwarn "Make sure you are root or have full access to ${OUTPUT}"
 	gwarn "${PARENTDEV} must have an MBR installed, run:"
-	gwarn "${W}dd if=${GNAPMBR} of=${PARENTDEV} bs=512 count=1${N} if needed"
+	gwarn "${W}dd if=${GNAP_MBR} 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} !"
@@ -122,15 +132,15 @@
 make_tempdir

 # Common actions
-gbegin "Expanding ${GNAPCORE} core"
-TEMPCOREDIR="${TEMPDIR}/core"
+gbegin "Expanding ${GNAP_CORE} core"
+TEMPCOREDIR="${GNAP_TEMPDIR}/core"
 mkdir "${TEMPCOREDIR}"
 gtest continued $? 'Failed to create core temporary subdirectory'
-tar x -C "${TEMPCOREDIR}" -f "${GNAPCORE}"
+tar x -C "${TEMPCOREDIR}" -f "${GNAP_CORE}"
 gtest $? 'Failed to extract core'

 gbegin 'Preparing overlay'
-TEMPOVERDIR="${TEMPDIR}/overlay"
+TEMPOVERDIR="${GNAP_TEMPDIR}/overlay"
 mkdir "${TEMPOVERDIR}"
 gtest $? 'Failed to create overlay temporary subdirectory'

@@ -250,7 +260,7 @@
 	gtest $?

 	gbegin "Mounting ${OUTPUT}"
-	TEMPMOUNTDIR="${TEMPDIR}/mount"
+	TEMPMOUNTDIR="${GNAP_TEMPDIR}/mount"
 	mkdir "${TEMPMOUNTDIR}"
 	gtest continued $? 'Failed to create mount temporary subdirectory'
 	mount -t msdos "${OUTPUT}" "${TEMPMOUNTDIR}"
@@ -289,7 +299,7 @@
 		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 $?
 		;;
@@ -298,5 +308,5 @@

 # Successful finish
 cleanup
-echo 'Overlay successful !'
+echo "${GNAP_PRODUCT} successful !"
 exit 0
Index: tools/gnap_remaster
===================================================================
--- tools/gnap_remaster	(revision 73)
+++ tools/gnap_remaster	(working copy)
@@ -2,14 +2,14 @@
 VERSION='2.0'

 source "gnap_shared.sh"
-echo "GNAP remastering tool ${GNAPNAME} ${VERSION}"
+echo "GNAP remastering tool ${GNAP_NAME} ${VERSION}"

 OUTPUT='mygnap-core.tar'

 usage() {
 	echo
 	echo 'Usage:'
-	echo "  ${GNAPNAME} [ options ]"
+	echo "  ${GNAP_NAME} [ options ]"
 	echo
 	echo 'Options:'
 	echo '  -e extension    Extension to include in core file'
@@ -22,7 +22,7 @@
 	echo '  -f              Force all answers to yes (dangerous !)'
 	echo '  -T gnap_tempdir Use given temp dir'
 	echo
-	echo "Please man ${GNAPNAME} for more details."
+	echo "Use man ${GNAP_NAME} for more details."
 }

 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
@@ -41,25 +41,25 @@
 		k ) KERNEXT="${OPTARG}";;
 		m ) MODEXT="${OPTARG}";;
 		o ) OUTPUT="${OPTARG}";;
-		g ) GNAPCORE="${OPTARG}";;
-		b ) GNAPBASEFS="${OPTARG}";;
-		d ) GNAPEXTDIR="${OPTARG}";;
+		g ) GNAP_CORE="${OPTARG}";;
+		b ) GNAP_BASEFS="${OPTARG}";;
+		d ) GNAP_EXTDIR="${OPTARG}";;
 		f ) FORCEYES=1;;
-		T ) TEMPDIR="${OPTARG}";;
+		T ) GNAP_TEMPDIR="${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 ${GNAP_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
@@ -75,34 +75,34 @@
 make_tempdir

 # Preparing new FS
-gbegin "Unpacking ${GNAPBASEFS} basefs"
-TEMPOVERDIR="${TEMPDIR}/basefs"
+gbegin "Unpacking ${GNAP_BASEFS} basefs"
+TEMPOVERDIR="${GNAP_TEMPDIR}/basefs"
 mkdir "${TEMPOVERDIR}"
 gtest continued $? 'Failed to create basefs temporary subdirectory'

-tar jx -C "${TEMPOVERDIR}" -f "${GNAPBASEFS}"
+tar jx -C "${TEMPOVERDIR}" -f "${GNAP_BASEFS}"
 gtest $? 'Failed to unpack basefs'

 for overlay in ${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

 # Preparing new core
 gbegin 'Extracting core tarball'
-TEMPCOREDIR="${TEMPDIR}/core"
+TEMPCOREDIR="${GNAP_TEMPDIR}/core"
 mkdir "${TEMPCOREDIR}"
 gtest continued $? 'Failed to create core temporary subdirectory'

-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}"
-	TEMPKERNDIR="${TEMPDIR}/kernel"
+	TEMPKERNDIR="${GNAP_TEMPDIR}/kernel"
 	mkdir "${TEMPKERNDIR}"
 	gtest continued $? 'Failed to create kernel temporary subdirectory'

@@ -136,6 +136,6 @@

 # Successful finish
 cleanup
-echo 'Remaster successful !'
+echo "${GNAP_PRODUCT} successful !"
 exit 0

Index: src/gnap_make
===================================================================
--- src/gnap_make	(revision 73)
+++ src/gnap_make	(working copy)
@@ -17,7 +17,7 @@
 	echo '    -e specs             Specs directory or tar.bz2 file'
 	echo '    -T gnap_tempdir      Use given temp dir'
 	echo
-	echo "Please man ${GNAPNAME} for more details."
+	echo "Use man ${GNAP_NAME} for more details."
 }

 if [[ "$#" -eq 0 || "${1}" == '-h' ]]; then
@@ -34,8 +34,8 @@
 	case ${options} in
 		h ) usage
 			exit 0;;
-		s ) STAGE3FILE="${OPTARG}";;
-		p ) SNAPSHOTFILE="${OPTARG}";;
+		s ) GNAP_STAGE3FILE="${OPTARG}";;
+		p ) GNAP_SNAPSHOTFILE="${OPTARG}";;
 		o ) PORTAGE_OVERLAYS="${PORTAGE_OVERLAYS} ${OPTARG}";;
 		v ) STAMP="${OPTARG}";;
 		t )
@@ -59,31 +59,31 @@
 		f ) FORCEYES=1;;
 		l ) GNAPLOGPREFIX="${OPTARG}";;
 		c ) CATALYST_CONF="${OPTARG}";;
-		e ) SPECS="${OPTARG}";;
-		T ) TEMPDIR="${OPTARG}";;
+		e ) GNAP_SPECS="${OPTARG}";;
+		T ) GNAP_TEMPDIR="${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 ${GNAP_NAME}"

 # Setting up temporary directory
 make_tempdir

 # Prepare specs dir and check common.conf file
-SPECDIR="${TEMPDIR}/specs"
-if [[ -f "${SPECS}" ]]; then
+SPECDIR="${GNAP_TEMPDIR}/specs"
+if [[ -f "${GNAP_SPECS}" ]]; then
 	mkdir "${SPECDIR}"
 	gtest continued $? 'Failed to create specs temporary subdirectory'
-	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 !"
@@ -124,20 +124,20 @@

 # Stage3 needs a seed stage
 if [[ "${STAGE3}" -eq 1 ]]; then
-	test -f "${STAGE3FILE}"
+	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"
+	test -f "${GNAP_STAGE3FILE}"
+	gtest continued $? "${GNAP_STAGE3FILE} is not a valid stage3 tarball"
 fi
 gtest 0

@@ -150,7 +150,7 @@
 		if [[ ! -d "${CATALYST_DIR}/builds/${RELTYPE}" ]]; then
 			mkdir -p "${CATALYST_DIR}/builds/${RELTYPE}"
 		fi
-		cp "${STAGE3FILE}" "${STAGE3LOC}"
+		cp "${GNAP_STAGE3FILE}" "${STAGE3LOC}"
 	fi
 fi

@@ -182,7 +182,7 @@

 # Logfile setup and confirmation
 if [[ -z "$GNAPLOGPREFIX" ]]; then
-	GNAPLOGPREFIX="./${GNAPNAME}-${STAMP}"
+	GNAPLOGPREFIX="./${GNAP_NAME}-${STAMP}"
 fi

 if [[ -f "${GNAPLOGPREFIX}.out" || -f "${GNAPLOGPREFIX}.err" ]]; then
@@ -208,14 +208,14 @@
 	fi

 	if [[ -z "${PORTAGE_OVERLAYS}" ]]; then
-		cp "${SNAPSHOTFILE}" "${CATALYST_DIR}/snapshots/portage-${STAMP}.tar.bz2"
+		cp "${GNAP_SNAPSHOTFILE}"
"${CATALYST_DIR}/snapshots/portage-${STAMP}.tar.bz2"
 		gtest $? "Snapshot preparation failed, ${SEELOGFILES}"
 	else
-		TEMPPRTDIR="${TEMPDIR}/portage"
+		TEMPPRTDIR="${GNAP_TEMPDIR}/portage"
 		mkdir "${TEMPPRTDIR}"
 		gtest continued $? 'Failed to create portage temporary subdirectory'

-		tar jxf "${SNAPSHOTFILE}" -C "${TEMPPRTDIR}" \
+		tar jxf "${GNAP_SNAPSHOTFILE}" -C "${TEMPPRTDIR}" \
 			>> "${GNAPLOGPREFIX}.out" 2>> "${GNAPLOGPREFIX}.err"

 		for overlay in ${PORTAGE_OVERLAYS} ; do
@@ -237,9 +237,9 @@
 	if [[ ! -d "${CATALYST_DIR}/builds/${RELTYPE}" ]]; then
 		mkdir -p "${CATALYST_DIR}/builds/${RELTYPE}"
 	fi
-	cp "${STAGE3FILE}" "${CATALYST_DIR}/builds/${RELTYPE}/seedstage.tar.bz2"
+	cp "${GNAP_STAGE3FILE}"
"${CATALYST_DIR}/builds/${RELTYPE}/seedstage.tar.bz2"

-	TEMPCONF="${TEMPDIR}/stage3.conf"
+	TEMPCONF="${GNAP_TEMPDIR}/stage3.conf"
 	touch "${TEMPCONF}"
 	gtest continued $? 'Failed to create stage3 temporary conf file'
 	cat >> "${TEMPCONF}" <<EOF
@@ -262,7 +262,7 @@
 # LIVECD-STAGE1 phase
 if [[ "${LIVECD1}" -eq 1 ]]; then
 	gbegin "${G}[livecd-stage1]${N} stage (GNAP-specific packages build)"
-	TEMPCONF="${TEMPDIR}/livecd-stage1.conf"
+	TEMPCONF="${GNAP_TEMPDIR}/livecd-stage1.conf"
 	touch "${TEMPCONF}"
 	gtest continued $? 'Failed to create livecd-stage1 temporary conf file'
 	cat >> "${TEMPCONF}" <<EOF
@@ -286,7 +286,7 @@
 # LIVECD-STAGE2 phase
 if [[ "${LIVECD2}" -eq 1 ]]; then
 	gbegin "${G}[livecd-stage2]${N} stage (kernel and LiveCD builds)"
-	TEMPCONF="${TEMPDIR}/livecd-stage2.conf"
+	TEMPCONF="${GNAP_TEMPDIR}/livecd-stage2.conf"
 	touch "${TEMPCONF}"
 	gtest continued $? 'Failed to create livecd-stage2 temporary conf file'
 	cat >> "${TEMPCONF}" <<EOF
@@ -321,10 +321,10 @@
 	gtest $? 'Missing livecd-stage2 results'

 	gbegin '  Creating core component'
-	TEMPMNTDIR="${TEMPDIR}/mount"
+	TEMPMNTDIR="${GNAP_TEMPDIR}/mount"
 	mkdir "${TEMPMNTDIR}"
 	gtest continued $? 'Failed to create mount temporary subdirectory'
-	TEMPISODIR="${TEMPDIR}/iso"
+	TEMPISODIR="${GNAP_TEMPDIR}/iso"
 	mkdir "${TEMPISODIR}"
 	gtest continued $? 'Failed to create iso temporary subdirectory'

@@ -368,7 +368,7 @@
 		mod_packlist="${mod_packlist/${mod_name}\/packlist:/}"
 		mod_cleanup=$(grep "^${mod_name}/cleanup:" ${SPECMODULE} 2>/dev/null);
 		mod_cleanup="${mod_cleanup/${mod_name}\/cleanup:/}"
-		TEMPCONF="${TEMPDIR}/ext-${mod_name}.conf"
+		TEMPCONF="${GNAP_TEMPDIR}/ext-${mod_name}.conf"
 		touch "${TEMPCONF}"
 		gtest continued $? 'Failed to create extension temporary conf file'
 		cat >> $TEMPCONF <<EOF
@@ -391,7 +391,7 @@
 		gtest continued $? \
 			"Extension build failed, ${SEELOGFILES}"

-		TEMPMODULEDIR="${TEMPDIR}/module_${mod_name}"
+		TEMPMODULEDIR="${GNAP_TEMPDIR}/module_${mod_name}"
 		mkdir "${TEMPMODULEDIR}"
 		gtest continued $? 'Failed to create module temporary subdirectory'
 		for pkg in $( ls ${GRP_PREFIX}/${mod_name}/All/*.tbz2 ); do
@@ -416,5 +416,5 @@
 fi

 cleanup
-echo 'Build successful !'
+echo "${GNAP_PRODUCT} successful !"
 exit 0
Index: src/gnap_shared.sh
===================================================================
--- src/gnap_shared.sh	(revision 73)
+++ src/gnap_shared.sh	(working copy)
@@ -1,23 +1,24 @@
-GNAPNAME=$(basename "$0")
+GNAP_NAME=$(basename "$0")

-case ${GNAPNAME} in
-	gnap_make )     GNAPPRODUCT="Build";;
-	gnap_overlay )  GNAPPRODUCT="Overlay";;
-	gnap_remaster ) GNAPPRODUCT="Remaster";;
-	* )             GNAPPRODUCT="Something";;
+case ${GNAP_NAME} in
+	gnap_make )     GNAP_PRODUCT="Build";;
+	gnap_overlay )  GNAP_PRODUCT="Overlay";;
+	gnap_remaster ) GNAP_PRODUCT="Remaster";;
+	* )             GNAP_PRODUCT="Something";;
 esac

-GNAPLIBDIR='/usr/lib/gnap'
-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_LIBDIR='/usr/lib/gnap'
+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_TEMPDIR=''

-TEMPDIR=''
 LOOP=''
+FORCEYES=0

 G=$'\e[32;01m'
 B=$'\e[31;01m'
@@ -37,10 +38,10 @@
 	else
 		read -ep " ${W}*${N} ${*} [N]: " answer
 		if [[ "${answer}" != 'y' && "${answer}" != 'Y' ]]; then
-			if [[ -n "${TEMPDIR}" ]]; then
+			if [[ -n "${GNAP_TEMPDIR}" ]]; then
 				cleanup
 			fi
-			echo "${GNAPPRODUCT} aborted !"
+			echo "${GNAP_PRODUCT} aborted !"
 			exit 2
 		fi
 	fi
@@ -67,10 +68,10 @@
 			echo -en " ${B}*${N} ${*}"
 			echo -e "${E}  ${K}[ ${B}!!${K} ]${N}"
 		fi
-		if [[ -n "${TEMPDIR}" ]]; then
+		if [[ -n "${GNAP_TEMPDIR}" ]]; then
 			cleanup
 		fi
-		echo "${GNAPPRODUCT} failed, try ${GNAPNAME} -h for more help"
+		echo "${GNAP_PRODUCT} failed, try ${GNAP_NAME} -h for help"
 		exit 1
 	fi
 }
@@ -82,9 +83,9 @@
 		gtest $? "Failed to unmount ${LOOP}"
 	fi
 	gbegin 'Cleaning temporary directories'
-	if [[ -d "${TEMPDIR}" ]]; then
-		DIRTOREMOVE="${TEMPDIR}"
-		TEMPDIR=''
+	if [[ -d "${GNAP_TEMPDIR}" ]]; then
+		DIRTOREMOVE="${GNAP_TEMPDIR}"
+		GNAP_TEMPDIR=''
 		rm -rf "${DIRTOREMOVE}"
 		gtest $? "Failed to remove ${DIRTOREMOVE}"
 	else
@@ -93,13 +94,13 @@
 }

 make_tempdir() {
-	if [[ "${TEMPDIR}" = "" ]]; then
-		TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
+	if [[ "${GNAP_TEMPDIR}" = "" ]]; then
+		GNAP_TEMPDIR=$(mktemp -d -t gnap_make.XXXXXX)
 		gtest continued $? 'Failed to create temporary directory'
-	elif [[ -d "${TEMPDIR}" ]]
-		gconfirm "${TEMPDIR} already exists. Continue?"
+	elif [[ -d "${GNAP_TEMPDIR}" ]]
+		gconfirm "${GNAP_TEMPDIR} already exists. Continue?"
 	else
-		mkdir -p "${TEMPDIR}"
-		gtest continued $? "Failed to create ${TEMPDIR}"
+		mkdir -p "${GNAP_TEMPDIR}"
+		gtest continued $? "Failed to create ${GNAP_TEMPDIR}"
 	fi
 }

-- 
gnap-dev@gentoo.org mailing list



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

* [gnap-dev] 09-cleanup-gnap_make.patch
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
                   ` (6 preceding siblings ...)
  2007-07-05 13:10 ` [gnap-dev] 08-namespace-gnap_shared.patch Philipp Riegger
@ 2007-07-05 13:11 ` Philipp Riegger
  2007-07-06  7:40 ` [gnap-dev] Some patches for gnap josé Alberto Suárez López
  8 siblings, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-05 13:11 UTC (permalink / raw
  To: gnap-dev

Index: src/gnap_make
===================================================================
--- src/gnap_make	(revision 81)
+++ src/gnap_make	(working copy)
@@ -29,7 +29,6 @@

 # Read options
 NOTARGET=1
-ALLTARGET=0
 STAGE3=0
 LIVECD1=0
 LIVECD2=0
@@ -47,7 +46,13 @@
 		v ) GNAP_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;;
@@ -57,10 +62,13 @@
 				livecd-stage2 )
 					LIVECD2=1
 					NEEDS_SNAPSHOT=1;;
-				tarball ) TARBALL=1;;
+				tarball )
+					TARBALL=1;;
 				extensions )
 					MODULES=1
 					NEEDS_SNAPSHOT=1;;
+				* )
+					gtest 1 'Specified stage unknown !';;
 			esac
 			NOTARGET=0;;
 		f ) FORCEYES=1;;
@@ -107,27 +115,14 @@
 gtest continued $? "${GNAP_CATALYST_CONF} file not found !"
 source "${GNAP_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
+mkdir -p "${CATALYST_DIR}"
+gtest continued $? "Error: failed to create ${CATALYST_DIR} directory."

 # Stage3 needs a seed stage
 if [[ "${STAGE3}" -eq 1 ]]; then
@@ -146,7 +141,6 @@
 	test -f "${GNAP_STAGE3FILE}"
 	gtest continued $? "${GNAP_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}-${GNAP_STAMP}.tar.bz2"
@@ -154,9 +148,9 @@
 	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
+		mkdir -p "${CATALYST_DIR}/builds/${RELTYPE}"
+		gtest continued $? \
+			"Error: failed to create ${CATALYST_DIR}/builds/${RELTYPE} directory."
 		cp "${GNAP_STAGE3FILE}" "${STAGE3LOC}"
 	fi
 fi
@@ -194,8 +188,7 @@

 if [[ -f "${GNAP_LOGPREFIX}.out" || -f "${GNAP_LOGPREFIX}.err" ]]; then
 	if [[ "${FORCEYES}" -ne 1 ]]; then
-		read -ep \
-			" ${W}*${N} Logfile(s) already exists. Append/Overwrite [A]: " \
+		read -ep " ${W}*${N} Logfile(s) already exists. Append/Overwrite [A]: " \
 			answer
 		if [[ "${answer}" == 'o' || "${answer}" == 'O' ]]; then
 			rm "${GNAP_LOGPREFIX}.out" "${GNAP_LOGPREFIX}.err"
@@ -210,9 +203,7 @@
 if [[ "${NEEDS_SNAPSHOT}" -eq 1 ]]; then
 	gbegin 'Preparing portage snapshot'

-	if [[ ! -d "${CATALYST_DIR}/snapshots" ]]; then
-		mkdir -p "${CATALYST_DIR}/snapshots"
-	fi
+	mkdir -p "${CATALYST_DIR}/snapshots"

 	if [[ -z "${GNAP_PORTAGE_OVERLAYS}" ]]; then
 		cp "${GNAP_SNAPSHOTFILE}"
"${CATALYST_DIR}/snapshots/portage-${GNAP_STAMP}.tar.bz2"

-- 
gnap-dev@gentoo.org mailing list



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

* Re: [gnap-dev] Some patches for gnap
  2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
                   ` (7 preceding siblings ...)
  2007-07-05 13:11 ` [gnap-dev] 09-cleanup-gnap_make.patch Philipp Riegger
@ 2007-07-06  7:40 ` josé Alberto Suárez López
  2007-07-06 15:08   ` Philipp Riegger
  8 siblings, 1 reply; 13+ messages in thread
From: josé Alberto Suárez López @ 2007-07-06  7:40 UTC (permalink / raw
  To: gnap-dev

El jue, 05-07-2007 a las 15:53 +0300, Philipp Riegger escribió:
> Hi!
> 
> I wanted to send the patches for gnap i made so far. I don't know what i
> screwed up, but somehow they do not apply cleanly. I send them anyway for
> review, if anybody wants i can send my current gnap_* scripts or recreate
> working patches.

kingtaco told me infra have the new machine, so i hope to have our new
home soon, so all of us can use the repo to work together and fast.

> I will send the patcehs as replies to this email (since they are mostly
> for review).

i will review them soon as possible, so can be great jaervousz and the
resto do it too.

> 01-split-gnap_make.patch
> 02-split-gnap_overlay.patch
> 03-split-gnap_remaster.patch
> 
> Theese first 3 patches take the common stuff (functions, constants) from
> the gnap_* scripts and put it into gnap_shared.sh
> 
> Note:
> 1) There are 2 gnap_shared.sh so far, one in the src and one in the toos
> directory of the gnap svn tree. This should maybe be changed...

shoudl be

> 2) The gnap_* scripts do 'source "gnap_shared.sh"', which is probably not
> good. In which directory will we put gnap_shared.sh?

at moment "/usr/lib/gnap"

[...]

> 08-namespace-gnap_shared.patch
> 
> This cleanes up the namespace, all variables that are used as input
> parameters in gnap_shared.sh are prefixed with GNAP_ to get a clean usage
> of the namespace. More to that later.

great

[...]

> Ok, so far, so good. What's next?
> 
> 1) Configuring gnap
> 
> At the moment configuring gnap_make (at which i concentrate so far) is
> quite a mess. We have default parameters (in gnap_shared.sh), we have
> catalyst.conf and commons.conf which we simply source, we have command
> line options. At the moment this means the following:
> 
> Default options are set first, then they are overwritten by command line
> options, which are overwritten by common.conf, ehich are overwritten by
> catalyst.conf.
> 
> This is not really clean. For example, we use CATALYST_TEMP_DIR in
> common.conf, catalyst uses store_dir in catalyst.conf. This is redundant
> and does not make it clean. The default common.conf also defines
> CATALYST_CONF (which might be broken because i renamed it, i have to
> check), but that means that the command line option for specifying
> catalyst.conf does not work if this is not commented out.
> 
> So... do we want to change this? I would like something like:
> 
> We can use variables from the environment. This will only be valid for
> GNAP_* variables, so we have a clear namespace and it enables people to
> set default variables. I'm not sure, how much this will be needed/used,
> but it sounds like an interesting feature. The catalyst.conf is only used
> for catalyst configuration (interaction between gnap and catalyst),
> therefore it does never make sense to overwrite information given there.
> 
> Default options < environment < common.conf < command line options.
> 
> This would be my prefered way of configuring gnap, where variables from
> sources more right overwrite variables from sources more left.

i like the idea, work on it and tell me. I prefer as less config files
to edit better.

> 2) gnap_make feature: pretend
> 
> I'd like a --pretend feature for gnap_make which lets it just create the
> configuration files for catalyst and the source files (portage tree, from
> tree snapsht and overlays). This might be useful for test runs,
> development and usage of catalyst features gnap does not support. This
> could be implemented by simply overwriting CATALYST_BIN with "echo
> $CATALYSY_BIN", if 1) from above is clear.

i prefer to mantain gnap simple as possible, Really some catalyst option
is so usefull to use it alone? non-implemented-catalyst options are
sufficent usefull to implement them in gnap_make?

> 3) gnap_make feature: improved overlay handling
> 
> The overlay handling of gnap_make is some kind of bug, i think. If you
> don't take care, Manifests are broken. Therefore i want to change it that
> packages (directories in which ebuilds are) are first deleted from the
> tree and metadata/cache if they exist, before new ones from overlays are
> added. This should be easy to understand, since people usually don't need
> stuff from the tree anymore if they use an overlay for a specific package.

To improve is ever good :)

> 4) some small stuff
> 
> At the moment, if there is a choice (Overwrite/Append, Yes/No) only one
> possibility is checked and the other is assumed, if the one is not given.
> I'd like to change this to something like "It is asked in a loop until a
> valid option is given."
> 
> There is a function gwarn, writes to stderr. It is used in some places
> where ginfo would make more sence, if it would exist. I'd like to
> implement and use this.

for example?

> That's all i wanted to say about the gnap_scripts at the moment.

you say a lot :)

nice job

--
gnap-dev@gentoo.org mailing list



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

* Re: [gnap-dev] Some patches for gnap
  2007-07-06  7:40 ` [gnap-dev] Some patches for gnap josé Alberto Suárez López
@ 2007-07-06 15:08   ` Philipp Riegger
  2007-07-09  7:13     ` josé Alberto Suárez López
  2007-07-12 23:49     ` Philipp Riegger
  0 siblings, 2 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-06 15:08 UTC (permalink / raw
  To: gnap-dev

josé Alberto Suárez López wrote:

> kingtaco told me infra have the new machine, so i hope to have our new
> home soon, so all of us can use the repo to work together and fast.

Nice. With this change, are you also switching to svn or soemthing like
that or changing the gnap repository layout? Making a difference between
gnap_make and the other scripts seems rather artificial, since they are
sharing code now.

>> Note:
>> 1) There are 2 gnap_shared.sh so far, one in the src and one in the toos
>> directory of the gnap svn tree. This should maybe be changed...
>
> shoudl be

Where do you want to have it?

>> 2) The gnap_* scripts do 'source "gnap_shared.sh"', which is probably
>> not
>> good. In which directory will we put gnap_shared.sh?
>
> at moment "/usr/lib/gnap"

Seems to make the most sense, i'll change that.

>> 08-namespace-gnap_shared.patch
>>
>> This cleanes up the namespace, all variables that are used as input
>> parameters in gnap_shared.sh are prefixed with GNAP_ to get a clean
>> usage
>> of the namespace. More to that later.
>
> great

It's not 100% clean so far, i did not work on variables in gnap_overlay
and gnap_remaster so far, i also forgot to check which implications this
has on the config files.

>> Ok, so far, so good. What's next?
>>
>> 1) Configuring gnap
>>
>> At the moment configuring gnap_make (at which i concentrate so far) is
>> quite a mess. We have default parameters (in gnap_shared.sh), we have
>> catalyst.conf and commons.conf which we simply source, we have command
>> line options. At the moment this means the following:
>>
>> Default options are set first, then they are overwritten by command line
>> options, which are overwritten by common.conf, ehich are overwritten by
>> catalyst.conf.
>>
>> This is not really clean. For example, we use CATALYST_TEMP_DIR in
>> common.conf, catalyst uses store_dir in catalyst.conf. This is redundant
>> and does not make it clean. The default common.conf also defines
>> CATALYST_CONF (which might be broken because i renamed it, i have to
>> check), but that means that the command line option for specifying
>> catalyst.conf does not work if this is not commented out.
>>
>> So... do we want to change this? I would like something like:
>>
>> We can use variables from the environment. This will only be valid for
>> GNAP_* variables, so we have a clear namespace and it enables people to
>> set default variables. I'm not sure, how much this will be needed/used,
>> but it sounds like an interesting feature. The catalyst.conf is only
>> used
>> for catalyst configuration (interaction between gnap and catalyst),
>> therefore it does never make sense to overwrite information given there.
>>
>> Default options < environment < common.conf < command line options.
>>
>> This would be my prefered way of configuring gnap, where variables from
>> sources more right overwrite variables from sources more left.
>
> i like the idea, work on it and tell me. I prefer as less config files
> to edit better.

The easiest way to implement this would be:

We use ${:-} or ${:=} (i have to understand the difference between them)
for default parameters, parse the command line for the first time only
extracting parameters concerning external config files or -h, parse theese
config files (we have them or default config files), order will be
common.conf and then catalyst.conf (so common.conf can overwrite the
variable saying where to find catalyst.conf), we parse the command line
options again and use all the info given there to set/overwrite variables.

Advantages:
 - No additional variables needed
 - Quite easy change
 - Should give us what we want
 - No need for a config file parser

Disadvantages:
 - Well... common.conf and catalyst.conf can overwrite lots of things, we
never check which config file is allowed to overwrite what. But if
somebody does strange things there, it's not our fault, i think


>> 2) gnap_make feature: pretend
>>
>> I'd like a --pretend feature for gnap_make which lets it just create the
>> configuration files for catalyst and the source files (portage tree,
>> from
>> tree snapsht and overlays). This might be useful for test runs,
>> development and usage of catalyst features gnap does not support. This
>> could be implemented by simply overwriting CATALYST_BIN with "echo
>> $CATALYSY_BIN", if 1) from above is clear.
>
> i prefer to mantain gnap simple as possible, Really some catalyst option
> is so usefull to use it alone? non-implemented-catalyst options are
> sufficent usefull to implement them in gnap_make?

Hmm, all the reasons why i thought this might be a good idea are only
minor. So... i'll move that off my todo list until i find a valid use case
for it.

>> 3) gnap_make feature: improved overlay handling

[...]

> To improve is ever good :)

An alternative would be to introduce overlay handling to catalyst, but i
think, we don't want that. :-)

>> 4) some small stuff
>>
>> At the moment, if there is a choice (Overwrite/Append, Yes/No) only one
>> possibility is checked and the other is assumed, if the one is not
>> given.
>> I'd like to change this to something like "It is asked in a loop until a
>> valid option is given."

Any comments on this?

Examples:

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 "${GNAP_TEMPDIR}" ]]; then
                                cleanup
                        fi
                        echo "${GNAP_PRODUCT} aborted !"
                        exit 2
                fi
        fi
}

what if the user mixes up for example german and us keyboard layout, wants
to say y but gets z instead?

if [[ -f "${GNAP_LOGPREFIX}.out" || -f "${GNAP_LOGPREFIX}.err" ]]; then
        if [[ "${FORCEYES}" -ne 1 ]]; then
                read -ep " ${W}*${N} Logfile(s) already exists.
Append/Overwrite
 [A]: " \
                        answer
                if [[ "${answer}" == 'o' || "${answer}" == 'O' ]]; then
                        rm "${GNAP_LOGPREFIX}.out" "${GNAP_LOGPREFIX}.err"
                fi
        fi
fi

Same here, i cannot think of keymap issues but peope sometimes hit the
wrong button. Should we have the questions in a loop until they are
answered correctly?

>> There is a function gwarn, writes to stderr. It is used in some places
>> where ginfo would make more sence, if it would exist. I'd like to
>> implement and use this.
>
> for example?

gwarn 'The following targets will be called:'
gwarn "${TARGETLIST}"

>> That's all i wanted to say about the gnap_scripts at the moment.
>
> you say a lot :)

Hmm... is that good or bad? :)

> nice job

Thanks, unfortunately not what i applied for. :-(

See you,
    Philipp
-- 
gnap-dev@gentoo.org mailing list



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

* Re: [gnap-dev] Some patches for gnap
  2007-07-06 15:08   ` Philipp Riegger
@ 2007-07-09  7:13     ` josé Alberto Suárez López
  2007-07-12 23:49     ` Philipp Riegger
  1 sibling, 0 replies; 13+ messages in thread
From: josé Alberto Suárez López @ 2007-07-09  7:13 UTC (permalink / raw
  To: gnap-dev

El vie, 06-07-2007 a las 18:08 +0300, Philipp Riegger escribió:
> josé Alberto Suárez López wrote:
> 
> > kingtaco told me infra have the new machine, so i hope to have our new
> > home soon, so all of us can use the repo to work together and fast.
> 
> Nice. With this change, are you also switching to svn or soemthing like
> that or changing the gnap repository layout? Making a difference between
> gnap_make and the other scripts seems rather artificial, since they are
> sharing code now.

we will change to svn, the layout is not determined yet, Who want to be
the first to propose the layout? :)

> >> Note:
> >> 1) There are 2 gnap_shared.sh so far, one in the src and one in the toos
> >> directory of the gnap svn tree. This should maybe be changed...
> >
> > shoudl be
> 
> Where do you want to have it?

as you own :)

[...]

> > i like the idea, work on it and tell me. I prefer as less config files
> > to edit better.
> 
> The easiest way to implement this would be:
> 
> We use ${:-} or ${:=} (i have to understand the difference between them)
> for default parameters, parse the command line for the first time only
> extracting parameters concerning external config files or -h, parse theese
> config files (we have them or default config files), order will be
> common.conf and then catalyst.conf (so common.conf can overwrite the
> variable saying where to find catalyst.conf), we parse the command line
> options again and use all the info given there to set/overwrite variables.
> 
> Advantages:
>  - No additional variables needed
>  - Quite easy change
>  - Should give us what we want
>  - No need for a config file parser
> 
> Disadvantages:
>  - Well... common.conf and catalyst.conf can overwrite lots of things, we
> never check which config file is allowed to overwrite what. But if
> somebody does strange things there, it's not our fault, i think

seem well to me, who thinks the other zombies in the list?

[...]

> >> 3) gnap_make feature: improved overlay handling
> 
> [...]
> 
> > To improve is ever good :)
> 
> An alternative would be to introduce overlay handling to catalyst, but i
> think, we don't want that. :-)

sure :P

> >> 4) some small stuff
> >>
> >> At the moment, if there is a choice (Overwrite/Append, Yes/No) only one
> >> possibility is checked and the other is assumed, if the one is not
> >> given.
> >> I'd like to change this to something like "It is asked in a loop until a
> >> valid option is given."

ok, is not a major change

> >> There is a function gwarn, writes to stderr. It is used in some places
> >> where ginfo would make more sence, if it would exist. I'd like to
> >> implement and use this.
> >
> > for example?
> 
> gwarn 'The following targets will be called:'
> gwarn "${TARGETLIST}"

ok implement ginfo.

> >> That's all i wanted to say about the gnap_scripts at the moment.
> >
> > you say a lot :)
> 
> Hmm... is that good or bad? :)

good :P

> 
> > nice job
> 
> Thanks, unfortunately not what i applied for. :-(
> 
> See you,
>     Philipp

--
gnap-dev@gentoo.org mailing list



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

* Re: [gnap-dev] Some patches for gnap
  2007-07-06 15:08   ` Philipp Riegger
  2007-07-09  7:13     ` josé Alberto Suárez López
@ 2007-07-12 23:49     ` Philipp Riegger
  1 sibling, 0 replies; 13+ messages in thread
From: Philipp Riegger @ 2007-07-12 23:49 UTC (permalink / raw
  To: gnap-dev

On Fri, 2007-07-06 at 18:08 +0300, Philipp Riegger wrote:
> > To improve is ever good :)
> 
> An alternative would be to introduce overlay handling to catalyst, but
> i
> think, we don't want that. :-) 

Catalyst can use overlays. At least ther eis a config option. I still
have to test that. Just for the record...

Philipp

-- 
gnap-dev@gentoo.org mailing list



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

end of thread, other threads:[~2007-07-12 23:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-05 12:53 [gnap-dev] Some patches for gnap Philipp Riegger
2007-07-05 13:03 ` [gnap-dev] 01-split-gnap_make.patch Philipp Riegger
2007-07-05 13:05 ` [gnap-dev] 03-split-gnap_remaster.patch Philipp Riegger
2007-07-05 13:06 ` [gnap-dev] 04-feature-gnap_make-T.patch Philipp Riegger
2007-07-05 13:07 ` [gnap-dev] 05-festure-gnap_overlay-T.patch Philipp Riegger
2007-07-05 13:08 ` [gnap-dev] 06-feature-gnap_remaster-T.patch Philipp Riegger
2007-07-05 13:09 ` [gnap-dev] 07-split-make_tempdir.patch Philipp Riegger
2007-07-05 13:10 ` [gnap-dev] 08-namespace-gnap_shared.patch Philipp Riegger
2007-07-05 13:11 ` [gnap-dev] 09-cleanup-gnap_make.patch Philipp Riegger
2007-07-06  7:40 ` [gnap-dev] Some patches for gnap josé Alberto Suárez López
2007-07-06 15:08   ` Philipp Riegger
2007-07-09  7:13     ` josé Alberto Suárez López
2007-07-12 23:49     ` Philipp Riegger

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