#! /bin/sh # # lnkpkg # # Shell script to create symbolic links in a user's test release # area, created under the BaBar code system, to the $BFDIST/packages # area. If pkgA uses include files from a package in the test area, # but source in pkgA itself won't be modified, then pkgA can be # rebuilt by adding links in the test area, e.g.: # # ~user/test/pkgA -> $BFDIST/packages/pkgA/V01-00-03 # ~user/test/include/pkgA -> $BFDIST/packages/pkgA/V01-00-03/include # # # Glenn Cooper Nov 1996 # Robert Harris, Jan 13, 1997: Changed $package to $1 to link include correctly # Robert Harris, Jan 13, 1997: Added error handling and diagnostic printout # Glenn Cooper, Jan 24, 1997: Remove (slow!) call to statusrel to get cvsRel # # Function: # # # # # Options: # -f ("force") Overwrite any existing links # # Arguments: # package name # Optional - if present, link to this version; if # not present, link to current # ########################################################################## USAGE="Usage: $0 <-f> [package] [version]" # process options force=0 #amj:FNAL: getopts has replaced getopt as recommended usage on SGI and # DECUnix. Only getopts exists in the cygnus NT system. while getopts f c do case $c in f) force=1;; esac done shift `expr $OPTIND - 1` # check for correct number of arguments if [ "$#" -gt 2 -o "$#" -lt 1 ]; then echo "Error: $0 requires one or two arguments:" echo $USAGE exit 2 fi # check to see whether link already exists if [ -r $1 ]; then if [ $force = 0 ]; then echo "Warning: links for package $1 already exist." echo "To replace these, use the -f option." exit 2 else echo "Replacing links for package $1." fi fi ############################################################### # remove old links if they exist if [ -r $1 ]; then rm -f $1 fi if [ -r include/$1 ]; then rm -f include/$1 fi # create the links to the specified package if [ "$#" -eq 2 ]; then # link to specified version # first check whether there is something to link to if [ -d $BFDIST/packages/$1/$2 ]; then # create the package link... ln -s $BFDIST/packages/$1/$2 $1 # then create the include link if [ -d $BFDIST/packages/$1/$2/$1 ]; then ln -s $BFDIST/packages/$1/$2/$1 include/$1 elif [ -d $BFDIST/packages/$1/$2/include ]; then ln -s $BFDIST/packages/$1/$2/include include/$1 elif [ -d $BFDIST/packages/$1/$2/src ]; then ln -s $BFDIST/packages/$1/$2/src include/$1 else ln -s $BFDIST/packages/$1/$2 include/$1 fi else if [ -d $BFDIST/packages/$1 ]; then echo Error: package $1 version $2 does not exist. Available versions are ls $BFDIST/packages/$1 else echo Error: package $1 does not exist. The release contains ls $BFDIST/packages fi fi elif [ "$#" -eq 1 ]; then # version isn't specified, so use current version if [ -r .current ]; then currentRel=`cat .current` cvsRel=`ls -ld $BFDIST/releases/$currentRel/$1 | awk -F'/' '{print $NF}'` else echo "No version specified, and can't find file .current." echo "Please make sure you are using $0 from the top of \c" echo "your test release area." exit 2 fi if [ "$cvsRel" = "" ]; then echo "Error: version number for $1 in $currentRel not available" exit 2 else echo Release $currentRel uses $1 version $cvsRel, will link to this version. # first create the package link... ln -s $BFDIST/packages/$1/$cvsRel $1 # then create the include link if [ -d $BFDIST/packages/$1/$cvsRel/$1 ]; then ln -s $BFDIST/packages/$1/$cvsRel/$1 include/$1 elif [ -d $BFDIST/packages/$1/$cvsRel/include ]; then ln -s $BFDIST/packages/$1/$cvsRel/include include/$1 elif [ -d $BFDIST/packages/$1/$cvsRel/src ]; then ln -s $BFDIST/packages/$1/$cvsRel/src include/$1 else ln -s $BFDIST/packages/$1/$cvsRel include/$1 fi fi fi