1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
|
#! /usr/local/bin/tcsh
#################################################################
# #
# Copyright (c) 2001-2020 Fidelity National Information #
# Services, Inc. and/or its subsidiaries. All rights reserved. #
# #
# This source code contains the intellectual property #
# of its copyright holder(s), and is made available #
# under a license. If you do not know the terms of #
# the license, please stop and do not read further. #
# #
#################################################################
# This file is used by package.csh and must be modified prior
# to deploying to a new platform
if ("$1" == "-m") then
set mods_only=1
shift
else
set mods_only=0
endif
if( $# != 2 ) then
echo ""
echo " Usage: $0 [-m] <cms-directory> <release-directory>"
echo ""
exit 5
endif
set cms_dir = $1
set dst_dir = $2
set dst_top_dir = $dst_dir:h
set dst_ver = $dst_dir:t
set cms_ver = $cms_dir:t
unalias cp chmod mv ls grep
alias ls 'echo "ls \!:* 2>/dev/null" | sh' # we want to redirect only stderr to /dev/null; can't do that in tcsh.
alias cp 'cp -f \!:* >& /dev/null' # some copies may be null copies. we dont want error messages coming out.
alias mv 'mv -f \!:* >& /dev/null' # some moves may be null moves. we dont want error messages coming out.
alias chmod 'chmod \!:* >& /dev/null' # some chmods may be null chmods. we dont want error messages coming out.
set platform_name = `uname | sed 's/-//g' | sed 's=/==g' | tr '[A-Z]' '[a-z]'`
set build_types = "pro dbg bta"
set build_dirs = "map obj"
set dir_structure = "inc pct src tools log $build_types"
############# Define mapping between file-types and directory-name ##################
set gtm_src_types = "c m64 s msg"
set gtm_inc_types = "h max mac si"
set gtm_pct_types = "mpt m hlp"
set gtm_tools_types = "gtc sed awk sh csh list txt exp mk ksh cmake tab in xc"
#####################################################################################
if !(-e $cms_dir) then
echo "$cms_dir doesn't exist. Exiting..."
exit 1
endif
if !(-e $dst_top_dir) then
echo "$dst_top_dir doesn't exist. Exiting..."
exit 1
endif
set preserve_time = "-p" # while doing the copy, let us preserve time by default
if ("os390" == "$platform_name") then
set preserve_time = "-m" # only preserve times
endif
cd $dst_top_dir
if (-e $dst_ver) then
foreach image (pro bta dbg)
if (-e $gtm_root/$dst_ver/$image/gtmsecshr) then
$gtm_com/IGS $gtm_root/$dst_ver/$image/gtmsecshr "STOP" # stop gtmsecshr in case it is running
endif
if (-d $gtm_root/$dst_ver/$image/utf8/gtmsecshrdir) then
$gtm_com/IGS $gtm_root/$dst_ver/$image/utf8/gtmsecshr "STOP"
endif
end
# Verify if anybody is using this version before deleting
if ($platform_name == "linux") then
set psopt = "-ef --width 300" # to get more screen output have a 300 column screen
else
set psopt = "-ef"
endif
/bin/ps $psopt | grep "$dst_top_dir/$dst_ver/" | grep -vE "grep|$0" >& /dev/null
if ($status == 0) then
# This check does not cover all cases of usage. There is still a window where new processes might start.
# But, this is better than not checking at all.
echo "Following processes are still using $dst_ver; not deleting $dst_top_dir/$dst_ver"
/bin/ps $psopt | grep "$dst_top_dir/$dst_ver/" | grep -vE "grep|$0"
exit 1
endif
if ($dst_ver =~ V3* || $dst_ver =~ V4* || $dst_ver =~ V5* || $dst_ver =~ V6* || $dst_ver == "V990") then
set move_args = "compulsory"
endif
# to use this script to update released versions, you must
# copy this script to your own directtory and change the following IF statement to: (!($mods_only) && $?move_args)
# execute the updated script as library with the following command, replacing VER as necessary
# doall -server "all" -fg -run '~/cms_load.csh -m $cms_root/${VER} $gtm_root/${VER} |& tee -a ~/logs/${VER}_${HOST}.log'
if ($?move_args) then
set save_ver = `ls -ld ${gtm_root}/$dst_ver | \
awk '{if (length($7)==1) $7="0"_$7; time=$6"_"$7"_"$8; print toupper(time)}' | sed 's/://g'`
echo "# Renaming ${gtm_root}/${dst_ver} to ${gtm_root}/${dst_ver}_${save_ver}"
mv ${gtm_root}/$dst_ver ${gtm_root}/${dst_ver}_${save_ver}
else if (! $mods_only) then
echo "# Deleting existing $dst_dir directory structure"
foreach image (pro bta dbg)
# remove root-owned gtmsecshr* files/dirs
if (-e $gtm_root/$dst_ver/$image/gtmsecshrdir) then
$gtm_com/IGS $gtm_root/$dst_ver/$image/gtmsecshr "RMDIR"
endif
if (-d $gtm_root/$dst_ver/$image/utf8/gtmsecshrdir) then
$gtm_com/IGS $gtm_root/$dst_ver/$image/utf8/gtmsecshr "RMDIR"
endif
end
rm -rf $dst_ver
if ($status != 0) then
exit $status
endif
else
echo "# Updating $dst_dir directory structure"
endif
endif
############## Create $dst_dir and subdirectories ##################
if (! -e $dst_ver) then
echo "# Creating -------> $dst_dir Directory Structure ..."
mkdir -p $dst_ver
if ($status != 0) then
exit $status
endif
cd $dst_ver
set gtm_ver = `pwd`
if ($status != 0) then
exit $status
endif
mkdir $dir_structure {`echo $build_types | sed 's/ /,/g'`}/{`echo $build_dirs | sed 's/ /,/g'`}
if ($status != 0) then
exit $status
endif
else
set gtm_ver = ${dst_dir}
endif
cd $gtm_ver
cp $preserve_time $cms_dir/*/gtmsrc.csh .
############### Define platform-specific libraries ##################################
# if you add a platform or a platform specific directory below you must modify
# tools/btc_tools/cms_cshrc.csh
# tools/work_tools/get_lib_dirs.csh
# CMakeLists.txt / sr_*/platform.cmake
#
# platform ordering goes:
# platform+OS arch arch_common OS {portable,nsb_portable}
# The extra spaces at the end are required for override_libs to work correctly
set gtm_s_aix = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_rs6000 sr_aix "
set gtm_s_osf1 = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_alpha sr_dux "
set gtm_s_hpux = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_hppa sr_hpux "
set gtm_s_linux = "sr_port sr_port_cm sr_unix sr_unix_nsb sr_unix_cm sr_unix_gnp sr_x86_regs sr_i386 sr_linux "
set gtm_s_linux64 = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_x86_regs sr_x86_64 sr_linux "
set gtm_s_sunos = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_sparc sr_sun "
set gtm_s_os390 = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_s390 sr_os390 "
set gtm_s_l390 = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_linux sr_s390 sr_l390 "
set gtm_s_hpia = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_hpux sr_ia64 "
set gtm_s_linuxia = "sr_port sr_port_cm sr_unix sr_unix_cm sr_unix_gnp sr_linux sr_ia64 "
set gtm_s_cygwin = "sr_port sr_port_cm sr_unix sr_unix_nsb sr_unix_cm sr_unix_gnp sr_x86_regs sr_i386 sr_linux "
set platform_library = "$platform_name"
if ( "s390x" == $MACHTYPE && "linux" == $platform_library ) then
set platform_library = "l390"
endif
if ( "z/OS" == $MACHTYPE ) then
set platform_library = "os390"
endif
set mach_type = `uname -m`
if ( "ia64" == $mach_type && "hpux" == $platform_library ) then
set platform_library = "hpia"
endif
if ( "ia64" == $mach_type && "linux" == $platform_library ) then
set platform_library = "linuxia"
endif
if ( "x86_64" == $mach_type && "linux" == $platform_library ) then
if ( $?OBJECT_MODE ) then
if ( $OBJECT_MODE != "32" ) then
set platform_library = "linux64"
endif
else
set platform_library = "linux64"
endif
endif
########### Copy sources from platform-specific directories into appropriate version-subdirectories ############
cd $cms_dir
echo "# Copying files from $cms_dir"
set ref_libs = `set | grep "^gtm_s_${platform_library}[ ]" | sed 's/^gtm_s_'${platform_library}'[ ][ ]*//g'`
foreach ref_library ( $ref_libs )
if ( -d $ref_library ) then
set override_libs=`set | grep "^gtm_s_${platform_library}" | sed "s/.*$ref_library //"`
# echo "Override_libs for $ref_library are $override_libs"
cd $ref_library
foreach dir (src inc pct tools)
foreach ftype (`set | grep "^gtm_${dir}_types[ ]" | sed 's/^gtm_'$dir'_types[ ][ ]*//g'`)
set nfiles = `\ls -1 | grep "\.$ftype"'$' | wc -l | sed 's/^[ ]*//g'`
if ($nfiles != 0) then
if ($mods_only == 0) then
echo "# Copying $nfiles files of type .$ftype from $ref_library to ${gtm_ver}/${dir}"
\ls -1 | grep "\.$ftype"'$' | xargs -i cp -f $preserve_time {} $gtm_ver/${dir}
else
# @ n_modfiles=0
foreach srcfile (*.$ftype)
if ("" != "${override_libs}") then
set override_exists=0
foreach override_lib ($override_libs)
if (-f ../${override_lib}/$srcfile) then
# echo "Override for ${ref_library}/${srcfile} found in
# ${override_lib}"
set override_exists=1
break
endif
end
if ($override_exists) then
continue # on to the next file
endif
endif
set dstfile="${srcfile}"
if ($srcfile:e == "mpt") then
set dstfile="_$srcfile:r.m"
# echo "$srcfile is mpt, comparing with $dstfile"
endif
if ($srcfile == "release_name.h") then
# echo "Skipping release_name.h"
continue # assume up-to-date release_name.h
endif
if (! { cmp -s ${srcfile} ${gtm_ver}/${dir}/${dstfile} } ) then
echo "# Copying differing $srcfile from $ref_library to $gtm_ver/${dir}"
cp -f $preserve_time $srcfile $gtm_ver/${dir}
# @ n_modfiles++
endif
end
# echo "Copied $n_modfiles out of $nfiles files of type .$ftype from $ref_library to
# ${gtm_ver}/${dir}"
endif
endif
endif
set nfiles=`ls -1 *.${ftype}nix | wc -l | sed 's/^[ ]*//g'`
if ($nfiles != 0) then
echo "# Restoring $nfiles NIXed files of type .$ftype in directory ${gtm_ver}/${dir}"
ls -1 *.${ftype}nix |\
awk '{printf "cp -f $preserve_time %s %s/%s\n", $1, '\"${gtm_ver}/${dir}\"', $1}' |\
sed 's/nix$//g' | sh
endif
end
end
cd ..
else
echo "# Skipping missing library $ref_library"
endif
end
cp sr_unix_cm/makefile* $gtm_ver/tools
########### Copy files from tools repo to $dst_dir/tools ############
if (! $?gtmpcat_dir && -d $ggtools/gtmpcat_tools/gtmpcat) then
set gtmpcat_dir=$ggtools/gtmpcat_tools/gtmpcat
endif
if ($?gtmpcat_dir) then
echo "# Copying gtmpcat related files from $gtmpcat_dir"
cp $gtmpcat_dir/gtmpcat{{,fldbld}.m,_{field_def,sh}.txt} ${gtm_root}/${dst_ver}/tools
endif
######################## Rename .mpt files to _*.m files #######################
if ($mods_only == 0) then
echo "# Renaming .mpt files to _*.m in $gtm_ver/pct"
cd $gtm_ver/pct
ls -1 *.mpt | awk '{printf "mv %s _%s\n", $1, $1}' | sed 's/mpt$/m/g' | sh
######################## Convert EBCDIC files to ASCII #######################
if ("OS/390" == $HOSTOS) then
cd ..
mv pct pctebc
mkdir pct
cd pctebc
foreach file (*)
iconv -T -f IBM-1047 -t ISO8859-1 $file > $gtm_ver/pct/$file
if (0 != $status) then
echo "# Error converting $file (with iconv) -- return status: $status"
endif
touch -r $file $gtm_ver/pct/$file
end
cd $gtm_ver/pct
endif
######################## Edit release_name.h ####################################
echo "# Modifying release_name.h"
$btc_tools/edrelnam.csh $dst_ver # Do we care if this fails?
endif
############## Set appropriate permissions on the files. For comments see $gtm_tools/comlist.csh ##############
set gtm_verno = $gtm_ver:t
switch ($gtm_verno)
case "V990":
set chmod_protect = 1
breaksw
case "V9*":
set chmod_protect = 0
breaksw
default:
set chmod_protect = 1
breaksw
endsw
if ($chmod_protect == 1) then
set chmod_conf = 755
set chmod_src = 444
else
set chmod_conf = 775
set chmod_src = 664
endif
chmod 755 $gtm_ver
cd $gtm_ver
chmod $chmod_conf bta dbg pro inc pct src tools gtmsrc.csh
chmod 775 log
cd $gtm_ver/inc
chmod $chmod_src *
cd $gtm_ver/pct
chmod $chmod_src *
cd $gtm_ver/src
/bin/ls | xargs -n25 chmod $chmod_src
cd $gtm_ver/tools
chmod $chmod_src *
if ($chmod_protect} == 1 ) then
chmod 555 *sh
else
chmod 775 *sh
endif
echo ""
echo "Done"
echo ""
exit 0
|