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