1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/nsprpub/pkg/solaris/bld_awk_pkginfo.ksh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,109 @@ 1.4 +#!/usr/bin/ksh -p 1.5 +# 1.6 +# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 1.7 +# Use is subject to license terms. 1.8 +# 1.9 +# This Source Code Form is subject to the terms of the Mozilla Public 1.10 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.11 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.12 +# 1.13 +#ident "$Id$" 1.14 +# 1.15 +# Simple script which builds the awk_pkginfo awk script. This awk script 1.16 +# is used to convert the pkginfo.tmpl files into pkginfo files 1.17 +# for the build. 1.18 +# 1.19 + 1.20 +usage() 1.21 +{ 1.22 + cat <<-EOF 1.23 +usage: bld_awk_pkginfo -p <prodver> -m <mach> -o <awk_script> [-v <version>] 1.24 +EOF 1.25 +} 1.26 + 1.27 +# 1.28 +# Awk strings 1.29 +# 1.30 +# two VERSION patterns: one for Dewey decimal, one for Dewey plus ,REV=n 1.31 +# the first has one '=' the second has two or more '=' 1.32 +# 1.33 +VERSION1="VERSION=[^=]*$" 1.34 +VERSION2="VERSION=[^=]*=.*$" 1.35 +PRODVERS="^SUNW_PRODVERS=" 1.36 +ARCH='ARCH=\"ISA\"' 1.37 + 1.38 +# 1.39 +# parse command line 1.40 +# 1.41 +mach="" 1.42 +prodver="" 1.43 +awk_script="" 1.44 +version="NSPRVERS" 1.45 + 1.46 +while getopts o:p:m:v: c 1.47 +do 1.48 + case $c in 1.49 + o) 1.50 + awk_script=$OPTARG 1.51 + ;; 1.52 + m) 1.53 + mach=$OPTARG 1.54 + ;; 1.55 + p) 1.56 + prodver=$OPTARG 1.57 + ;; 1.58 + v) 1.59 + version=$OPTARG 1.60 + ;; 1.61 + \?) 1.62 + usage 1.63 + exit 1 1.64 + ;; 1.65 + esac 1.66 +done 1.67 + 1.68 +if [[ ( -z $prodver ) || ( -z $mach ) || ( -z $awk_script ) ]] 1.69 +then 1.70 + usage 1.71 + exit 1 1.72 +fi 1.73 + 1.74 +if [[ -f $awk_script ]] 1.75 +then 1.76 + rm -f $awk_script 1.77 +fi 1.78 + 1.79 +# 1.80 +# Build REV= field based on date 1.81 +# 1.82 +rev=$(date "+%Y.%m.%d.%H.%M") 1.83 + 1.84 +# 1.85 +# Build awk script which will process all the 1.86 +# pkginfo.tmpl files. 1.87 +# 1.88 +# the first VERSION pattern is replaced with a leading quotation mark 1.89 +# 1.90 +rm -f $awk_script 1.91 +cat << EOF > $awk_script 1.92 +/$VERSION1/ { 1.93 + sub(/\=[^=]*$/,"=\"$rev\"") 1.94 + print 1.95 + next 1.96 + } 1.97 +/$VERSION2/ { 1.98 + sub(/\=[^=]*$/,"=$rev\"") 1.99 + sub(/NSPRVERS/,"$version") 1.100 + print 1.101 + next 1.102 + } 1.103 +/$PRODVERS/ { 1.104 + printf "SUNW_PRODVERS=\"%s\"\n", "$prodver" 1.105 + next 1.106 + } 1.107 +/$ARCH/ { 1.108 + printf "ARCH=\"%s\"\n", "$mach" 1.109 + next 1.110 + } 1.111 +{ print } 1.112 +EOF