From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.67) (envelope-from <gnap-dev+bounces-50-garchives=archives.gentoo.org@gentoo.org>) id 1IGxL1-0000vC-GV for garchives@archives.gentoo.org; Fri, 03 Aug 2007 13:37:08 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.14.0/8.14.0) with SMTP id l73Db3cT027182; Fri, 3 Aug 2007 13:37:03 GMT Received: from mail.bawue.net (phoenix.bawue.net [193.7.176.60]) by robin.gentoo.org (8.14.0/8.14.0) with ESMTP id l73Db23h027174 for <gnap-dev@lists.gentoo.org>; Fri, 3 Aug 2007 13:37:02 GMT Received: from [193.166.89.200] (b136a.mtalo.tontut.fi [193.166.89.200]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mail.bawue.net (Postfix) with ESMTP id 7362A8630E for <gnap-dev@lists.gentoo.org>; Fri, 3 Aug 2007 15:32:59 +0200 (CEST) Subject: [gnap-dev] [PATCH 2/4] GNAP split From: Philipp Riegger <lists@anderedomain.de> To: gnap-dev@lists.gentoo.org In-Reply-To: <1186146995.10651.18.camel@b136a> References: <1186146995.10651.18.camel@b136a> Content-Type: text/plain Date: Fri, 03 Aug 2007 16:32:56 +0300 Message-Id: <1186147976.10651.29.camel@b136a> Precedence: bulk List-Post: <mailto:gnap-dev@lists.gentoo.org> List-Help: <mailto:gnap-dev+help@gentoo.org> List-Unsubscribe: <mailto:gnap-dev+unsubscribe@gentoo.org> List-Subscribe: <mailto:gnap-dev+subscribe@gentoo.org> List-Id: Gentoo GNAP development <gnap-dev.gentoo.org> X-BeenThere: gnap-dev@gentoo.org Reply-to: gnap-dev@lists.gentoo.org Mime-Version: 1.0 X-Mailer: Evolution 2.10.2 Content-Transfer-Encoding: 7bit X-Archives-Salt: 39a351de-a074-4e81-bd3b-0b919500884d X-Archives-Hash: 298450830e1e421b4fbaf58f8fd70a7d 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