xref: /titanic_51/usr/src/cmd/sgs/packages/common/bld_awk_pkginfo.ksh (revision 3edf445cce90224c4218c6987d6709e8481cae58)
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#pragma ident	"%Z%%M%	%I%	%E% SMI"
24#
25# Copyright 2008 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
34usage()
35{
36   echo "usage: bld_awk_pkginfo -R <revision> -r <release> -m <mach> -o <awk_script>"
37}
38#
39# Awk strings
40#
41VERSION="VERSION\="
42PRODVERS="^PRODVERS\="
43ARCH='ARCH=\"ISA\"'
44
45
46#
47# parse command line
48#
49mach=""
50release=""
51awk_script=""
52revision=""
53
54while getopts DR:o:r:m: c
55do
56   case $c in
57   o)
58      awk_script=$OPTARG
59      ;;
60   m)
61      mach=$OPTARG
62      ;;
63   r)
64      release=$OPTARG
65      ;;
66   R)
67   	revision=$OPTARG
68	;;
69   \?)
70      usage
71      exit 1
72      ;;
73   esac
74done
75
76if [[ ( -z $release ) || ( -z $mach ) || ( -z $awk_script ) \
77    || ( -z $revision) ]]
78then
79   usage
80   exit 1
81fi
82
83if [[ -f $awk_script ]]
84then
85	rm -f $awk_script
86fi
87
88#
89# Build REV= field based on date
90#
91rev=$(date "+%y.%m.%d.%H.%M")
92
93#
94# Build PRODVERS string - same as in libconv/common/bld_vernote.ksh
95#
96prodver="${release}-${revision}"
97
98#
99# Build awk script which will process all the
100# pkginfo.tmpl files.
101#
102rm -f $awk_script
103cat << EOF > $awk_script
104/$VERSION/ {
105      sub(/\=[^=]*$/,"=$rev\"")
106      print
107      next
108   }
109/$PRODVERS/ { 
110      printf "PRODVERS=\"%s\"\n", "$prodver" 
111      next
112   }
113/$ARCH/ {
114      printf "ARCH=\"%s\"\n", "$mach"
115      next
116   }
117{ print }
118EOF
119
120