#! /bin/sh # # addpkg # # Shell script to add a package to an existing test release within # the BaBar code system # # Bob Jacobsen Sept 1994 # # Function: # # # # # Options: # -h Take the CVS HEAD version # -d CVS-root-directory Get package from CVS-root-directory # (same as -d option in cvs) # # Arguments: # package name or # / for subpackages # # Optional - if present, CVS checkout the package # using this tag # # Note: Before this version "addpkg foo" would give you the # the CVS HEAD revision. From here on, "addpkg -h foo" # gets the HEAD, and "addpkg foo" gets the version that # was used to make the current revision (from looking # at the .current file made by newrel -t). Use "cvs update -A" # to get HEAD after the fact. # # BobJ May 1996 - removed the -R option, as RCVS no longer # supported by SLAC # # JFA Oct 1998 - added -d and subpackage options # ################################################################ # process options ################################################################ cvsco () { args=`echo $@ | sed 's/\(.*\) .*/\1/'` # # standard cvs co # cvs $@ # # co base files if checking out a sub module # shift `expr $# - 1` top_package=`dirname $1` while [ "$top_package" != "." ]; do cvs $args -l $top_package; top_package=`dirname $top_package` done } ################################################################ checkout=0 #FNAL_GC # prune empty directories, e.g., deleted ones #FNAL_END checkoutOpt="-P" head=0 otherServer=0 cvsOpt="" #amj:FNAL: getopts has replaced getopt as recommended usage on SGI and # DECUnix. Only getopts exists in the cygnus NT system. while getopts vhd: c do case $c in h) head=1;; d) otherServer=1; serverName=$OPTARG;; esac done shift `expr $OPTIND - 1` if [ "$otherServer" -eq 1 ]; then cvsOpt1="-d $serverName" fi # check for correct number of arguments if [ "$#" -gt 2 -o "$#" -lt 1 ]; then echo "One or two arguments required" echo "(You gave me $#)" exit 2 fi ############################################################### # check consistency of arguments if [ "$#" -eq 2 -a -w $1 ]; then echo "New package subdirectory $1 already exists." # is exists and not writable, will get errors soon enough exit 2 fi if [ "$#" -eq 1 -a ! -w $1 ]; then if [ $head = 1 ]; then echo "Taking $1 from head of CVS main branch" # is exists and not writable, will get errors soon enough cvsco $cvsOpt1 checkout $checkoutOpt $1 else # find the version in the .current release currentRel=`cat .current` cvsRel=`statusrel -p $currentRel | grep "^$1 " | cut -f2 -d' '` if [ "$cvsRel" = "" ]; then echo "Version number for $1 in $currentRel not available (is $currentRel older than 0.4.2?)" echo "Will check out most recent CVS contents for $1" cvsco $cvsOpt1 checkout $checkoutOpt $1 elif [ "$currentRel" = "development" ]; then echo "Current release based on development; will check out most recent version of $1" cvsco $cvsOpt1 checkout $checkoutOpt $1 else echo Release $currentRel uses $1 version $cvsRel, will check that out cvsco $cvsOpt1 checkout $checkoutOpt -r $cvsRel $1 fi fi fi # if requested, extract the tagged package if [ "$#" -eq 2 ]; then cvsco $cvsOpt1 checkout $checkoutOpt -r $2 $1 fi package=$1 include_ln=`dirname $1` if [ "x$include_ln" = "x." ]; then include_ln=$package fi # create the include link if [ -r include/$include_ln ]; then rm -f include/$include_ln fi if [ -d $include_ln/$include_ln ]; then ln -s ../$include_ln/$include_ln include/$include_ln elif [ -d $include_ln/include ]; then ln -s ../$include_ln/include include/$include_ln elif [ -d $include_ln/src ]; then ln -s ../$include_ln/src include/$include_ln else ln -s ../$include_ln/ include/$include_ln fi gmake installtopdirs top_package=$package next_top_package=`dirname $top_package` while [ "$next_top_package" != "." ]; do top_package=$next_top_package next_top_package=`dirname $top_package` done gmake $top_package.installtmpdir #gmake ${include_ln}.check # warn about possible Make time problems # find the newest file in the libraries and binaries newestobj=`ls -t bin/*/* lib/*/* 2>/dev/null | head -1` # see if need to delete objects (may have already done so) # can only use the existing objects iff all files in the new package # are newer than the youngest library/executable (i.e. all compiles # and links are forced to make) if [ "$newestobj" ]; then back=`/bin/pwd` if [ "`(cd $package; find . ! -type d ! -newer $back/$newestobj -print | head -1)`" ]; then echo "Package $package contains files that are older" echo "than libraries or binaries you have built. You should delete" echo "the existing binaries and libraries so that gmake can" echo "reliably make a clean copy. Use 'rm -r lib bin tmp'," echo "then gmake installdirs." fi fi