Gentoo Archives: gnap-dev

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