#!/bin/csh -f # # script to apply a CNSsolve patch generated by the create_patch script # does checking to make sure patch file and installed CNSsolve version match # assumes version information is held in source/version.inc # # written by: Paul Adams # # copyright Yale University # set patchdir='patches-done' set delscript='patch.del' # if ( ! ${?CNS_SOLVE} ) then echo 'environmental variable $CNS_SOLVE is not defined' echo 'maybe you need to source the file cns_solve_env' exit 1 endif # cd $CNS_SOLVE # set pfile=`ls patch_*_*.tar.Z >& /dev/null` # if ( $status != 0 ) then echo 'no patch file present' echo "move the CNSsolve patch file to the directory: $CNS_SOLVE" exit 1 endif # set pfile=`ls patch_*_*.tar.Z` # if ( $#pfile > 1 ) then echo 'only one patch file can be applied at a time' echo 'please remove any older patch files from the directory: $CNS_SOLVE' exit 1 endif # echo "found patch file: $pfile" # set oldvp=`echo $pfile | awk 'BEGIN{FS="_"}{print $2}'` set oldv=`echo $oldvp | sed -e 's/[A-Za-z]//g'` set oldp=`echo $oldvp | sed -e 's/[0-9\.]//g'` # set newvp=`echo $pfile | sed -e 's/\.tar\.Z//' | awk 'BEGIN{FS="_"}{print $3}'` set newv=`echo $newvp | sed -e 's/[A-Za-z]//g'` set newp=`echo $newvp | sed -e 's/[0-9\.]//g'` # set currv=`grep -i 'parameter *(cnsversion' source/version.inc | cut -d\' -f2` set currp=`grep -i 'parameter *(cnspatch' source/version.inc | cut -d\' -f2` if ( $currp == '0' ) set currp='' # echo "installed program version: $currv$currp" echo "applying this patch will convert version $oldvp to $newvp" # if ( $currv != $oldv ) then echo "installed version of CNSsolve does not match the patch file" echo "aborting patch - use patch for version $currv$currp" exit 1 endif # if ( $currp != $oldp ) then echo "installed version of CNSsolve has the wrong patch level for this patch file" echo "aborting patch - use patch for version $currv$currp" exit 1 endif # echo "extracting files from patch file: $pfile" set local_umask=`umask` if ( $local_umask != 22 ) then echo "***********************************************************" echo "***** WARNING: the current umask is not 022 \!\! *****" echo "***** files will be extracted with umask=$local_umask *****" echo "***** some files permissions may need to be changed *****" echo "***********************************************************" endif zcat $pfile | tar xvmf - # echo "running script patch.del to remove out-of-date files" ./$delscript if ( $status != 0 ) then echo "error deleting old files" else /bin/rm -f $delscript endif # echo "regenerating cns_solve_env file" sed -e "s#setenv CNS_SOLVE '.*'#setenv CNS_SOLVE \'$CNS_SOLVE\'#" \ cns_solve_env > cns_solve_env.tmp # if ( ( ! -z cns_solve_env.tmp ) && \ ( `diff cns_solve_env cns_solve_env.tmp | wc -l` != 0 ) ) then mv cns_solve_env.tmp cns_solve_env else /bin/rm -f cns_solve_env.tmp endif # if ( ! -d $patchdir ) then echo "making patch storage directory $patchdir" mkdir $patchdir endif # echo "moving patch file $pfile to directory $patchdir" mv $pfile $patchdir # echo "~~~~~~~~~~~~~~~~~~ patch installation complete ~~~~~~~~~~~~~~~~~" # echo "=====================================================================" echo "= run the command 'make update' on all installed platforms =" echo "=====================================================================" #