bld_awk_pkginfo.ksh (1918B)
1 #!/usr/bin/ksh -p 2 # 3 # Copyright 2005 Sun Microsystems, Inc. All rights reserved. 4 # Use is subject to license terms. 5 # 6 # This Source Code Form is subject to the terms of the Mozilla Public 7 # License, v. 2.0. If a copy of the MPL was not distributed with this 8 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 # 10 #ident "$Id$" 11 # 12 # Simple script which builds the awk_pkginfo awk script. This awk script 13 # is used to convert the pkginfo.tmpl files into pkginfo files 14 # for the build. 15 # 16 17 usage() 18 { 19 cat <<-EOF 20 usage: bld_awk_pkginfo -p <prodver> -m <mach> -o <awk_script> [-v <version>] 21 EOF 22 } 23 24 # 25 # Awk strings 26 # 27 # two VERSION patterns: one for Dewey decimal, one for Dewey plus ,REV=n 28 # the first has one '=' the second has two or more '=' 29 # 30 VERSION1="VERSION=[^=]*$" 31 VERSION2="VERSION=[^=]*=.*$" 32 PRODVERS="^SUNW_PRODVERS=" 33 ARCH='ARCH=\"ISA\"' 34 35 # 36 # parse command line 37 # 38 mach="" 39 prodver="" 40 awk_script="" 41 version="NSPRVERS" 42 43 while getopts o:p:m:v: c 44 do 45 case $c in 46 o) 47 awk_script=$OPTARG 48 ;; 49 m) 50 mach=$OPTARG 51 ;; 52 p) 53 prodver=$OPTARG 54 ;; 55 v) 56 version=$OPTARG 57 ;; 58 \?) 59 usage 60 exit 1 61 ;; 62 esac 63 done 64 65 if [[ ( -z $prodver ) || ( -z $mach ) || ( -z $awk_script ) ]] 66 then 67 usage 68 exit 1 69 fi 70 71 if [[ -f $awk_script ]] 72 then 73 rm -f $awk_script 74 fi 75 76 # 77 # Build REV= field based on date 78 # 79 rev=$(date "+%Y.%m.%d.%H.%M") 80 81 # 82 # Build awk script which will process all the 83 # pkginfo.tmpl files. 84 # 85 # the first VERSION pattern is replaced with a leading quotation mark 86 # 87 rm -f $awk_script 88 cat << EOF > $awk_script 89 /$VERSION1/ { 90 sub(/\=[^=]*$/,"=\"$rev\"") 91 print 92 next 93 } 94 /$VERSION2/ { 95 sub(/\=[^=]*$/,"=$rev\"") 96 sub(/NSPRVERS/,"$version") 97 print 98 next 99 } 100 /$PRODVERS/ { 101 printf "SUNW_PRODVERS=\"%s\"\n", "$prodver" 102 next 103 } 104 /$ARCH/ { 105 printf "ARCH=\"%s\"\n", "$mach" 106 next 107 } 108 { print } 109 EOF