#! /bin/sh # # newver # # Shell script to 'create' a new version of software within # the BaBar code system # # Bob Jacobsen Sept 1994 # # Function: # Check in correct directory ($BFDIST/packages/) (*) # Check version does not exist # CVS export the tagged code # Touch all files with the current date # Mark all files read only # # Items with a (*) are not yet implemented # # Options: # -v Tells you the version, then quits. # -p This will be a production version. # This must be explicitly specified, even though -t is not allowed. # -R Passed to cvs to control remote export # -d CVS-root-directory Get package from CVS-root-directory # (same as -d option in cvs) # # Arguments # CVS tag to use # # 19981103 kreymer # UPS declare using $BFDIST only when $PROJECT_DIR/.experiment contains CDF # # 19981208 Amundson # Added -d option. # Special case for using newver on SoftRelTools itself: # SRTsite.(c)sh and arch_spec_site.mk files are now copied from the # release "current" iff they exist. ############################################################################### # process options prod=0 cvsOpt="" otherServer=0 while getopts tpvRd: c do case $c in p) prod=1; test=0;; R) cvsOpt="-R";; d) otherServer=1; serverName=$OPTARG;; esac done shift `expr $OPTIND - 1` if [ "$otherServer" -eq 1 ]; then cvsOpt1="-d $serverName" fi if [ "$prod" -ne 1 ]; then echo "-p option is currently required" exit 2 fi # check for correct number of arguments if [ "$#" -ne 1 ]; then echo "One argument required" exit 2 fi newrel=$1 if [ -w $newrel ]; then echo "New version directory $2 already exists." # is exists and not writable, will get errors soon enough exit 2 fi # get package name from current directory name # (A. Kreymer - why do we not use basename `pwd` ?) line=`pwd` OIFS=$IFS IFS=/ set $line IFS=$OIFS shiftcount=`expr $# - 1` shift $shiftcount package=$1 echo " " echo "Package name is $package " # find previous version prev_vers=`ls -t -d -1 * | head -1` export prev_vers # extract cvs $cvsOpt1 $cvsOpt export -r $newrel -d $newrel $package cvserr=$? if [ "$cvserr" != "0" ]; then echo "cvs export failed. newrel aborted." exit 1; fi # copy dab files from previous versions dab_files=`/bin/sh -c "ls $prev_vers/*.dab 2>/dev/null"` if [ "$dab_files" ]; then echo "copying *.dab files from previous versions $vers of package" cp $prev_vers/*.dab $newrel fi # touch all find $newrel -exec touch {} \; # find out if ups is available and if so declare new version if [ "$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 $RUN2_PRODUCTS/.upsfiles/dbconfig, # per D0 usage. if [ -r "$BFDIST/releases/$BFCURRENT/.experiment" -a \ "`head -1 $BFDIST/releases/$BFCURRENT/.experiment`" = "CDF" ] then absref='${BFDIST}/' else absref='' fi $UPS_DIR/bin/ups declare \ -r ${absref}packages/$package/$newrel \ -z ${RUN2_PRODUCTS} \ -f NULL ${havetable} \ $package $newrel fi # If we are making a new version of SoftRelTools and # SRTsite.(c)sh exists in the release "current", it is copied to the # new version. found_site_files=false if [ "$package" = "SoftRelTools" ]; then if [ -f $BFDIST/packages/SoftRelTools/current/config/SRTsite.sh ]; then found_site_files=true cp $BFDIST/packages/SoftRelTools/current/config/SRTsite.sh $newrel/config fi if [ -f $BFDIST/packages/SoftRelTools/current/config/SRTsite.csh ]; then found_site_files=true cp $BFDIST/packages/SoftRelTools/current/config/SRTsite.csh $newrel/config fi if [ -f $BFDIST/packages/SoftRelTools/current/config/arch_spec_site.mk ]; then found_site_files=true cp $BFDIST/packages/SoftRelTools/current/config/arch_spec_site.mk $newrel/config fi if [ "$found_site_files" = "true" ]; then echo "Local files found in" echo " $BFDIST/packages/SoftRelTools/current/config" echo "copied to new version." echo "Remember to run runme.sh after renaming directory." fi fi # set permissions find $newrel ! -type d -exec chmod 444 {} \; find $newrel -type d -exec chmod 555 {} \; if [ "$found_site_files" = "true" ]; then chmod +x $newrel/install/runme.sh fi unset prev_vers