Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gnap-dev
Navigation:
Lists: gnap-dev: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gnap-dev@g.o
From: Philipp Riegger <lists@...>
Subject: [PATCH 2/4] GNAP split
Date: Fri, 03 Aug 2007 16:32:56 +0300
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@g.o mailing list


References:
[PATCH 0/4] GNAP improvements, probably for 2.1
-- Philipp Riegger
Navigation:
Lists: gnap-dev: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
[PATCH 1/4] GNAP cleanup
Next by thread:
[PATCH 3/4] GNAP namespace
Previous by date:
[PATCH 1/4] GNAP cleanup
Next by date:
[PATCH 3/4] GNAP namespace


Updated Jun 17, 2009

Summary: Archive of the gnap-dev mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.