Gentoo Archives: gnap-dev

From: Philipp Riegger <lists@××××××××××××.de>
To: gnap-dev@l.g.o
Subject: [gnap-dev] 05-festure-gnap_overlay-T.patch
Date: Thu, 05 Jul 2007 13:07:35
Message-Id: 44054.130.230.11.107.1183640851.squirrel@my.bawue.net
In Reply to: [gnap-dev] Some patches for gnap by Philipp Riegger
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@g.o mailing list