1 #!/usr/bin/ksh -p 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 #ident "%Z%%M% %I% %E% SMI" 24 # 25 # Copyright 2007 Sun Microsystems, Inc. All rights reserved. 26 # Use is subject to license terms. 27 # 28 # Simple script which builds the awk_pkginfo awk script. This awk script 29 # is used to convert the pkginfo.tmpl files into pkginfo files 30 # for the build. 31 # 32 33 usage() 34 { 35 cat <<-EOF 36 usage: bld_awk_pkginfo -p <prodver> -m <mach> -o <awk_script> [-v <version>] 37 EOF 38 } 39 40 # 41 # Awk strings 42 # 43 # two VERSION patterns: one for Dewey decimal, one for Dewey plus ,REV=n 44 # the first has one '=' the second has two or more '=' 45 # 46 VERSION1="VERSION=[^=]*$" 47 VERSION2="VERSION=[^=]*=.*$" 48 PRODVERS="^SUNW_PRODVERS=" 49 ARCH='ARCH=\"ISA\"' 50 ARCHCLASSES="^CLASSES_" 51 ALLCLASSES="^CLASSES=" 52 53 # 54 # parse command line 55 # 56 mach="" 57 prodver="" 58 awk_script="" 59 version="ONVERS" 60 61 while getopts o:p:m:v: c 62 do 63 case $c in 64 o) 65 awk_script=$OPTARG 66 ;; 67 m) 68 mach=$OPTARG 69 ;; 70 p) 71 prodver=$OPTARG 72 ;; 73 v) 74 version=$OPTARG 75 ;; 76 \?) 77 usage 78 exit 1 79 ;; 80 esac 81 done 82 83 if [[ ( -z $prodver ) || ( -z $mach ) || ( -z $awk_script ) ]] 84 then 85 usage 86 exit 1 87 fi 88 89 if [[ -f $awk_script ]] 90 then 91 rm -f $awk_script 92 fi 93 94 # 95 # Build REV= field based on date 96 # 97 rev=$(date "+%Y.%m.%d.%H.%M") 98 99 # 100 # Build awk script which will process all the 101 # pkginfo.tmpl files. 102 # 103 # the first VERSION pattern is replaced with a leading quotation mark 104 # 105 rm -f $awk_script 106 cat << EOF > $awk_script 107 /$VERSION1/ { 108 sub(/\=[^=]*$/,"=\"$rev\"") 109 print 110 next 111 } 112 /$VERSION2/ { 113 sub(/\=[^=]*$/,"=$rev\"") 114 sub(/ONVERS/,"$version") 115 print 116 next 117 } 118 /$PRODVERS/ { 119 printf "SUNW_PRODVERS=\"%s\"\n", "$prodver" 120 next 121 } 122 /$ARCH/ { 123 printf "ARCH=\"%s\"\n", "$mach" 124 next 125 } 126 /$ARCHCLASSES/ { 127 sub(/\=/," ") 128 gsub(/\"/,"") 129 archclasses[\$1]=\$0 130 next 131 } 132 /$ALLCLASSES/ { 133 tag="CLASSES_$mach" 134 sub(tag,"",archclasses[tag]) 135 sub(/\"$/,archclasses[tag]"\"") 136 print 137 next 138 } 139 { print } 140 EOF 141