michael@0: #!/usr/bin/ksh -p michael@0: # michael@0: # Copyright 2005 Sun Microsystems, Inc. All rights reserved. michael@0: # Use is subject to license terms. michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: # michael@0: # Simple script which builds the awk_pkginfo awk script. This awk script michael@0: # is used to convert the pkginfo.tmpl files into pkginfo files michael@0: # for the build. michael@0: # michael@0: michael@0: usage() michael@0: { michael@0: cat <<-EOF michael@0: usage: bld_awk_pkginfo -p -m -o [-v ] michael@0: EOF michael@0: } michael@0: michael@0: # michael@0: # Awk strings michael@0: # michael@0: # two VERSION patterns: one for Dewey decimal, one for Dewey plus ,REV=n michael@0: # the first has one '=' the second has two or more '=' michael@0: # michael@0: VERSION1="VERSION=[^=]*$" michael@0: VERSION2="VERSION=[^=]*=.*$" michael@0: PRODVERS="^SUNW_PRODVERS=" michael@0: ARCH='ARCH=\"ISA\"' michael@0: michael@0: # michael@0: # parse command line michael@0: # michael@0: mach="" michael@0: prodver="" michael@0: awk_script="" michael@0: version="NSSVERS" michael@0: michael@0: while getopts o:p:m:v: c michael@0: do michael@0: case $c in michael@0: o) michael@0: awk_script=$OPTARG michael@0: ;; michael@0: m) michael@0: mach=$OPTARG michael@0: ;; michael@0: p) michael@0: prodver=$OPTARG michael@0: ;; michael@0: v) michael@0: version=$OPTARG michael@0: ;; michael@0: \?) michael@0: usage michael@0: exit 1 michael@0: ;; michael@0: esac michael@0: done michael@0: michael@0: if [[ ( -z $prodver ) || ( -z $mach ) || ( -z $awk_script ) ]] michael@0: then michael@0: usage michael@0: exit 1 michael@0: fi michael@0: michael@0: if [[ -f $awk_script ]] michael@0: then michael@0: rm -f $awk_script michael@0: fi michael@0: michael@0: # michael@0: # Build REV= field based on date michael@0: # michael@0: rev=$(date "+%Y.%m.%d.%H.%M") michael@0: michael@0: # michael@0: # Build awk script which will process all the michael@0: # pkginfo.tmpl files. michael@0: # michael@0: # the first VERSION pattern is replaced with a leading quotation mark michael@0: # michael@0: rm -f $awk_script michael@0: cat << EOF > $awk_script michael@0: /$VERSION1/ { michael@0: sub(/\=[^=]*$/,"=\"$rev\"") michael@0: print michael@0: next michael@0: } michael@0: /$VERSION2/ { michael@0: sub(/\=[^=]*$/,"=$rev\"") michael@0: sub(/NSSVERS/,"$version") michael@0: print michael@0: next michael@0: } michael@0: /$PRODVERS/ { michael@0: printf "SUNW_PRODVERS=\"%s\"\n", "$prodver" michael@0: next michael@0: } michael@0: /$ARCH/ { michael@0: printf "ARCH=\"%s\"\n", "$mach" michael@0: next michael@0: } michael@0: { print } michael@0: EOF