Gentoo Archives: gnap-dev

From: Philipp Riegger <lists@××××××××××××.de>
To: gnap-dev@l.g.o
Subject: [gnap-dev] 02-split-gnap_overlay.patch
Date: Thu, 05 Jul 2007 13:06:28
Message-Id: 44037.130.230.11.107.1183640686.squirrel@my.bawue.net
Index: tools/gnap_shared.sh
===================================================================
--- tools/gnap_shared.sh	(revision 53)
+++ tools/gnap_shared.sh	(working copy)
@@ -1,15 +1,20 @@
 GNAPNAME=$(basename "$0")

 case ${GNAPNAME} in
-	gnap_make ) GNAPPRODUCT="Build";;
-	* )         GNAPPRODUCT="Something";;
+	gnap_make )    GNAPPRODUCT="Build";;
+	gnap_overlay ) GNAPPRODUCT="Overlay";;
+	* )            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"
+GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
+GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"

+LOOP=''
+
 G=$'\e[32;01m'
 B=$'\e[31;01m'
 N=$'\e[0m'
@@ -67,6 +72,11 @@
 }

 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}"
Index: tools/gnap_overlay
===================================================================
--- tools/gnap_overlay	(revision 52)
+++ tools/gnap_overlay	(working copy)
@@ -1,75 +1,11 @@
 #!/bin/bash
 VERSION='2.0'

-GNAPNAME=$(basename "$0")
+source "gnap_shared.sh"
 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} ${*}"
-}
-
-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
-
-	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
-}
-
 usage() {
 	echo
     echo 'Usage:'
@@ -102,23 +38,6 @@
     echo "Please 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
Index: src/gnap_shared.sh
===================================================================
--- src/gnap_shared.sh	(revision 53)
+++ src/gnap_shared.sh	(working copy)
@@ -1,15 +1,20 @@
 GNAPNAME=$(basename "$0")

 case ${GNAPNAME} in
-	gnap_make ) GNAPPRODUCT="Build";;
-	* )         GNAPPRODUCT="Something";;
+	gnap_make )    GNAPPRODUCT="Build";;
+	gnap_overlay ) GNAPPRODUCT="Overlay";;
+	* )            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"
+GNAPCORE="${GNAPLIBDIR}/gnap-core.tar"
+GNAPMBR="${GNAPLIBDIR}/mbr/mbr.bin"

+LOOP=''
+
 G=$'\e[32;01m'
 B=$'\e[31;01m'
 N=$'\e[0m'
@@ -67,6 +72,11 @@
 }

 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}"

-- 
gnap-dev@g.o mailing list