#!/bin/sh - # # newrel # # Shell script to 'create' a new release of software within # the BaBar code system # # 19981122 kreymer@fnal.gov # # corrected syntax of two '=' tests, arguments must be strings, were not # # "${default}" = "0" was default = 0 # ... = "NT" was ... = NT # # Function for a production release: # # Create the destination directory # Create the standard subdirectories # Copy the files that are normally created in bin and lib # Store the previous release in .current # Foreach package subdirectory: # If -f specified, use version specified in file; # otherwise, prompt user for choice of package version (or location) # Make link to appropriate package and include directories # Create work directory # # # Options: # -v Tells you the version, then quits. # -p This will be a production release. # -t This will be a test release, as small as possible # (symbolic links to libraries, etc). # -l Skip tar copy of libraries. # -f Package versions are specified in , with format: # pkgA V00-01-02 # pkgB V00-02-03 # ... ... # -1, -2, -3, ..., -9 Put the -p release in AFSREL0n # (for use with the SLAC multi-volume AFS weirdness) # # Arguments: # Number/name of previous release to use as base # Used as directory name # # amj:FNAL:9/12/97 need to handle subdirectories of arbitrary depth # modify chmod and rm calls to handle this. # ################################################################ # Function newrel_link # # Used to create links to the appropriate version of each package. # Implement as a function so we can reuse the code for separate cases when: # we're using an input file, and this package is in the file; # we're using an input file, but this package isn't in the file; or # we're not using an input file. # newrel_link () { # link to the package directory ln -s ../../packages/$package/$newver $package chmod 555 $package # create the include link if [ -d $package/$package ]; then ln -s ../$package/$package include/$package elif [ -d $package/include ]; then ln -s ../$package/include include/$package elif [ -d $package/src ]; then ln -s ../$package/src include/$package else # This message is common and isn't useful, so don't print it (G. Cooper) # echo " $package has no explicit include subdirectory - using directory." ln -s ../$package/ include/$package fi if [ "${default}" = "0" ]; then # see if need to delete objects (may have already done so) # can only use the copied objects if all files in the new package # are newer than the youngest library/executable (i.e. all compiles # and links are forced to make) if [ "$oldest" ]; then back=$newreldir if [ "`(cd $package; find . ! -type d ! -newer $back/$oldest -print | head -1)`" ]; then echo "Package $package is too old - deleting binaries and objects." #amj:FNAL:9/12/97 need to handle subdirectories of arbitrary depth # might as well delete all the $BFARCH directories too. chmod -R 777 bin/*/* rm -r bin/*/* chmod -R 777 lib/*/* rm -r lib/*/* for lib in tmp/*/* do chmod -R 777 $lib rm -r $lib done oldest="" fi fi fi } # End of function newrel_link # Function read_settings # # read_settings allows customization the directories created by # newrel -t. It will source any/all of three files, # $SRT_HOME/config/srtrc, $HOME/.srtrc, and ./.srtrc, in that order. The # file should contain the line # stddirs=" dir1 dir2 dir3 " # to override the default, # stddirs=" tmp bin lib include man man/man1 doc results ups " # for unix machines, or # stddirs=" tmp bin lib include man man/man1 doc results ide ups " # for NT. # # Symbolic links may be substituted for directories as in the following # stddirs=" tmp bin>/tmp/bin lib include man doc results ups " # which will make bin a symbolic link to /tmp/bin, creating /tmp/bin if # necessary. read_settings () { if [ -n "$SRT_HOME" ]; then if [ -f "$SRT_HOME/config/srtrc" ]; then . "$SRT_HOME/config/srtrc" echo "read site srtrc" fi fi if [ -f "$HOME/.srtrc" ]; then . "$HOME/.srtrc" echo "read user srtrc" fi if [ -f "./.srtrc" ]; then . "./.srtrc" echo "read directory srtrc" fi } # # Main part of script # # process options test=0 prod=0 nolib=0 usefile=0 #amj:FNAL: getopts has replaced getopt as recommended usage on SGI and # DECUnix. Only getopts exists in the cygnus NT system. while getopts tpvlf: c do case $c in p) prod=1; test=0;; t) prod=0; test=1;; l) nolib=1;; f) usefile=1; filename="$OPTARG";; esac done shift `expr $OPTIND - 1` # check for correct number of arguments if [ "$#" -ne 2 ]; then echo "Two arguments required; found $#" exit 2 fi # check for release number only (i.e. not a path name) in # previous and next release names iff production version if [ "$prod" -eq 1 ]; then if (echo $1 $2 | grep \/ >/dev/null) ; then echo Do not use path names for production releases! exit 3 fi fi # -f should NOT be used with -t if [ $test -eq 1 ]; then if [ $usefile -eq 1 ]; then echo -t and -f $filename are incompatible. exit 3 fi fi # If -f option is used, make sure we can find the file if [ $usefile -eq 1 ]; then if (echo "$filename" | grep -v \/ >/dev/null) then filename=$BFDIST/releases/$filename fi if [ ! -r $filename ]; then echo "Sorry, I can't find file $filename." echo "Please use the full path name, or put the file in $BFDIST/releases," echo "or try again without the -f option." exit 3 else echo "Found file $filename." fi fi ############################################################### # check consistency of arguments newrel=$2 if [ "$prod" -eq 1 ]; then newreldir=$BFDIST/releases/$2 else newreldir=$2 fi if [ -w $newreldir ]; then echo "New directory $newreldir already exists." # is exists and not writable, will get errors soon enough exit 2 fi # find the previous release if [ "$test" -eq 1 ]; then if [ -d $1 ]; then echo "Previous release found in current directory" prevrel=$1 elif [ ! -d $BFDIST/releases/$1 ]; then echo "Could not find previous release" $BFDIST/releases/$1 exit 3 else prevrel=$BFDIST/releases/$1 fi elif [ "$prod" -eq 1 ]; then if [ ! -d $BFDIST/releases/$1 ]; then echo "Could not find previous release" $BFDIST/releases/$1 exit 3 else prevrel=$BFDIST/releases/$1 fi else echo "Either '-t' or '-p' must be specified" exit 100 fi ################################################################ # end of checks # the spaces around the file name lists are needed stdfiles=" GNUmakefile ReleaseLog " stddirs=" tmp bin lib include man man/man1 doc results ups " # jfa 9/98: read settings files if they exist read_settings # create the release directory mkdir $newreldir cd $newreldir # jfa 9/98: obsolete # # copy the standard files # # for var in $stddirs # do # mkdir $var # done # mkdir man/man1 # jfa 9/98: make directories and/or links for var in $stddirs do possible_pair=`echo "$var" | sed -e "s/>/ /"` if [ "$var" = "$possible_pair" ]; then # make a directory mkdir $var else # make a link, creating the directory if necessary link=`echo "$var" | sed -e "s/\(.*\)>.*/\1/"` real_dir=`echo "$var" | sed -e "s/.*>\(.*\)/\1/"` if [ ! -d $real_dir ]; then mkdir -p $real_dir fi ln -s $real_dir $link fi done # test release stops here if [ "$test" -eq 1 ]; then cp $prevrel/SoftRelTools/GNUmakefile.top GNUmakefile # make experiment file -LSK cp $prevrel/.experiment .experiment newpwd=`pwd` cd $BFDIST/releases/$1 line=`/bin/pwd` OIFS=$IFS IFS=/ set $line IFS=$OIFS shiftcount=`expr $# - 1` shift $shiftcount cd $newpwd echo $1 > .current echo "next, add pkg, checkout or ln -s to your packages, then gmake installdirs" exit fi # production release: start creating links to packages # Note that a screwed up previous_release is _not_ checked for, # but should be caught by the auditrel on this release at the end. #FNAL_GC 9-Apr-1998 # First, store the *new* release in .current, so $BFCURRENT will point to # the new release and not the old one, e.g. when searching for includes. echo $2 > .current # copy libraries and binaries for all architectures from previous # production release if [ "$nolib" -eq 0 ]; then ( cd $prevrel; tar cBf - bin lib tmp) | tar xBf - else cp $prevrel/* . fi # make libraries and temporary files group writeable until freezerel chmod -R ug+rw,o+r,o-w * # find the oldest file in the libraries and binaries #oldest=`ls -t bin/*/* lib/*/* tmp/*/*/* | head -1` # removed reference to tmp area because of arg list problem (R. Harris) oldest=`ls -t bin/*/* lib/*/* | head -1` # Now make the links to new packages # If -f option specified, install packages without interactive input. if [ $usefile -eq 1 ]; then # # Do only packages listed in $filename, not everything in $prevrel. # cat $filename | while read package newver do if [ "$newver" = "delete" ]; then echo "Deleting package $package from release." else newrel_link echo "$package: using requested version $newver." if [ -r $prevrel/$package ]; then # Print message if package was in base release with a different version oldver=`ls -l $prevrel/$package | awk -F/ '{print $NF}'` if [ "$newver" != "$oldver" ]; then echo " Older version exists - $oldver." fi # Print message if a newer version of package exists mostrecent=`ls -t $BFDIST/packages/$package | head -1` if [ "$newver" != "$mostrecent" ]; then echo " Newer version exists - $mostrecent." fi else # Print message that this package is new since base release echo " Completely new package." fi # [ -r $prevrel/$package ] echo "" # Add a newline, since we suppressed them above fi # [ "$newver" = "delete" ] done else # If not using -f option, ask user about each package for var in $prevrel/* do # the following lines set $1 to the last part of the pathname OIFS=$IFS IFS=/ set $var IFS=$OIFS shiftcount=`expr $# - 1` shift $shiftcount package=$1 # Skip files and dirs that aren't packages: GNUmakefile, bin, etc. if (echo "$stdfiles $stddirs" | grep -v " $package " >/dev/null) then # form a relative link to the production package line=`ls -lt $prevrel/$package` OIFS=$IFS IFS=/ set $line IFS=$OIFS shiftcount=`expr $# - 1` shift $shiftcount version=$1 mostrecent=`ls -t $BFDIST/packages/$package | head -1` if [ "$version" != "$mostrecent" ]; then echo "*** Version $mostrecent of $package is newer than $version" fi echo -n "Override version $version for package $package (return for default): " read newver # no input implies use the default default=0 if [ ! "$newver" ]; then newver=$version default=1 fi # user override - loop until valid until [ -d ../../packages/$package/$newver ]; do echo -n "$package/$newver not found - try again:" read newver if [ ! "$newver" ]; then newver=$version fi done # make the links newrel_link fi done # End of loop when not using file input fi # copy the makefile from the SoftRelTools directory cp SoftRelTools/GNUmakefile.top GNUmakefile chmod 444 GNUmakefile # make experiment file -LSK cp $prevrel/.experiment .experiment # make ups directory -LSK if [ -d $prevrel/ups ]; then echo "Making ups directory" cp $prevrel/ups/* ups fi # create log of activity echo " Creating release" $release "in " `pwd` > ReleaseLog echo " on " `date` >> ReleaseLog echo " by " `whoami` " at " `hostname` >> ReleaseLog echo >> ReleaseLog echo "-------------------------------------------" >> ReleaseLog ls -lt >> ReleaseLog echo "-------------------------------------------" >> ReleaseLog printenv >> ReleaseLog echo "===========================================" >> ReleaseLog # if release history area exists, copy log there and create a package list file # this way when we delete the release, there will still be some history of it. if [ -d $BFDIST/relhistory ]; then echo "Copying ReleaseLog to relhistory area" mkdir $BFDIST/relhistory/$newrel cp ReleaseLog $BFDIST/relhistory/$newrel/ReleaseLog echo "Making PackageList via statusrel for relhistory area" statusrel -p $newrel > $BFDIST/relhistory/$newrel/PackageList fi echo echo "Production version $newrel created. On each architecture, now do: " echo " gmake installdirs" echo " gmake all" echo "from the release directory."