public inbox for gnap-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Philipp Riegger <lists@anderedomain.de>
To: gnap-dev@lists.gentoo.org
Subject: [gnap-dev] [PATCH 2/4] GNAP split
Date: Fri, 03 Aug 2007 16:32:56 +0300	[thread overview]
Message-ID: <1186147976.10651.29.camel@b136a> (raw)
In-Reply-To: <1186146995.10651.18.camel@b136a>

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@gentoo.org mailing list



  parent reply	other threads:[~2007-08-03 13:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-03 13:16 [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
2007-08-03 13:26 ` [gnap-dev] [PATCH 1/4] GNAP cleanup Philipp Riegger
2007-08-03 13:32 ` Philipp Riegger [this message]
2007-08-03 13:37 ` [gnap-dev] [PATCH 3/4] GNAP namespace Philipp Riegger
2007-08-03 13:53 ` [gnap-dev] [PATCH 4/4] GNAP environment Philipp Riegger
2007-08-03 13:57 ` [gnap-dev] [PATCH 0/4] GNAP improvements, probably for 2.1 Philipp Riegger
2007-08-03 14:01 ` Philipp Riegger
2007-08-03 14:02 ` Philipp Riegger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1186147976.10651.29.camel@b136a \
    --to=lists@anderedomain.de \
    --cc=gnap-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox