#! /bin/sh # Hey, Emacs, this is a -*- shell-script -*- ! # $Id: msrt,v 1.86 2009/11/17 23:04:52 rhatcher Exp $ # # Bootstrap and manage MINOSSOFT SRT releases. # Run "msrt" with out args to get help. # # contact: bv@bnl.gov # Some hard coded values unlikely to change very frequently: srt_cvsroot=":pserver:anonymous@cdcvs.fnal.gov:/srtcvs" cvsroot_pserver=":pserver:anonymous@minoscvs.fnal.gov:/cvs/minoscvs/rep1" cvsroot_ssh="minoscvs@minoscvs.fnal.gov:/cvs/minoscvs/rep1" ######################################################################## main () { if [ -n "$GATEWAY_INTERFACE" ] ; then lt="<" gt=">" else lt="<" gt=">" fi max_make_jobs=1 while true ; do case "$1" in -D) debug=yes ;; -v) verbose=yes ;; -l) logit=yes ;; -e) user_env=yes ;; -d) use_distcc=yes ;; -c) use_ccache=yes ;; -j) max_make_jobs=$2 ; shift ;; *) break;; esac shift done if [ -n "$debug" ] ; then set -x env fi if [ -f $HOME/.msrtrc ] ; then . $HOME/.msrtrc fi if [ -n "$verbose" ] ; then MINOS_VERBOSE=yes export MINOS_VERBOSE fi if [ -n "$logit" ] ; then USE_LOG_DIR=yes export USE_LOG_DIR fi srt_qual="$SRT_QUAL" if [ -n "$use_ccache" ] ; then srt_qual="ccache${srt_qual:+,$srt_qual}" fi if [ -n "$use_distcc" ] ; then srt_qual="distcc${srt_qual:+,$srt_qual}" if [ -z "$DISTCC_HOSTS" ] ; then DISTCC_HOSTS="localhost" fi fi if [ -n "$srt_qual" ] ; then make_flags="SRT_QUAL=$srt_qual $make_flags" fi if [ $max_make_jobs -gt 1 ] ; then if [ -z "$PARALLEL" -a -z "$PARALLEL_TOP" ] ; then # MINOSSOFT Midad and OnlineUtil don't build (consistently) when # using PARALLEL (intrapackage) builds # export PARALLEL=yes export PARALLEL_TOP=yes fi if [ -n "$PARALLEL" ] ; then make_flags="PARALLEL=yes $make_flags" fi if [ -n "$PARALLEL_TOP" ] ; then make_flags="PARALLEL_TOP=yes $make_flags" fi make_flags="-j $max_make_jobs $make_flags" # On Darwin we need to put a throttle on things via MAXLOAD platform=`uname` if [ $platform = "Darwin" ] ; then make_flags="$make_flags MAXLOAD=$max_make_jobs" fi fi cmd=$1 shift case $cmd in version) echo "\$Revision: 1.86 $" | sed -e 's/Revision://' -e 's/\$//g' exit ;; bootstrap) # bootstrap onto a virgin system msrt_bootstrap $@ ;; template) # generate setup files msrt_template $@ ;; release) # create a release msrt_release $@ ;; build) # build an existing release msrt_build $@ ;; update) # update an existing release msrt_update $@ ;; validate) # build and run validation code msrt_validate $@ ;; addpkg) # add a package to and release msrt_addpkg $@ ;; clean) # clean an existing release msrt_clean $@ ;; prune) # prune a release and associated pkgs msrt_prune $@ ;; purge) # remove uneeded files in tmp dirs msrt_purge $@ ;; migrate) # migrate CVSROOT msrt_migrate $@ ;; help) # print a long help message msrt_help ;; testing) # internal msrt_testing $@ ;; snapshot) # Do snapshot (SYY-MM-DD) tagging package file creation msrt_snapshot $@ ;; branchtag) # Do branch (RX.Y) tagging package file creation msrt_branchtag $@ ;; frozentag) # Do frozen (RX.Y.Z) tagging package file creation msrt_frozentag $@ ;; proxy) # Resolve .proxy files msrt_proxy $@ ;; testrel) # Create a test release msrt_testrel $@ ;; *) # print a short help message msrt_usage ;; esac } msrt_usage () { echo "usage: msrt [options] ${lt}command${gt} [command options]" echo " msrt help" } msrt_synopsis () { echo "SYNOPSIS" echo " msrt [options] ${lt}command${gt} ${lt}command options${gt}" echo " msrt help" echo " msrt version" echo echo "OPTIONS" echo " cmd line (rc file cmds) description" echo " -v (verbose) be verbose, sets MINOS_VERBOSE" echo " -l (logit) log compilation, sets USE_LOG_DIR" echo " -e (user_env) use existing env instead of default" echo " -d (use_distcc) use distcc" echo " -c (use_ccache) use ccache" echo " -j (max_make_jobs) set max make jobs (ie make -j XX)" echo echo "RC FILE" echo " \$HOME/.msrtrc (sh format) is sourced just after command lines" echo " Setting the variable names in \"()\" above is the same as" echo " using the command line switch. For example:" echo echo " verbose=yes" echo " logit=yes" echo echo " will always turn on -v and -l" echo echo "COMMANDS" msrt_bootstrap_usage echo msrt_template_usage echo msrt_release_usage echo msrt_build_usage echo msrt_update_usage echo msrt_validate_usage echo msrt_addpkg_usage echo msrt_clean_usage echo msrt_prune_usage echo msrt_purge_usage echo msrt_snapshot_usage echo msrt_branchtag_usage echo msrt_frozentag_usage echo msrt_proxy_usage echo msrt_testrel_usage echo msrt_migrate_usage echo msrt_help_usage echo echo "FILES" echo " \$HOME/.msrtrc can hold any default environment (.sh format)" echo } msrt_help_usage () { echo " msrt help" } msrt_help () { outfile=/tmp/msrt-help.$$ cat << EOF > $outfile NAME msrt - a tool to manage SRT releases EOF msrt_synopsis >> $outfile cat << EOF >> $outfile DESCRIPTION msrt is an sh script which gives a simple interface to handling SRT related chores when working with MINOS offline software. Starting with just msrt, it is possible to boot-strap a virgin system, build the development release or one of the frozen release. Day to day maintenance such as updating and re-building all or part of a release is also possible. EOF if [ -n "$GATEWAY_INTERFACE" ] ; then echo >> $outfile echo '' >> $outfile echo >> $outfile fi cat << EOF >> $outfile 12 STEP PROGRAM Follow these 12 steps to create a new development base release on a virgin system. 0) Admit you have a problem... 1) Get the latest version of the msrt script http://minos.phy.bnl.gov/software/cvs/setup/msrt 2) Make a directory to house the code mkdir /path/to/some/dir 3) Go there cd /path/to/some/dir 4) Boot strap the SRT srt/ dir and the MINOSSOFT setup/ dir msrt bootstrap See the section titled "SRT_CXX issues" on the msrt web site if you think you need to specify GCC version string here. 5) Set the initial SRT environment source minossoft/srt/srt.csh (for csh derived shells) or source minossoft/srt/srt.sh (for sh derived shells) 6) Create a cache area for proxied files and create .proxyrc file mkdir -p /path/to/site/cache/release_data echo "SITE_PROXY_CACHE:/path/to/site/cache/release_data" > \\ \$SRT_DIST/setup/.proxyrc The "release_data" will be populated with the site-local copies of auxillary data files associated with code releases as releases are installed from CVS. It should have the same visibility (e.g. NFS) as the SRT installation. 7) Get the source code for the development release msrt release [-W] use the -W flag if you want the release to use read-write SSH CVS access instead of read-only anonymous-CVS access (you can always change it later, see the "migrate" command). 8) Create a template file to source which sets up your environment for building (and eventually running) the code: msrt template -s csh or msrt template -s sh or msrt template -s bash 9) Edit the produced setup_minossoft.{csh,sh,bash} file to match local setup. The comments in the file should be enough to explain what to do. 10) Set the resulting environment variables source setup_minossoft.csh or source setup_minossoft.sh or source setup_minossoft.bash 11) Build the release msrt -l build The "-l" is optional. It will reduce the verbosity slightly and send all details to files in the SRT_DIST/releases/${lt}release-name${gt}/build-logs directory. 12) Run the job loon .... Step 9 needs to be repeated each time you freshly log in. The template setup_minossoft.{csh,sh,bash} scripts also source the srt.{csh,sh} script, so no need to do this explicitly. SEE ALSO See the extra documentation at: EOF if [ -z "$GATEWAY_INTERFACE" ] ; then cat << EOF >> $outfile http://minos.phy.bnl.gov/software/cvs/WebDocs/msrt.html See the example .msrtrc file in \$SRT_DIST/setup/example.msrtrc. If your environment is set up this file should be here: $SRT_DIST/setup/example.msrtrc EOF else cat << EOF >> $outfile http://minos.phy.bnl.gov/software/cvs/WebDocs/msrt.html See the example .msrtrc file in \$SRT_DIST/setup/example.msrtrc, EOF fi cat << EOF >> $outfile CONTACT: Please report any problems, questions or comments to Brett Viren ${lt}bv@bnl.gov${gt}. EOF if [ -n "$PAGER" ] ; then $PAGER $outfile else cat $outfile if [ -z "$GATEWAY_INTERFACE" ] ; then # hide from SSI/CGI echo echo "If this flashed passed you, consider setting your PAGER variable" echo "or piping the output to more (or less)" fi fi rm -f $outfile } ### # utility: ### MKDIR () { if [ ! -d $1 ] ; then mkdir -p $1 ; fi } MAKE () { # just use gmake gmake $make_flags $@ } anoncvs () { cvsroot=$1 ; shift if [ ! -f $HOME/.cvspass ] ; then touch $HOME/.cvspass ; fi grep -q $cvsroot $HOME/.cvspass > /dev/null 2>&1 if [ $? -ne 0 ] ; then echo echo "Please type \"anoncvs\" at the \"CVS password:\" prompt." echo cvs -d $cvsroot login fi if [ $? != 0 ] ; then echo "Quitting because of failed login" exit fi if [ "$verbose" = "yes" ] ; then echo "cvs -d $cvsroot $@" cvs -d $cvsroot $@ else cvs -d $cvsroot $@ > /dev/null fi if [ $? != 0 ] ; then echo "Quitting because of failed cvs" exit fi } get_packages () { if [ -z "$1" ] ; then return ; fi relfile=$1 cat $relfile | grep -v '[[:space:]]*#' | grep -v '^[[:space:]]*$' } get_testrel_pkgs () { # get the list of packages for the current test release # assume proper links in include subdir ls $SRT_PRIVATE_CONTEXT/include | tr "\n" " " } # do a readlink -f. RH's readlink can't cope. Assumes it is given a # symlink to directory! READLINK () { link=$1 ; shift wd=`/bin/pwd` cd $link dir=`/bin/pwd` cd $wd echo $dir } ### # Do a "cvs checkout" of the SRT_DIST/setup files ### checkout_setup_files () { srt_dist=$1 ; shift wd=`/bin/pwd` cd $srt_dist anoncvs $cvsroot_pserver get -d setup setup cd $wd } ### # Get the main SRT stuff. This replaces the need for the .tar file # args SRT_DIST ### checkout_srt_files () { srt_dist=$1 ; shift compiler=$1 ; shift wd=`/bin/pwd` # Create "boot" release MKDIR $srt_dist/packages/SoftRelTools cd $srt_dist/packages/SoftRelTools anoncvs $srt_cvsroot get -d HEAD SoftRelTools # unpack the boot release MKDIR $srt_dist/releases/ cd $srt_dist/releases/ tar -xvf $srt_dist/packages/SoftRelTools/HEAD/install/boot_release.tar # update srt/ files MKDIR $srt_dist/srt cd $srt_dist/srt cp $srt_dist/releases/boot/SoftRelTools/install/srt/* . cat << EOF > srt_envrc DEFAULT_SRT_CXX=$compiler DEFAULT_SRT_BASE_RELEASE=development EOF SRT_DIST=$srt_dist export SRT_DIST ./install -c $cvsroot_pserver -p MINOS source $SRT_DIST/srt/srt.sh internal_srt_setup SRT_BASE_RELEASE=boot cd $srt_dist/releases/boot MAKE cd $wd } ### ### The main functions. These correspond to "msrt " ### ### # Boot strap SRT onto a virgin system. This replaces the old # "install_srt". # # args: COMPILER. Assumes SRT_DIST should be the "minossoft" dir in # the cwd. ### msrt_bootstrap_usage () { echo " msrt bootstrap [ ${lt}compiler_label${gt} ]" echo " ${lt}compiler_label${gt} is usually not needed" echo " see the msrt web documents for instructions if you think" echo " you need to use something besides the default of \"GCC\"" } msrt_bootstrap () { compiler=$1 ; shift srt_dist=`/bin/pwd`/minossoft MKDIR $srt_dist if [ -z "$compiler" ] ; then compiler="GCC" fi checkout_setup_files $srt_dist checkout_srt_files $srt_dist $compiler cd $srt_dist/.. cat << EOF SRT has been boot strapped to: SRT_DIST=$SRT_DIST Continue on to step (5) where you will source: $SRT_DIST/srt/srt.{csh,sh} EOF } spitvar () { sh=$1 ; shift var=$1 ; shift val=$1 ; shift if [ -n "$1" ] ; then com=$1 ; shift ; else com="" ; fi if [ "$sh" = "csh" ] ; then echo -n $com echo "setenv $var $val" elif [ "$sh" = "sh" ] ; then echo -n $com echo "$var=$val" echo -n $com echo "export $var" elif [ "$sh" = "bash" ] ; then echo -n $com echo "export $var=$val" else echo -n $com echo "export $var=$val" fi } msrt_template_usage () { echo " msrt template [-d SRT_DIST] [-s sh|csh|bash]" echo " -d set the SRT_DIST (o.w. use \$SRT_DIST, or cwd/minossoft)" echo " -s set the shell to for which to generate" echo " -p post install - if env var already exists, use it" } msrt_template () { set -- `getopt s:d:p $*` if [ $? != 0 ] ; then msrt_template_usage return; fi srt_dist=$SRT_DIST post_install=0 for arg in $* ; do case $arg in -s) shell=$2; shift 2;; -d) srt_dist=$2; shift 2;; -p) post_install=1; shift;; --) shift; break; esac done if [ -z "$srt_dist" ] ; then if [ -d minossoft ] ; then srt_dist=`/bin/pwd`/minossoft echo "msrt template: no SRT_DIST given, guessing $srt_dist" else echo "No SRT_DIST found" msrt_template_usage return fi fi if [ -z "$shell" ] ; then echo "msrt template: no shell given, defaulting to csh" shell=csh fi shell_ext=$shell if [ "$shell_ext" = "bash" ] ; then shell_ext=sh ; fi # Define placeholders for the various installation parameters # and if post installing replace by current values where set. installation_dir="/path/to/installation/dir" reader_pass_word="reader_pass_word" reader_user_name="reader_user_name" loon_db_cascade="mysql://localhost/temp;mysql://localhost/offline" rootsys_dir="/path/to/where/root/is/installed" labyrinth_dir="/twisty/passages/all/alike" bmap_dir="" if [ $post_install = 1 ] ; then installation_dir=${INSTALLATION-$installation_dir} reader_pass_word=${ENV_TSQL_PSWD-$reader_pass_word} reader_user_name=${ENV_TSQL_USER-$reader_user_name} loon_db_cascade=${ENV_TSQL_URL-$loon_db_cascade} rootsys_dir=${ROOTSYS-$rootsys_dir} labyrinth_dir=${LABYRINTH-$labyrinth_dir} bmap_dir=${BMAPPATH-bmap_dir} fi fname="setup_minossoft.$shell" cat << EOF > $fname # This line tells emacs this is a -*- shell-script -*- # MINOSSOFT setup environment for $shell like shells. # This file generated by msrt.pl but likely needs editting. # Bring in the basic SRT environment source $srt_dist/srt/srt.$shell_ext # Bring in the rest of the environment, setting up for using the # default base release ("development"). To use other than the default # release, instead use (you can do this from the command line after # you have sourced this script, or you can do it here): # # srt_setup SRT_BASE_RELEASE=${lt}release-name${gt} # # For a "test" relase, use: # # cd /path/to/my/test/release # srt_setup -a # # All this srt_setup nonsense isn't strictly needed needed by msrt, # but you will need to call it to setup your environment if you want # to explictly type "make" or actually run the resulting code. srt_setup # See WebDocs/install_products.html for 3rd party package installation # instructions. By default, this setup script assumes all 3rd party # packages are installed into INSTALLATION. Either edit the value for # this variable, or if necessary, set each _DIR variable separately. EOF spitvar $shell "INSTALLATION" "$installation_dir" >>$fname echo -e "\n# Location of the libsigc++ 3rd party package" >>$fname spitvar $shell "SIGC_DIR" "\$INSTALLATION" >>$fname echo -e "\n# Get all 3rd party lib dirs into LD_LIBRARY_PATH" >>$fname spitvar $shell "LD_LIBRARY_PATH" \ "\${LD_LIBRARY_PATH}:\${SIGC_DIR}/lib" >>$fname cat << EOF >> $fname # How you access the database. See the User Manual for details: # http://minos.phy.bnl.gov/software/UserManual.html # and look at Database Interface / Installing and Running / Setting up the Environment EOF spitvar $shell "ENV_TSQL_PSWD" "\"$reader_pass_word\"" >>$fname spitvar $shell "ENV_TSQL_USER" "$reader_user_name" >>$fname spitvar $shell "ENV_TSQL_URL" "\"$loon_db_cascade\"" >>$fname cat << EOF >> $fname #################### # Below are some other variables you may want to set in this file. # They are optional either because they are not needed by msrt nor to # run the offline or you may simply want to set them somewhere else # MINOS_DATA: A variable of dubious worth. This isn't used by msrt, # but is historical and often used in the colloquial. EOF spitvar $shell "MINOS_SOFT" "\$SRT_DIST/.." "##" >>$fname cat << EOF >> $fname # ROOT_DATA: Many sites have a central location for MINOS data and # point to it with this un-aptly named variable: EOF spitvar $shell "ROOT_DATA" "/path/to/some/directory" "##" >>$fname cat << EOF >> $fname # ROOT: You need to tell the build and run environment where to find # ROOT. You must do this, but you may do it somewhere besides this # script. Note, there are 2 ways to install ROOT, this example only # covers the usual way done via a normal "make" or when using the .tar # binary packages. EOF spitvar $shell "ROOTSYS" "$rootsys_dir" >>$fname spitvar $shell "PATH" "\${ROOTSYS}/bin:\${PATH}" >>$fname spitvar $shell "LD_LIBRARY_PATH" "\${ROOTSYS}/lib:\${LD_LIBRARY_PATH}" >>$fname cat << EOF >> $fname # Labyrinth: If you want to build rerootjob, gminos or otherwise use # the old FORTRAN system you need to set these variables and do some # other things. For instructions see: # http://www-numi.fnal.gov/fnal_minos/computing/labyrinth/index.html EOF spitvar $shell "LABYRINTH" "$labyrinth_dir" "##" >>$fname echo "## source \${LABYRINTH}/setup_labyrinth.$shell_ext" >>$fname if [ "x$bmap_dir" != "x" ] ; then cat << EOF >> $fname # BMAPPATH: Path for Bfield Maps (normally part of Labyrinth) EOF spitvar $shell "BMAPPATH" "$bmap_dir" >>$fname fi cat << EOF Generated skeleton: "setup_minossoft.$shell". You will want to edit it to fit your local setup. Read the comments for help. EOF } ### Helper: get_relname () { if [ -z "$1" -a -n "$user_env" ] ; then echo "Using release \"$SRT_BASE_RELEASE\" from existing environment" 1>&2 echo $SRT_BASE_RELEASE elif [ -n "$1" -a -n "$user_env" ] ; then echo "Overriding release \"$SRT_BASE_RELEASE\" from existing environment with \"$1\"" 1>&2 echo $1 elif [ -n "$1" ] ; then echo "Using release \"$1\"" 1>&2 echo $1 else echo "defaulting to \"development\" release" 1>&2 echo development fi } ### ### All things below here must pass env_okay ### env_okay () { if [ -z "$SRT_DIST" ] ; then echo "SRT_DIST not set. Did you source SRT_DIST/srt/srt.{csh,sh}," echo " (or a script which does so)?" false return fi if [ ! -d "$SRT_DIST/releases/boot" ] ; then echo "No \"boot\" release. Did you run \"msrt bootstrap\"?" false return fi if [ ! -d "$SRT_DIST/setup" ] ; then echo "No SRT_DIST/setup directory. Did you run \"msrt bootstrap\"?" false return fi CVSROOT=`cat $SRT_DIST/srt/cvsroot` export CVSROOT true } ### # Create a release. Args: ### msrt_release_usage () { echo " msrt release [-r release_name] [-R|W]" echo " release_name = \"development\" is default" echo " o.w. something like RX.Y.Z" echo " -R specifies creating a read-only (anoncvs) package (default)" echo " -W specifies creating a read-Write (ssh) package. " echo " You must have SSH CVS access for this to work." } msrt_release () { set -- `getopt RWr: $*` if [ $? != 0 ] ; then msrt_release_usage return; fi access_method="" for arg in $* ; do case $arg in -r) relname=$2; shift 2;; -R) access_method="-d $cvsroot_pserver"; shift;; -W) access_method="-d $cvsroot_ssh"; shift;; --) shift; break; esac done relname=`get_relname $relname` env_okay || return wd=`pwd`; cd $SRT_DIST/setup echo "Updating: $SRT_DIST/setup" if [ "$verbose" = "yes" ] ; then cvs update | tee -a $logfile else cvs update > /dev/null fi cd $wd relfile=$SRT_DIST/setup/packages-$relname if [ ! -f $relfile ] ; then echo "No release file: $relfile" return fi # newrel will fail if the release pre-exists if [ -d "$SRT_DIST/releases/$relname" ] ; then echo "msrt_release: already existing release:" echo "$SRT_DIST/releases/$relname" echo "SRT's newrel would fail, so I must abort now but," echo "You can run \"msrt update\" to complete." return fi # fix up SoftRelTools which is not in the MINOS repository. This # makes use of a feature of addpkg for n in SoftRelTools do MKDIR $SRT_DIST/packages/$n if [ ! -f $SRT_DIST/packages/$n/cvsroot ] ; then echo $srt_cvsroot > $SRT_DIST/packages/$n/cvsroot fi done # create new, empty release wd=`pwd` cd $SRT_DIST/releases newrel -e $relname # deal with inconsistent packages format if [ "$relname" = "development" ] ; then get_packages $relfile | sed -e 's/$/ HEAD/' > .release-list else # assume frozen release get_packages $relfile | tr ':' ' ' > .release-list fi cat .release-list | while read pkg ver do echo "Adding $pkg version $ver to release $relname" if [ -f $SRT_DIST/packages/$pkg/cvsroot ] ; then msrt_addpkg -v $ver -r $relname $pkg else msrt_addpkg $access_method -v $ver -r $relname $pkg fi done # resolve any .proxy files msrt_proxy -r $relname rm -f .release-list cd $wd } ### # Build a release # Args: release name ### build_env_okay () { env_okay || return error=no if [ -z "$SIGC_DIR" ] ; then echo "You must define SIGC_DIR" error=yes fi if [ -z "$ENV_TSQL_PSWD" ] ; then echo "You must define ENV_TSQL_PSWD" error=yes fi if [ -z "$ENV_TSQL_USER" ] ; then echo "You must define ENV_TSQL_USER" error=yes fi if [ -z "$ENV_TSQL_URL" ] ; then echo "You must define ENV_TSQL_URL" error=yes fi if [ "$error" = "yes" ] ; then echo "Did you source your setup_minossoft script?" false else true fi } internal_srt_setup () { if [ -z "$user_env" ] ; then if [ -n "$debug" ] ; then echo "===== env before srt_setup ======================" env echo "=================================================" fi echo "internal_srt_setup() (re)doing srt_environment" . `srt_environment -X "$@"` if [ -n "$debug" ] ; then echo "===== env after srt_setup =======================" env echo "=================================================" fi fi if [ -n "$logit" ] ; then LOG_DIR=build-logs/$SRT_SUBDIR export LOG_DIR if [ ! -d $SRT_PUBLIC_CONTEXT/$LOG_DIR ] ; then MKDIR $SRT_PUBLIC_CONTEXT/$LOG_DIR fi fi } msrt_build_usage () { echo " msrt build [-r release] [pkg1 pkg2 ...]" echo " -r sets release name (development by default)" echo " optional package list restricts to building just these" } msrt_build () { set -- `getopt lr: $*` if [ $? != 0 ] ; then msrt_build_usage return; fi for arg in $* ; do case $arg in -r) relname=$2; shift 2;; --) shift; break; esac done relname=`get_relname $relname` build_env_okay || return wd=`pwd` cd $SRT_DIST/releases/$relname internal_srt_setup SRT_BASE_RELEASE=$relname if [ -z "$1" ] ; then MAKE else for pkg in $@; do MAKE $pkg.all done fi cd $SRT_DIST/releases/$relname makemodulemap --public cd $wd } ### # Update the packages based on setup/packages- file # Args: ### msrt_update_usage () { echo " msrt update [-r release] [-p] [-A] [pkg1 pkg2 ...]" echo " -r sets release name (development by default)" echo " -p force use of pserver" echo " -A force cvs reset sticky tags (for test release only)" echo " optional package list restricts to updating just these" } msrt_update () { set -- `getopt r:p $*` if [ $? != 0 ] ; then msrt_update_usage return; fi force_pserver="" force_unsticky="" for arg in $* ; do case $arg in -r) relname=$2; shift 2;; -p) force_pserver=yes; shift;; -A) force_unsticky=yes; shift;; --) shift; break; esac done relname=`get_relname $relname` cvsflags="-Pd" if [ "$relname" = "development" ] ; then cvsflags="-PAd" # prune, reset sticky tags, create new dirs elif [ "$relname" = "test" ] ; then if [ "${SRT_PRIVATE_CONTEXT}" = "." ] ; then echo "no \$SRT_PRIVATE_CONTEXT set - can not update" return fi if [ "$force_sticky" = "yes" ] ; then cvsflags="-PAd" ; fi fi env_okay || return logfile=/tmp/msrt-update-$$.log date > $logfile echo "msrt update -r $relname $@" >> $logfile wd=`pwd` if [ -z "$1" ] ; then if [ "$relname" = "test" ] ; then # test releases (w/ SRT_PRIVATE_CONTEXT != ".") pkglist=`get_testrel_pkgs ` else cd $SRT_DIST/setup # package-list-less base release updates also do $SRT_DIST/setup echo "Updating MINOS setup dir" echo "Updating: $SRT_DIST/setup" >> $logfile if [ "$verbose" = "yes" ] ; then cvs update $cvsflags | tee -a $logfile else cvs update $cvsflags >> $logfile 2>&1 fi if [ "$relname" = "development" ] ; then pkglist=`get_packages $SRT_DIST/setup/packages-development` else pkglist=`get_packages $SRT_DIST/setup/packages-$relname | tr ':' ' ' | cut -f 1 -d ' '` fi fi proxylist="" else pkglist="$@" proxylist=$pkglist fi for pkg in $pkglist ; do if [ "$relname" = "test" ] ; then dir=$SRT_PRIVATE_CONTEXT/$pkg else dir=$SRT_DIST/releases/$relname/$pkg fi cvsroot="" if [ -n "$force_pserver" -a ! -f $(readlink $dir)/../cvsroot ] ; then cvsroot="-d $cvsroot_pserver" fi if [ ! -d $dir ] ; then if [ "$relname" = "test" ] ; then echo "Sorry, package \"$pkg\" missing from test release - user must perform addpkg" continue fi echo "No such package: $pkg, will try to add it" if [ "$relname" = "development" ] ; then msrt_addpkg $cvsroot -r $relname $pkg else ver=`get_packages $SRT_DIST/setup/packages-$relname | tr ':' ' ' | grep "^$pkg "| cut -f 2 -d ' '` msrt_addpkg $cvsroot -r $relname -v $ver $pkg fi fi cd $dir echo "Updating $pkg" echo "Updating: $dir" >> $logfile if [ "$verbose" = "yes" ] ; then cvs $cvsroot update $cvsflags 2>&1 | tee -a $logfile else cvs $cvsroot update $cvsflags 2>&1 >> $logfile 2>&1 fi done cd $wd # resolve any .proxy files msrt_proxy -r $relname $proxylist >> $logfile if [ "$verbose" = "yes" ] ; then echo "Logging cvs updates to $logfile" fi if grep -q "^M " $logfile ; then echo "Modified files found:" grep -B 1 "^M " $logfile fi if grep -q "^C " $logfile ; then echo "Conflicts found:" grep -B 1 "^C " $logfile fi echo "See $logfile for details of the update" } ### # Build and run validation code ### msrt_validate_usage () { echo " msrt validate [-r release-name]" echo " Builds and runs the validation code" } msrt_validate () { set -- `getopt r: $*` if [ $? != 0 ] ; then msrt_validate_usage return; fi for arg in $* ; do case $arg in -r) relname=$2; shift 2;; --) shift; break; esac done relname=`get_relname $relname` build_env_okay || return wd=`pwd` cd $SRT_DIST/releases/$relname internal_srt_setup SRT_BASE_RELEASE=$relname if [ -z "$1" ] ; then MAKE tbin else for pkg in $@; do MAKE $pkg.tbin done fi cd $wd echo echo "Test programs built, but running of validation code not yet supported" echo } ### # Add a package to a release and to its packages file, if needed # this is essentially an internal routine as one can just do # "msrt update Package" to access it. ### msrt_addpkg_usage () { echo " msrt addpkg [-d cvsroot] [-r release] [-v version] package_name" echo " \"-v version\" can be used to set a version other than HEAD" echo " \"-d cvsroot\" override CVSROOT env. var." } msrt_addpkg () { set -- `getopt d:v:r: $*` if [ $? != 0 ] ; then msrt_addpkg_usage return; fi cvsroot="" for arg in $* ; do case $arg in -r) relname=$2; shift 2;; -v) ver=$2 ; shift 2;; -d) cvsroot="-d $2"; shift 2;; --) shift; break; esac done relname=`get_relname $relname` if [ -z "$ver" ] ; then ver="HEAD" ; fi if [ -z "$1" ] ; then msrt_addpkg_usage return fi pkg=$1 env_okay || return relfile=$SRT_DIST/setup/packages-$relname if [ ! -f $relfile ] ; then echo "msrt addpkg: can't add package: no such file $relfile" return fi # setup full environment internal_srt_setup SRT_BASE_RELEASE=$relname # if package version not in packages/PACKAGE/VERSION, put it there need_update="no" if [ ! -d "$SRT_DIST/packages/$pkg/$ver" ] ; then if [ "$ver" = "HEAD" ] ; then newver $cvsroot -h $pkg else newver $cvsroot --development $pkg $ver fi else need_update="yes" fi # Try to addpkg wd=`pwd` cd $SRT_DIST/releases/$relname #rwh090731 addpkg -l $pkg $ver # -p flag makes relative links addpkg -p $pkg $ver if [ "$need_update" = "yes" ] ; then cd $pkg cvs update fi cd $wd # Add to packages file if needed if [ "$?" = "0" ] ; then if ! grep -q $pkg $relfile ; then if [ "$relname" = "development" ] ; then # handle lameness echo $pkg >> $relfile else echo "$pkg:$ver" >> $relfile fi fi fi } ### # Clean a release, wholly or in part ### msrt_clean_usage () { echo " msrt clean [-r release] [pkg1 pkg2 ...]" echo " -r sets release name (development by default)" echo " optional package list restricts to cleaning just these" } msrt_clean () { set -- `getopt r: $*` if [ $? != 0 ] ; then msrt_clean_usage return; fi for arg in $* ; do case $arg in -r) relname=$2; shift 2;; --) shift; break; esac done relname=`get_relname $relname` env_okay || return if [ -z "$1" ] ; then if [ $relname = "development" ] ; then pkglist=`cat $SRT_DIST/setup/packages-development` else pkglist=`cat $SRT_DIST/setup/packages-$relname | tr ':' ' ' | cut -f 1 -d ' '` fi else pkglist="$@" fi wd=`pwd` internal_srt_setup SRT_BASE_RELEASE=$relname cd $SRT_DIST/releases/$relname for pkg in $pkglist ; do MAKE $pkg.clean done cd $wd } ### # Prune a release from an SRT directory tree ### msrt_prune_usage () { echo " msrt prune " echo " removes files associated with a release" } msrt_prune () { relname=$1 ; shift if [ "-r" = "$relname" ]; then relname=$1 ; shift ; fi env_okay || return if [ -z "$relname" ] ; then echo "Must specify a release name via" msrt_prune_usage exit fi if [ ! -d "$SRT_DIST/releases/$relname" ] ; then echo "No release $relname to prune" exit fi RM="rm -r" # RM="echo fakerm -r" wd=`pwd` cd $SRT_DIST listfile=/tmp/.msrt-prune-temp.$$ pkgfile=setup/packages-$relname if [ "$relname" = "development" ] ; then cat $pkgfile | sed -e 's/$/ HEAD/' >> $listfile else cat $pkgfile | tr ':' ' ' >> $listfile fi cat $listfile | while read pkg ver do pkgdir="releases/$relname/$pkg" if [ ! -d "$pkgdir" ] ; then continue; fi realdir=`READLINK $pkgdir` if [ -z "$realdir" ] ; then continue; fi linkcount=0 for dir in releases/{R*[0-9].*[0-9],R*[0-9].*[0-9].*[0-9],development}/$pkg do if [ "`echo $dir | grep '*'`" != "" ]; then continue; fi if [ "$dir" = "$pkgdir" ] ; then continue; fi if [ ! -d "$dir" ] ; then continue; fi thisrealdir=`READLINK $dir` if [ -z "$thisrealdir" ] ; then continue; fi if [ "$thisrealdir" = "$realdir" ] ; then linkcount=`echo $linkcount + 1 | bc` fi done if [ "$linkcount" = "0" ] ; then deaddir="packages/$pkg/"`basename $realdir` if [ -d $deaddir ] ; then echo "Deleting: $deaddir" $RM $deaddir else echo "Dir already gone: $deaddir" fi else echo "Not deleting shared directory: $realdir" fi done $RM releases/$relname cd $wd } ### # Purge unneeded files from tmp dirs ### msrt_purge_usage () { echo " msrt purge [ -r ]" echo " remove unneeded (.o, .d, *Cint*) files from tmp dirs" } msrt_purge () { set -- `getopt r: $*` if [ $? != 0 ] ; then msrt_purge_usage return; fi for arg in $* ; do case $arg in -r) relname=$2; shift 2;; --) shift; break; esac done relname=`get_relname $relname` env_okay || return internal_srt_setup SRT_BASE_RELEASE=$relname tmpdir=$SRT_DIST/releases/$relname/tmp/$SRT_SUBDIR find $tmpdir -name '*.o' -exec rm {} \; find $tmpdir -name '*.d' -exec rm {} \; find $tmpdir -name '*Cint.*' -exec rm {} \; } ### # Migrate from one CVSROOT to another ### msrt_migrate_usage () { echo " msrt migrate [-R] [-r release] [pkg1 ...]" echo " -R reverses the migration, ie will go from SSH to anoncvs" } msrt_migrate () { set -- `getopt Rr: $*` if [ $? != 0 ] ; then msrt_clean_usage return; fi reverse_migration=no for arg in $* ; do case $arg in -r) relname=$2; shift 2;; -R) reverse_migration=yes; shift;; --) shift; break; esac done relname=`get_relname $relname` if [ "$relname" = "test" ] ; then if [ "${SRT_PRIVATE_CONTEXT}" = "." ] ; then echo "no \$SRT_PRIVATE_CONTEXT set - can not migrate" return fi fi env_okay || return if [ -z "$1" ] ; then if [ $relname = "test" ] ; then pkglist=`get_testrel_pkgs ` elif [ $relname = "development" ] ; then pkglist=`get_packages $SRT_DIST/setup/packages-development` else pkglist=`get_packages $SRT_DIST/setup/packages-$relname | tr ':' ' ' | cut -f 1 -d ' '` fi else pkglist=$@ fi if [ "$reverse_migration" = "yes" ] ; then oldroot=$cvsroot_ssh newroot=$cvsroot_pserver else oldroot=$cvsroot_pserver newroot=$cvsroot_ssh fi if [ -z "$1" ] ; then if [ "$relname" != "test" ] ; then cd $SRT_DIST/setup echo "Migrating $SRT_DIST/setup" cvsmigrate -o $oldroot -d $newroot fi fi wd=`pwd` for pkg in $pkglist ; do cvsrootfile=$SRT_DIST/packages/$pkg/cvsroot if [ -f $cvsrootfile ] ; then echo "$pkg has a special cvsroot file holding:" cat $cvsrootfile echo -n "Change anyways? (y/N) " read yn if [ -z "$yn" -o "$yn" = "n" ] ; then continue; fi echo $newroot > $cvsrootfile fi if [ "$relname" = "test" ] ; then dir=$SRT_PRIVATE_CONTEXT/$pkg else dir=$SRT_DIST/releases/$relname/$pkg fi if [ -d $dir ] ; then cd $dir echo "cvsmigrate pkg $dir" cvsmigrate -f -o $oldroot -d $newroot fi done echo "Package level CVSROOTs changed." echo "Do you also wish to change the default SRT_DIST/srt/cvsroot? (Y/n)" read yn if [ -z "$yn" -o "$yn" = "y" ] ; then echo $newroot > $SRT_DIST/srt/cvsroot fi cd $wd } msrt_testing () { set -- `getopt r: $*` if [ $? != 0 ] ; then echo "you suck" return; fi for arg in $* ; do case $arg in -r) relname=$2; shift 2;; --) shift; break; esac done relname=`get_relname $relname` echo "relname=$relname" echo "user_env=$user_env" echo "arg = $1" echo "06-01-19"| tr -- '-' ' '| while read -n 8 yy mm dd do if [ -z "$yy" -o -z "$mm" -o -z "$dd" ] ; then echo "bad, bye bye" break fi echo "yy=$yy mm=$mm dd=$dd" done } msrt_snapshot_usage () { echo " msrt snapshot [-c] [ -f ] [-H] YY-MM-DD" echo " make a snapshot release for given YY-MM-DD date" echo " -f RX-YY appends \"-RX-YY\" to tag and release name (optional)" echo " -s skip the tagging, packages file still made (optional)" echo " -c will add and commit the produced packages file (optional)" echo " -H tag the HEAD instead code at given date string" } msrt_snapshot () { set -- `getopt Hf:cs $*` frozen="" commit="" skiptag="" usehead="" for arg in $* ; do case $arg in -f) frozen="-$2"; shift 2;; -c) commit="yes"; shift ;; -s) skiptag="yes"; shift ;; -H) usehead="yes"; shift ;; --) shift; break; esac done yymmdd=$1 ; shift tag="S${yymmdd}${frozen}" pkgfile=$SRT_DIST/setup/packages-$tag echo "# Snapshot $tag produced on "$(date) > $pkgfile if [ ! -w $pkgfile ] ; then echo "Apparently can't write to the packages file, bailing" return fi datestr="-D $yymmdd" if [ "$usehead" = "yes" ] ; then datestr=""; fi #rwh2008-10-31 pkglist=$(get_packages $SRT_DIST/setup/packages-development) pkglist=$(get_packages $SRT_DIST/setup/packages-baserelease) for pkg in $pkglist ; do cvsrootfile=$SRT_DIST/packages/$pkg/cvsroot if [ -f $cvsrootfile ] ; then if ! grep -q minoscvs $cvsrootfile ; then echo "${pkg}:HEAD" >> $pkgfile continue fi fi # special case: WebDocs # don't tag, use HEAD if [ "$pkg" = "WebDocs" ] ; then echo "${pkg}:HEAD" >> $pkgfile continue fi if [ -z "$skiptag" ] ; then cvs -d $cvsroot_ssh rtag $datestr $tag $pkg fi echo "${pkg}:${tag}" >> $pkgfile done echo "Made $pkgfile" if [ -n "$commit" ] ; then echo "Adding and committing new packages file" pf=$(basename $pkgfile) wd=$(pwd) cd $SRT_DIST/setup cvs -d $cvsroot_ssh add $pf cvs -d $cvsroot_ssh commit -m "First commit" $pf fi } msrt_branchtag_usage () { echo " msrt branchtag [-s] [-c] RX.YZ" echo " make a branchtag release with RX.YZ as release name and RX-YZ as tag" echo " -s skip the tagging, packages file still made (optional)" echo " -c will add and commit the produced packages file (optional)" } msrt_branchtag () { set -- `getopt sc $*` commit="" skiptag="" usehead="yes" for arg in $* ; do case $arg in -s) skiptag="yes"; shift ;; -c) commit="yes"; shift ;; --) shift; break; esac done relname=$1; shift tag=`echo "${relname}" | sed -e 'y/\./\-/'` pkgfile=$SRT_DIST/setup/packages-$relname echo "# branchtag $tag produced on "$(date) > $pkgfile if [ ! -w $pkgfile ] ; then echo "Apparently can't write to the packages file, bailing" return fi # datestr="-D $yymmdd" # if [ "$usehead" = "yes" ] ; then datestr=""; fi #rwh2008-10-31 pkglist=$(get_packages $SRT_DIST/setup/packages-development) pkglist=$(get_packages $SRT_DIST/setup/packages-baserelease) for pkg in $pkglist ; do cvsrootfile=$SRT_DIST/packages/$pkg/cvsroot if [ -f $cvsrootfile ] ; then if ! grep -q minoscvs $cvsrootfile ; then echo "${pkg}:HEAD" >> $pkgfile continue fi fi # special case: WebDocs # don't tag, use HEAD if [ "$pkg" = "WebDocs" ] ; then echo "${pkg}:HEAD" >> $pkgfile continue fi if [ -z "$skiptag" ] ; then cvs -d $cvsroot_ssh rtag -b $tag $pkg fi echo "${pkg}:${tag}" >> $pkgfile done echo "Made $pkgfile" if [ -n "$commit" ] ; then echo "Adding and committing new packages file" pf=$(basename $pkgfile) wd=$(pwd) cd $SRT_DIST/setup cvs -d $cvsroot_ssh add $pf cvs -d $cvsroot_ssh commit -m "First commit" $pf fi } msrt_frozentag_usage () { echo " msrt frozentag [-s] [-c] RX.Y.Z" echo " make a release with RX.Y.Z as release name and RX-Y-Z as tag" echo " based on the branchtag release RX.Y" echo " -s skip the tagging, packages file still made (optional)" echo " -c will add and commit the produced packages file (optional)" } msrt_frozentag () { set -- `getopt sc $*` commit="" skiptag="" usehead="yes" for arg in $* ; do case $arg in -s) skiptag="yes"; shift ;; -c) commit="yes"; shift ;; --) shift; break; esac done relname=$1; shift brtagdot=`echo $relname | cut -d'.' -f1-2` tag=`echo "${relname}" | sed -e 'y/\./\-/'` brtag=`echo "${brtagdot}" | sed -e 'y/\./\-/'` echo "create $relname from $brtagdot, cvs tag $tag from $brtag" pkgfile=$SRT_DIST/setup/packages-$relname echo "# frozentag $tag produced on "$(date) > $pkgfile if [ ! -w $pkgfile ] ; then echo "Apparently can't write to the packages file, bailing" return fi pkglist=$(get_packages $SRT_DIST/setup/packages-${brtagdot}) for pkgx in $pkglist ; do pkg=`echo $pkgx | cut -d':' -f1` cvsrootfile=$SRT_DIST/packages/$pkg/cvsroot if [ -f $cvsrootfile ] ; then if ! grep -q minoscvs $cvsrootfile ; then echo "${pkg}:HEAD" >> $pkgfile continue fi fi # special case: WebDocs # don't tag, use HEAD if [ "$pkg" = "WebDocs" ] ; then echo "${pkg}:HEAD" >> $pkgfile continue fi if [ -z "$skiptag" ] ; then cvs -d $cvsroot_ssh rtag -r $brtag $tag $pkg fi echo "${pkg}:${tag}" >> $pkgfile done echo "Made $pkgfile" if [ -n "$commit" ] ; then echo "Adding and committing new packages file" pf=$(basename $pkgfile) wd=$(pwd) cd $SRT_DIST/setup cvs -d $cvsroot_ssh add $pf cvs -d $cvsroot_ssh commit -m "First commit" $pf fi } test_proxyrc () { if [ "${lforce}" == "--local" ] ; then true return elif [ ! -f $SRT_DIST/setup/.proxyrc ] ; then echo " *************************************************************" echo " * No \$SRT_DIST/setup/.proxyrc found *" echo " * Example content lines (use one only): *" echo " * SITE_PROXY_CACHE:/path/to/local/release_data *" echo " * SITE_PROXY_CACHE:symlink-afs *" echo " * Subsequent lines list file patterns to exclude *" echo " *************************************************************" false # return non-zero exit code for failure return fi true return } msrt_proxy_usage () { echo " msrt proxy [-f] [-l] [-r release] [pkg1 pkg2 ...]" echo " resolve .proxy files (must have \$SRT_DIST/setup/.proxyrc file)" echo " -f force clean resolution (unlink, force refetch)" echo " -l force local copies (override .proxyrc)" echo " -r sets release name (HEAD=development by default)" echo " optional package list restricts to resolving just those" test_proxyrc } msrt_proxy () { set -- `getopt flr: $*` if [ $? != 0 ]; then msrt_proxy_usage return; fi pforce="no" lforce="" relname="development" pkgfile=$SRT_DIST/setup/packages-development for arg in $* ; do case $arg in -f) pforce="yes" ; shift ;; -l) lforce="--local" ; shift ;; -r) relname=$2 pkgfile=$SRT_DIST/setup/packages-${relname} shift 2 ;; --) shift; break; esac done pkglist=$@ tag=`echo "${relname}" | sed -e 'y/\./\-/'` if [ "$tag" = "development" ] ; then tag="HEAD" ; fi test_proxyrc noproxyrc=$? # echo "pforce $pforce relname $relname tag $tag proxyrc $noproxyrc pkglist $pkglist" if [ $noproxyrc -ne 0 ] ; then echo "Can not perform .proxy resolution for release: ${relname}" return fi if [ -z "$pkglist" ] ; then echo "resolve .proxy files in release: ${relname}" if [ "$pforce" = "yes" ] ; then $SRT_DIST/setup/proxy_resolver.py --unlink -r ${tag} $SRT_DIST/setup/proxy_resolver.py ${lforce} --force -r ${tag} else $SRT_DIST/setup/proxy_resolver.py ${lforce} -r ${tag} fi else for pkg in $pkglist ; do echo "resolve .proxy files in release: ${relname}, package: ${pkg}" if [ "$pforce" = "yes" ] ; then $SRT_DIST/setup/proxy_resolver.py --unlink -r ${tag} -p ${pkg} $SRT_DIST/setup/proxy_resolver.py ${lforce} --force -r ${tag} -p ${pkg} else $SRT_DIST/setup/proxy_resolver.py ${lforce} -r ${tag} -p ${pkg} fi done fi } ### # Create a test release. Args: ### msrt_testrel_usage () { echo " msrt testrel -n testrelname [-r base_release_name] [-R|W] [pkglist]" echo " -n testrelname = name of test release" echo " -r release_name = base release name (\"development\" is default)" echo " o.w. something like RX.Y.Z" # echo " -R specifies creating a read-only (anoncvs) package (default)" # echo " -W specifies creating a read-Write (ssh) package. " # echo " You must have SSH CVS access for this to work." } msrt_testrel () { set -- `getopt RWn:r: $*` if [ $? != 0 ] ; then msrt_testrel_usage return; fi access_method="" for arg in $* ; do case $arg in -n) testname=$2; shift 2;; -r) relname=$2; shift 2;; -R) access_method="-d $cvsroot_pserver"; shift;; -W) access_method="-d $cvsroot_ssh"; shift;; --) shift; break; esac done if [ -z "$testname" ] ; then echo "Must supply name of test release with -n flag:" msrt_testrel_usage return fi relname=`get_relname $relname` pkglist=$@ env_okay || return wd=`pwd`; # newrel will fail if the test release pre-exists if [ -d "$testname" ] ; then echo "msrt_testrel: already existing test release: $testname" echo "in $wd" return fi # newrel will fail if the base release doesn't exist if [ ! -d "$SRT_DIST/releases/$relname" ] ; then echo "msrt_testrel: missing base release: $relname" return fi echo "Creating new test release: $testname against base release $relname" newrel -t $relname $testname cd $testname internal_srt_setup -a echo SRT_PRIVATE_CONTEXT $SRT_PRIVATE_CONTEXT echo "pkglist: $pkglist" for pkg in $pkglist ; do echo "addpkg -t $pkg" addpkg -t $pkg done # resolve any .proxy files msrt_proxy -r test cd $wd } main $@