8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sgs / packages / common / bld_awk_pkginfo.ksh
blob4b1f33e2dab6e7677db1b3cf99b68d0e1e37e5fc
1 #!/usr/bin/ksh -p
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
23 #pragma ident "%Z%%M% %I% %E% SMI"
25 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
26 # Use is subject to license terms.
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.
34 usage()
36 echo "usage: bld_awk_pkginfo -R <revision> -r <release> -m <mach> -o <awk_script>"
39 # Awk strings
41 VERSION="VERSION\="
42 PRODVERS="^PRODVERS\="
43 ARCH='ARCH=\"ISA\"'
47 # parse command line
49 mach=""
50 release=""
51 awk_script=""
52 revision=""
54 while getopts DR:o:r:m: c
56 case $c in
58 awk_script=$OPTARG
61 mach=$OPTARG
64 release=$OPTARG
67 revision=$OPTARG
69 \?)
70 usage
71 exit 1
73 esac
74 done
76 if [[ ( -z $release ) || ( -z $mach ) || ( -z $awk_script ) \
77 || ( -z $revision) ]]
78 then
79 usage
80 exit 1
83 if [[ -f $awk_script ]]
84 then
85 rm -f $awk_script
89 # Build REV= field based on date
91 rev=$(date "+%y.%m.%d.%H.%M")
94 # Build PRODVERS string - same as in libconv/common/bld_vernote.ksh
96 prodver="${release}-${revision}"
99 # Build awk script which will process all the
100 # pkginfo.tmpl files.
102 rm -f $awk_script
103 cat << EOF > $awk_script
104 /$VERSION/ {
105 sub(/\=[^=]*$/,"=$rev\"")
106 print
107 next
109 /$PRODVERS/ {
110 printf "PRODVERS=\"%s\"\n", "$prodver"
111 next
113 /$ARCH/ {
114 printf "ARCH=\"%s\"\n", "$mach"
115 next
117 { print }