#!/bin/sh # newver script_defaults () { expected_args=2 version_type=frozen head=false } usage () { echo "usage: newver [options] " echo echo "newver adds a new version of a package to a distribution." echo echo "options:" echo " -?, --help: prints this usage message" echo " -p, -r, --frozen: create a frozen version (default)" echo " --development: create a development version" echo " -h, --head: add the head version of " echo " head versions default to development" echo " -d use for the cvsroot" echo " -Q, --quiet: perform cvs actions quietly" exit } process_args () { while getopts "?prhQRd:-:" opt; do if [ "$opt" = "-" ]; then opt=$OPTARG fi case $opt in \? | help) usage ;; p | r | frozen) release_type=frozen ;; development) release_type=development ;; h | head) head=true expected_args=1 release_type=development ;; Q | quiet) cvs_extra_args="$cvs_extra_args -Q" ;; d) cvs_server_args="-d $OPTARG" ;; *) usage ;; esac done shift `expr $OPTIND - 1` if [ "$#" -ne "$expected_args" ]; then usage fi package=$1 if [ "$head" = "true" ]; then tag="HEAD" else tag=$2 fi if [ "$tag" = "HEAD" ]; then release_type=development fi } fail () { echo "$1" >&2 echo "$prog_name failed." >&2 exit 1 } actions () { target_dir=$SRT_DIST/packages/$package if [ -d "$target_dir/$tag" ]; then fail "The \"$package\" version \"$tag\" already exists in $SRT_DIST." fi if [ ! -d "$target_dir" ]; then mkdir "$target_dir" fi # if [ ! -w "$target_dir" ]; then # fail "You do not have write permission in \"$target_dir\"." # fi cd $target_dir echo "Adding version $tag to \"$package\" in $SRT_DIST." if [ "$head" = "true" ]; then cvs_tag_args="" else cvs_tag_args="-r $tag" fi if [ -z "$cvs_server_args" ]; then if [ -f "$SRT_DIST/packages/$package/cvsroot" ]; then echo "using package special cvs server" cvs_server_args="-d `cat $SRT_DIST/packages/$package/cvsroot`" fi fi if [ "$release_type" = "development" ]; then cvs_action=checkout else cvs_action=export fi cvs $cvs_extra_args $cvs_server_args $cvs_action $cvs_tag_args -d $tag $package cvs_error=$? if [ "$cvs_error" != "0" ]; then fail "cvs checkout failed." fi newrel=$tag # find out if ups is available and if so declare new version if test "$UPS_DIR" != "" then # assume ups V4 if [ -f $newrel/ups/${package}.table ] then havetable="-M ups -m ${package}.table" else havetable="" fi # Use absolute path only for the CDF experiment. # Otherwise, declare relative to the PROD_DIR_PREFIX # contained in ${SRT_DIST}/upsdb/.upsfiles/dbconfig, # per D0 usage. if [ -f "${SRT_PUBLIC_CONTEXT}/.experiment" -a \ "`head -1 ${SRT_PUBLIC_CONTEXT}/.experiment`" = "CDF" ] then absref='${SRT_DIST}/' else absref='' fi $UPS_DIR/bin/ups declare \ -r ${absref}packages/$package/$newrel \ -z ${SRT_DIST}/upsdb \ -f NULL ${havetable} \ $package $newrel fi } main () { script_defaults process_args $* actions } prog_name=newver if [ -f "$SRT_PRIVATE_CONTEXT/SRT_$SRT_PROJECT/special/scripts/$prog_name" ]; then . "$SRT_PRIVATE_CONTEXT/SRT_$SRT_PROJECT/special/scripts/$prog_name" elif [ -f "$SRT_PUBLIC_CONTEXT/SRT_$SRT_PROJECT/special/scripts/$prog_name" ]; then . "$SRT_PUBLIC_CONTEXT/SRT_$SRT_PROJECT/special/scripts/$prog_name" fi main $*