#!/bin/sh # maketag # # A script to provide integration atgging support for # CDF packages (and zoom and SRT packages used by CDF). # # Usage: # maketag [opt] tag_value file [cvs-rtag-options] # # Where: # opt is -t for test mode - echo's the # cvs rtags rather than executing them. # # tag_value is the tag to be placed upon file. # This is assumed to be a CDF integration tag. # ( for example, v3_13_0int4a as the second tag for # integration release 3.13.0int4 ) # # file is either of the following: # # - a file containing a list of # cvs repository objects to be tagged and, optionally, # for each, appropriate cvs rtag options, or # # - a cvs repository object to be tagged. # # cvs-rtag-options are the options to be placed on a # cvs rtag command to uniquely identify the revision # of the object to be tagged. (usually -r [tag|revision], # or -D [date-time reference]). Any option not in option # form {beginning with '-') in either case above is # assumed to be -r [revision|tag] to be consistent with # the retagger and MakeIntRetags, etc. # # Method: # # The command line information is checked for reasonability as follows: # # - The tag_value is converted to an equivalent release value, if # possible. An attempt is then made to find the release definition # file at the head of the Release/Releases cvs object. If an # appropriate release definition file is not found, a warning is # output and a request for permission to continue output (waiting # for input). # # If a release definition file is found, a check is made to determine # determine if this release already exists. Again a warning is # output with a request for permission to continue. # # - For each cvs repository object in file, the existance of the package # is checked. If the tag is being placed at the package level, a # check is made to determine if this package already wears this tag. # If it is determined that the package already has been tagged with # this tag a warning is output with a request for permission to # continue. # # The tagging then proceeds as follows: # # - If the tag is being placed at other than the package level, an # equivalence is established between the latest tag placed on the # package and the value from the command line. (This preserves # the current state of the package.) # If the package has already been tagged with the tag_value # tag, no retagging of the package is done. The tag_value tag is then # placed upon the referenced object in accordance with the rtag options. # # - If the tag is being placed at the package level, it is so placed in # accordance with the rtag options. # # # Set the Pre variable to echo for debugging # Set it a null value for normal execution # if [ `echo ${1} | cut -c1` = '-' ] then if [ "${1}" = '-t' ] then echo "Setting debug mode" Pre=echo else Pre='' fi shift 1 fi tag=$1 file_of_retags_name=$2 old_str=${2} shift 2 negopts="$@" if [ "$tag" = "" ] then echo '' echo Usage: $0 tag file_of_retags_name echo '' exit 1 fi cwd=`pwd` first_char=`echo $file_of_retags_name|cut -c1` if [ "$file_of_retags_name" = "" ] then file_of_retags_name=${cwd}/${tag}.retags elif [ "`echo ${file_of_retags_name}|cut -c1-2`" = ".." ] then file_of_retags_name=${cwd}/${file_of_retags_name} elif [ "$first_char" = '.' ] then file_of_retags_name=${cwd}`echo $file_of_retags_name|cut -c2-` elif [ ! "$first_char" = '/' ] then file_of_retags_name="${cwd}/${file_of_retags_name}" fi UPS_SHELL=sh; export UPS_SHELL . `$UPS_DIR/bin/ups setup ups` setup cdfsoft2 development if [ "${CDFSOFT2_DIR}" = '' ] then echo "Unable to set up cdfsoft2" echo 'Exiting!' fi # # The following assumes that the tagging is being done for an # integration release and the format for the integration tag # is # vnn_nn_nn'int'nx # The tag_base for this tag is then vnn_nn_nnintn # tag_rel=`echo $tag | cut -f1 -d'i'` tag_inc=`echo $tag | cut -f2- -d't'` tag_base=${tag_rel}int tag_rel=`echo ${tag_base} | cut -c2- | sed 's%_%.%g'` tag_rel=${tag_rel}`echo ${tag_inc} | cut -c1` echo 'Assuming tag is for release' ${tag_rel} My_dir=$CDFSOFT2_DIR/Release/Scripts #set -x #set -v # My_dir=`${My_dir}/make_my_dir $0` work_space=`${My_dir}/define_work_area` for Rep in CDF OSS SRT ZOOM do [ -f $work_space/${Rep}_cvs_tag_history ] && \ rm -f $work_space/${Rep}_cvs_tag_history done opt="-d `${My_dir}/Find_cvs_root Release | cut -f2 -d','`" cd $work_space [ -d Release ] && rm -r Release cvs -Q $opt checkout Release/Releases if [ ! -d Release/Releases ] then echo '' echo 'Checkout of Release package failed' exit 1 fi if [ -f Release/Releases/${tag_rel}.newrel ] then Newrel=$work_space/Release/Releases/${tag_rel}.newrel if [ "`ups list -KVersion cdfsoft2 ${tag_rel}`" != '' ] then echo '' echo '* '"A release of cdfsoft2 corresponding to ${tag} already exists" echo '* '"Are you sure ${tag} is the desired tag? [y/n] (n)" read Ans A1=`echo ${Ans} | cut -c1` if [ "${A1}" != 'y' -a "${A1}" != 'Y' ] then echo '' echo '* ''Quiting' exit fi fi else echo '' echo '* '"Unable to find release information related to ${tag}" echo '* '"Are you sure ${tag} is the desired tag? [y/n] (n)" read Ans A1=`echo ${Ans} | cut -c1` if [ "${A1}" != 'y' -a "${A1}" != 'Y' ] then echo '' echo '* ''Quiting' exit 1 fi Newrel='' fi echo "" echo "Looking for $file_of_retags_name" if [ ! -f $file_of_retags_name ] then echo '' echo '* 'Cannot find $file_of_retags_name echo '' echo '* ''Checking if this is package/file' file_of_retags_name=${old_str} test_package=`echo ${file_of_retags_name} | cut -f1 -d'/'` if [ ! -d $BFDIST/releases/development/${test_package} -a \ "${test_package}" != '' ] then echo '* '"OOPS - $test_package is not in development" echo '* '" cannot retag this" echo '* ' echo '* 'Usage: $0 tag file_of_retags_name exit 1 else echo "Okay - Preparing to retag ${file_of_retags_name}" echo ${file_of_retags_name} ${negopts}> /tmp/$$_retags file_of_retags_name=/tmp/$$_retags Clean=Yes fi else echo '' echo Found $file_of_retags_name echo '' fi [ -f ${work_space}/sorted_retags ] && rm ${work_space}/sorted_retags sort ${file_of_retags_name} > ${work_space}/sorted_retags while read str_line <&4 do [ "${str_line}" = "" ] && continue [ `echo ${str_line} | cut -c1` = '#' ] && continue set $str_line module=${1} shift tag_opt="$@" if [ "${tag_opt}" != '' ] then [ `echo ${tag_opt} | cut -c1` != '-' ] && tag_opt=-r${tag_opt} fi package=`echo ${module} | cut -f1 -d'/'` if [ "${package}" = "${skip_package}" ] then echo '* '"Skipping ${module}" continue fi if [ ! -d $CDFSOFT2_DIR/${package} ] then echo '' echo '* '"Nothing known about $module - skipping" continue fi t_rep=`${My_dir}/Find_cvs_root $package` if [ "${t_rep}" = "" ] then echo '* '"Cannot determine cvs repository information for ${package}" echo '* '"Skipping this package" skip_package=${package} continue else set `echo ${t_rep} | sed 's%,% %g'` opt="-d ${1}" w_opt="-d ${2}" Rep=${3} History_file=$work_space/${Rep}_cvs_tag_history fi if [ "$package" = "${o_package}" ] then if [ "${package}" = "${module}" ] then continue else ${Pre} cvs ${w_opt} rtag -F ${tag_opt} ${tag} ${module} fi else if [ "${Newrel}" != '' ] then t_str=`grep '^'${package}' ' ${Newrel}` t_package='' if [ t_str != '' ] then set ${t_str} t_package=${1} old_tag=${2} fi fi if [ ! -f ${History_file} ] then echo "Generating tagging history for ${Rep} repository" cvs $opt history -T -D '14 days ago' -a > ${History_file} fi # # The following algorithm assumes that the meaningful tags in the # history file are the "integration" tags. These will be used # where "reasonable". Otherwise the tags from the, perhaps cloned, # release.newrel file, if any, will be used. # current_tag=`grep " ${package} " ${History_file} | cut -f2 -d'[' | \ grep -v ':D]' | cut -f1 -d':' | tail -1` [ "${current_tag}" = "" ] && current_tag=${old_tag} if [ "`echo ${current_tag} | grep ${tag_base}`" = "" ] then if [ "${old_tag}" != "" ] then current_tag=${old_tag} fi fi T_mess=`grep " ${package} " ${History_file} | grep '\['${tag}':' | \ grep -v ':D]'` if [ "${T_mess}" != "" -a "${package}" = "${module}" ] then echo '' echo '* '"${package} already tagged with ${tag}" echo '========================================================' echo ${T_mess} echo '========================================================' echo '* ''Continuing will overwrite this tag' echo '* '' Do you wish to continue? [y/n] (n)' read Ans A1=`echo ${Ans} | cut -c1` if [ "${A1}" != 'y' -a "${A1}" != 'Y' ] then echo '* ''Discontinuing the tag operation for this package' echo '* ''You may wish to restart with another tag' skip_package=${package} continue else ${Pre} cvs ${w_opt} rtag ${tag_opt} -F $tag ${package} fi elif [ "${package}" = "${module}" ] then ${Pre} cvs ${w_opt} rtag ${tag_opt} $tag ${package} elif [ "${package}" != "${module}" ] then if [ "${T_mess}" = "" ] then if [ "${current_tag}" = "" ] then echo '' echo '* '"${package} has never been tagged, cannot preserve" echo '* ''current state of this package while tagging' ${module} echo '* '"Discontinuing the tag operations for this package" echo '* '"Please consider cvs rtag ${tag} ${package} or" echo '* '" ${0} ${tag} ${package}" echo '* '"to tag ${package} from the head." skip_package=${package} continue fi # Current_tag = null ${Pre} cvs ${w_opt} rtag -r ${current_tag} ${tag} ${package} fi # current_tag = tag ${Pre} cvs ${w_opt} rtag ${tag_opt} -F ${tag} ${module} fi # T_mess fi # package = o_package o_package=${package} done 4< ${work_space}/sorted_retags [ "${Clean}" = "Yes" ] && rm ${file_of_retags_name} rm ${work_space}/sorted_retags rm -r ${work_space}/Release echo '' echo 'Maketag done'