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.62) (envelope-from ) id 1I6R2H-0005zZ-LI for garchives@archives.gentoo.org; Thu, 05 Jul 2007 13:06:18 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.14.0/8.14.0) with SMTP id l65D6AuK005905; Thu, 5 Jul 2007 13:06:10 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 l65D69O7005891 for ; Thu, 5 Jul 2007 13:06:09 GMT Received: from my.bawue.net (imap.bawue.net [193.7.176.64]) by mail.bawue.net (Postfix) with ESMTP id C584FB8EA3 for ; Thu, 5 Jul 2007 15:03:41 +0200 (CEST) Received: from 130.230.11.107 (SquirrelMail authenticated user stoile) by my.bawue.net with HTTP; Thu, 5 Jul 2007 16:03:41 +0300 (EEST) Message-ID: <54140.130.230.11.107.1183640621.squirrel@my.bawue.net> In-Reply-To: <59506.130.230.11.107.1183640031.squirrel@my.bawue.net> References: <59506.130.230.11.107.1183640031.squirrel@my.bawue.net> Date: Thu, 5 Jul 2007 16:03:41 +0300 (EEST) Subject: [gnap-dev] 01-split-gnap_make.patch From: "Philipp Riegger" To: gnap-dev@lists.gentoo.org User-Agent: SquirrelMail/1.4.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo GNAP development X-BeenThere: gnap-dev@gentoo.org Reply-to: gnap-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 Importance: Normal X-Archives-Salt: 8b55c2a6-05aa-4c01-8c55-a2559447c7af X-Archives-Hash: 7c1f99756edc0e2d6de912576affffd0 Index: tools/gnap_shared.sh =================================================================== --- tools/gnap_shared.sh (revision 0) +++ tools/gnap_shared.sh (revision 0) @@ -0,0 +1,79 @@ +GNAPNAME=$(basename "$0") + +case ${GNAPNAME} in + gnap_make ) GNAPPRODUCT="Build";; + * ) 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" + +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} ${*}" +} + +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 "${GNAPPRODUCT} 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 "${GNAPPRODUCT} failed, try ${GNAPNAME} -h for more help" + exit 1 + fi +} + +cleanup() { + gbegin 'Cleaning temporary directories' + if [[ -d "${TEMPDIR}" ]]; then + DIRTOREMOVE="${TEMPDIR}" + TEMPDIR='' + rm -rf "${DIRTOREMOVE}" + gtest $? "Failed to remove ${DIRTOREMOVE}" + else + gtest 0 + fi +} Index: src/gnap_make =================================================================== --- src/gnap_make (revision 52) +++ src/gnap_make (working copy) @@ -1,70 +1,9 @@ #!/bin/bash GNAPVERSION='2.0' -GNAPNAME=$(basename "$0") +source "gnap_shared.sh" 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} ${*}" -} - -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 -} - usage() { echo 'Options:' echo ' -t stage Build stage to execute (or "all")' @@ -80,18 +19,6 @@ echo "Please 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 Index: src/gnap_shared.sh =================================================================== --- src/gnap_shared.sh (revision 0) +++ src/gnap_shared.sh (revision 0) @@ -0,0 +1,79 @@ +GNAPNAME=$(basename "$0") + +case ${GNAPNAME} in + gnap_make ) GNAPPRODUCT="Build";; + * ) 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" + +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} ${*}" +} + +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 "${GNAPPRODUCT} 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 "${GNAPPRODUCT} failed, try ${GNAPNAME} -h for more help" + exit 1 + fi +} + +cleanup() { + 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