security/nss/pkg/solaris/bld_awk_pkginfo.ksh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/pkg/solaris/bld_awk_pkginfo.ksh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,107 @@
     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 +# Simple script which builds the awk_pkginfo awk script.  This awk script
    1.14 +# is used to convert the pkginfo.tmpl files into pkginfo files
    1.15 +# for the build.
    1.16 +#
    1.17 +
    1.18 +usage()
    1.19 +{
    1.20 +   cat <<-EOF
    1.21 +usage: bld_awk_pkginfo -p <prodver> -m <mach> -o <awk_script> [-v <version>]
    1.22 +EOF
    1.23 +}
    1.24 +
    1.25 +#
    1.26 +# Awk strings
    1.27 +#
    1.28 +# two VERSION patterns: one for Dewey decimal, one for Dewey plus ,REV=n
    1.29 +# the first has one '=' the second has two or more '='
    1.30 +#
    1.31 +VERSION1="VERSION=[^=]*$"
    1.32 +VERSION2="VERSION=[^=]*=.*$"
    1.33 +PRODVERS="^SUNW_PRODVERS="
    1.34 +ARCH='ARCH=\"ISA\"'
    1.35 +
    1.36 +#
    1.37 +# parse command line
    1.38 +#
    1.39 +mach=""
    1.40 +prodver=""
    1.41 +awk_script=""
    1.42 +version="NSSVERS"
    1.43 +
    1.44 +while getopts o:p:m:v: c
    1.45 +do
    1.46 +   case $c in
    1.47 +   o)
    1.48 +      awk_script=$OPTARG
    1.49 +      ;;
    1.50 +   m)
    1.51 +      mach=$OPTARG
    1.52 +      ;;
    1.53 +   p)
    1.54 +      prodver=$OPTARG
    1.55 +      ;;
    1.56 +   v)
    1.57 +      version=$OPTARG
    1.58 +      ;;
    1.59 +   \?)
    1.60 +      usage
    1.61 +      exit 1
    1.62 +      ;;
    1.63 +   esac
    1.64 +done
    1.65 +
    1.66 +if [[ ( -z $prodver ) || ( -z $mach ) || ( -z $awk_script ) ]]
    1.67 +then
    1.68 +   usage
    1.69 +   exit 1
    1.70 +fi
    1.71 +
    1.72 +if [[ -f $awk_script ]]
    1.73 +then
    1.74 +	rm -f $awk_script
    1.75 +fi
    1.76 +
    1.77 +#
    1.78 +# Build REV= field based on date
    1.79 +#
    1.80 +rev=$(date "+%Y.%m.%d.%H.%M")
    1.81 +
    1.82 +#
    1.83 +# Build awk script which will process all the
    1.84 +# pkginfo.tmpl files.
    1.85 +#
    1.86 +# the first VERSION pattern is replaced with a leading quotation mark
    1.87 +#
    1.88 +rm -f $awk_script
    1.89 +cat << EOF > $awk_script
    1.90 +/$VERSION1/ {
    1.91 +      sub(/\=[^=]*$/,"=\"$rev\"")
    1.92 +      print
    1.93 +      next
    1.94 +   }
    1.95 +/$VERSION2/ {
    1.96 +      sub(/\=[^=]*$/,"=$rev\"")
    1.97 +      sub(/NSSVERS/,"$version")
    1.98 +      print
    1.99 +      next
   1.100 +   }
   1.101 +/$PRODVERS/ { 
   1.102 +      printf "SUNW_PRODVERS=\"%s\"\n", "$prodver" 
   1.103 +      next
   1.104 +   }
   1.105 +/$ARCH/ {
   1.106 +      printf "ARCH=\"%s\"\n", "$mach"
   1.107 +      next
   1.108 +   }
   1.109 +{ print }
   1.110 +EOF

mercurial