0
|
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 |
#
|
40
|
23 |
#ident "@(#)bld_awk_pkginfo.ksh 1.4 10/07/22 SMI"
|
0
|
24 |
#
|
40
|
25 |
# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
0
|
26 |
#
|
|
27 |
# Simple script which builds the awk_pkginfo awk script. This awk script
|
|
28 |
# is used to convert the pkginfo.tmpl files into pkginfo files
|
|
29 |
# for the build.
|
|
30 |
#
|
|
31 |
|
|
32 |
usage()
|
|
33 |
{
|
|
34 |
cat <<-EOF
|
|
35 |
usage: bld_awk_pkginfo -p <prodver> -m <mach> -o <awk_script> [-v <version>]
|
|
36 |
EOF
|
|
37 |
}
|
|
38 |
|
|
39 |
#
|
|
40 |
# Awk strings
|
|
41 |
#
|
|
42 |
# two VERSION patterns: one for Dewey decimal, one for Dewey plus ,REV=n
|
|
43 |
# the first has one '=' the second has two or more '='
|
|
44 |
#
|
|
45 |
VERSION1="VERSION=[^=]*$"
|
|
46 |
VERSION2="VERSION=[^=]*=.*$"
|
|
47 |
PRODVERS="^SUNW_PRODVERS="
|
|
48 |
ARCH='ARCH=\"ISA\"'
|
40
|
49 |
VENDOR='VENDOR=\"COMPANY\"'
|
0
|
50 |
|
|
51 |
#
|
|
52 |
# parse command line
|
|
53 |
#
|
|
54 |
mach=""
|
|
55 |
prodver=""
|
|
56 |
awk_script=""
|
|
57 |
version="SFWVERS"
|
|
58 |
|
|
59 |
while getopts o:p:m:v: c
|
|
60 |
do
|
|
61 |
case $c in
|
|
62 |
o)
|
|
63 |
awk_script=$OPTARG
|
|
64 |
;;
|
|
65 |
m)
|
|
66 |
mach=$OPTARG
|
|
67 |
;;
|
|
68 |
p)
|
|
69 |
prodver=$OPTARG
|
|
70 |
;;
|
|
71 |
v)
|
|
72 |
version=$OPTARG
|
|
73 |
;;
|
|
74 |
\?)
|
|
75 |
usage
|
|
76 |
exit 1
|
|
77 |
;;
|
|
78 |
esac
|
|
79 |
done
|
|
80 |
|
|
81 |
if [[ ( -z $prodver ) || ( -z $mach ) || ( -z $awk_script ) ]]
|
|
82 |
then
|
|
83 |
usage
|
|
84 |
exit 1
|
|
85 |
fi
|
|
86 |
|
|
87 |
if [[ -f $awk_script ]]
|
|
88 |
then
|
|
89 |
rm -f $awk_script
|
|
90 |
fi
|
|
91 |
|
|
92 |
#
|
|
93 |
# Build REV= field based on date
|
|
94 |
#
|
|
95 |
rev=$(date "+%Y.%m.%d.%H.%M")
|
|
96 |
|
|
97 |
#
|
|
98 |
# Build awk script which will process all the
|
|
99 |
# pkginfo.tmpl files.
|
|
100 |
#
|
|
101 |
# the first VERSION pattern is replaced with a leading quotation mark
|
|
102 |
#
|
|
103 |
rm -f $awk_script
|
|
104 |
cat << EOF > $awk_script
|
|
105 |
/$VERSION1/ {
|
|
106 |
sub(/\=[^=]*$/,"=\"$rev\"")
|
|
107 |
print
|
|
108 |
next
|
|
109 |
}
|
|
110 |
/$VERSION2/ {
|
|
111 |
sub(/\=[^=]*$/,"=$rev\"")
|
|
112 |
sub(/SFWVERS/,"$version")
|
|
113 |
print
|
|
114 |
next
|
|
115 |
}
|
|
116 |
/$PRODVERS/ {
|
|
117 |
printf "SUNW_PRODVERS=\"%s\"\n", "$prodver"
|
|
118 |
next
|
|
119 |
}
|
|
120 |
/$ARCH/ {
|
|
121 |
printf "ARCH=\"%s\"\n", "$mach"
|
|
122 |
next
|
|
123 |
}
|
40
|
124 |
/$VENDOR/ {
|
116
|
125 |
printf "VENDOR=\"%s\"\n", "Project OpenIndiana"
|
40
|
126 |
next
|
|
127 |
}
|
0
|
128 |
{ print }
|
|
129 |
EOF
|