From 4dbb3fd5bd5c937a9e737ba3934e09253bd36433 Mon Sep 17 00:00:00 2001 From: thierry Date: Tue, 6 Mar 2007 19:46:06 +0000 Subject: [PATCH] review base naming --- scripts/nightly-build.sh | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/scripts/nightly-build.sh b/scripts/nightly-build.sh index c281cb7..f33ab72 100755 --- a/scripts/nightly-build.sh +++ b/scripts/nightly-build.sh @@ -12,7 +12,7 @@ TAG=HEAD CHROOTDIR=/root/bin # plc chroot runs in UTC -date=$(date -u +'%Y.%m.%d') +DATE=$(date -u +'%Y.%m.%d') ### in the root context function do_chroot () { @@ -37,7 +37,6 @@ function success () { } function create_base () { - BASE=${TAG/HEAD/`date +%Y.%m.%d`} i= while ! mkdir ${BASE}${i} 2>/dev/null ; do [ -z ${i} ] && BASE=${BASE}. @@ -85,6 +84,8 @@ function show_env () { echo BASE=$BASE echo TAG=$TAG echo DISTRO=$DISTRO + echo MAKEVARS="${MAKEVARS[@]}" + echo MAKEOPTS="${MAKEOPTS[@]}" } function usage () { @@ -92,11 +93,13 @@ function usage () { echo "This is revision $REVISION" echo "Supported options" echo " -v verbose" + echo " -b BASE" + echo " -u : uses directory given as BASE as is, even if already exists" + echo " -e : exits (does nothing) if BASE already exists" + echo " -f DISTRO" echo " -d CVSROOT" echo " -r TAG" echo " -m MAILTO" - echo " -f DISTRO" - echo " -b BASE" echo " -s MAKEVAR=value - spaces in value are not supported" echo " -n passed to make" exit 1 @@ -107,9 +110,9 @@ function main () { if [ -d /plc/devel/data ] ; then do_chroot "$@" else + while getopts "vd:r:m:f:b:s:uenh" opt ; do MAKEVARS=() MAKEOPTS=() - while getopts "vd:r:m:f:b:s:nh" opt ; do case $opt in v) set -x ;; d) CVSROOT=$OPTARG ;; @@ -117,6 +120,8 @@ function main () { m) MAILTO=$OPTARG ;; f) DISTRO=$OPTARG ;; b) BASE=$OPTARG ;; + u) USEOLD=true ;; + e) EXITIFOLD=true ;; s) MAKEVARS=(${MAKEVARS[@]} $OPTARG) ;; n) MAILTO="" ; MAKEOPTS=(${MAKEOPTS[@]} -n) ;; h|*) usage ;; @@ -127,12 +132,24 @@ function main () { MAKETARGETS="$@" cd $ROOT - ### determine BASE - # if specified, use it, otherwise create from date - if [ -z "$BASE" ] ; then - create_base - else + ### set BASE if unspecified, from TAG + [ -z "$BASE" ] && BASE=${TAG/HEAD/${DATE}} + + if [ -n "$EXITIFOLD" -a -d "$BASE" ] ; then + echo "$COMMAND: -e : exits on existing base directory $BASE" + BUILD=$ROOT/$BASE + failure + exit 1 + fi + + if [ -n "$USEOLD" ] ; then use_base $BASE + else + # base is not the date, it's probably a tag or whatever + if [ "$BASE" != "$DATE" ] ; then + [ -d "$BASE" ] && BASE=${BASE}-${DATE} + fi + create_base fi BUILD=$ROOT/$BASE -- 2.47.0