xref: /onnv-gate/usr/src/cmd/sgs/packages/common/bld_awk_pkginfo.ksh (revision 6322:c7bf2a887dd4)
10Sstevel@tonic-gate#!/usr/bin/ksh -p
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*6322Sab196087# Common Development and Distribution License (the "License").
7*6322Sab196087# You may not use this file except in compliance with the License.
80Sstevel@tonic-gate#
90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate# See the License for the specific language governing permissions
120Sstevel@tonic-gate# and limitations under the License.
130Sstevel@tonic-gate#
140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate#
200Sstevel@tonic-gate# CDDL HEADER END
210Sstevel@tonic-gate#
220Sstevel@tonic-gate#
230Sstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
240Sstevel@tonic-gate#
25*6322Sab196087# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
26*6322Sab196087# Use is subject to license terms.
270Sstevel@tonic-gate#
280Sstevel@tonic-gate# Simple script which builds the awk_pkginfo awk script.  This awk script
290Sstevel@tonic-gate# is used to convert the pkginfo.tmpl files into pkginfo files
300Sstevel@tonic-gate# for the build.
310Sstevel@tonic-gate#
320Sstevel@tonic-gate
330Sstevel@tonic-gate
340Sstevel@tonic-gateusage()
350Sstevel@tonic-gate{
36*6322Sab196087   echo "usage: bld_awk_pkginfo -R <revision> -r <release> -m <mach> -o <awk_script>"
370Sstevel@tonic-gate}
380Sstevel@tonic-gate#
390Sstevel@tonic-gate# Awk strings
400Sstevel@tonic-gate#
410Sstevel@tonic-gateVERSION="VERSION\="
420Sstevel@tonic-gatePRODVERS="^PRODVERS\="
430Sstevel@tonic-gateARCH='ARCH=\"ISA\"'
440Sstevel@tonic-gate
450Sstevel@tonic-gate
460Sstevel@tonic-gate#
470Sstevel@tonic-gate# parse command line
480Sstevel@tonic-gate#
490Sstevel@tonic-gatemach=""
500Sstevel@tonic-gaterelease=""
510Sstevel@tonic-gateawk_script=""
52*6322Sab196087revision=""
530Sstevel@tonic-gate
540Sstevel@tonic-gatewhile getopts DR:o:r:m: c
550Sstevel@tonic-gatedo
560Sstevel@tonic-gate   case $c in
570Sstevel@tonic-gate   o)
580Sstevel@tonic-gate      awk_script=$OPTARG
590Sstevel@tonic-gate      ;;
600Sstevel@tonic-gate   m)
610Sstevel@tonic-gate      mach=$OPTARG
620Sstevel@tonic-gate      ;;
630Sstevel@tonic-gate   r)
640Sstevel@tonic-gate      release=$OPTARG
650Sstevel@tonic-gate      ;;
660Sstevel@tonic-gate   R)
67*6322Sab196087   	revision=$OPTARG
680Sstevel@tonic-gate	;;
690Sstevel@tonic-gate   \?)
700Sstevel@tonic-gate      usage
710Sstevel@tonic-gate      exit 1
720Sstevel@tonic-gate      ;;
730Sstevel@tonic-gate   esac
740Sstevel@tonic-gatedone
750Sstevel@tonic-gate
760Sstevel@tonic-gateif [[ ( -z $release ) || ( -z $mach ) || ( -z $awk_script ) \
77*6322Sab196087    || ( -z $revision) ]]
780Sstevel@tonic-gatethen
790Sstevel@tonic-gate   usage
800Sstevel@tonic-gate   exit 1
810Sstevel@tonic-gatefi
820Sstevel@tonic-gate
830Sstevel@tonic-gateif [[ -f $awk_script ]]
840Sstevel@tonic-gatethen
850Sstevel@tonic-gate	rm -f $awk_script
860Sstevel@tonic-gatefi
870Sstevel@tonic-gate
880Sstevel@tonic-gate#
890Sstevel@tonic-gate# Build REV= field based on date
900Sstevel@tonic-gate#
910Sstevel@tonic-gaterev=$(date "+%y.%m.%d.%H.%M")
920Sstevel@tonic-gate
930Sstevel@tonic-gate#
940Sstevel@tonic-gate# Build PRODVERS string - same as in libconv/common/bld_vernote.ksh
950Sstevel@tonic-gate#
96*6322Sab196087prodver="${release}-${revision}"
970Sstevel@tonic-gate
980Sstevel@tonic-gate#
990Sstevel@tonic-gate# Build awk script which will process all the
1000Sstevel@tonic-gate# pkginfo.tmpl files.
1010Sstevel@tonic-gate#
1020Sstevel@tonic-gaterm -f $awk_script
1030Sstevel@tonic-gatecat << EOF > $awk_script
1040Sstevel@tonic-gate/$VERSION/ {
1050Sstevel@tonic-gate      sub(/\=[^=]*$/,"=$rev\"")
1060Sstevel@tonic-gate      print
1070Sstevel@tonic-gate      next
1080Sstevel@tonic-gate   }
1090Sstevel@tonic-gate/$PRODVERS/ { 
1100Sstevel@tonic-gate      printf "PRODVERS=\"%s\"\n", "$prodver" 
1110Sstevel@tonic-gate      next
1120Sstevel@tonic-gate   }
1130Sstevel@tonic-gate/$ARCH/ {
1140Sstevel@tonic-gate      printf "ARCH=\"%s\"\n", "$mach"
1150Sstevel@tonic-gate      next
1160Sstevel@tonic-gate   }
1170Sstevel@tonic-gate{ print }
1180Sstevel@tonic-gateEOF
1190Sstevel@tonic-gate
120