security/nss/pkg/solaris/bld_awk_pkginfo.ksh

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 #!/usr/bin/ksh -p
     2 #
     3 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
     4 # Use is subject to license terms.
     5 #
     6 # This Source Code Form is subject to the terms of the Mozilla Public
     7 # License, v. 2.0. If a copy of the MPL was not distributed with this
     8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     9 #
    10 # Simple script which builds the awk_pkginfo awk script.  This awk script
    11 # is used to convert the pkginfo.tmpl files into pkginfo files
    12 # for the build.
    13 #
    15 usage()
    16 {
    17    cat <<-EOF
    18 usage: bld_awk_pkginfo -p <prodver> -m <mach> -o <awk_script> [-v <version>]
    19 EOF
    20 }
    22 #
    23 # Awk strings
    24 #
    25 # two VERSION patterns: one for Dewey decimal, one for Dewey plus ,REV=n
    26 # the first has one '=' the second has two or more '='
    27 #
    28 VERSION1="VERSION=[^=]*$"
    29 VERSION2="VERSION=[^=]*=.*$"
    30 PRODVERS="^SUNW_PRODVERS="
    31 ARCH='ARCH=\"ISA\"'
    33 #
    34 # parse command line
    35 #
    36 mach=""
    37 prodver=""
    38 awk_script=""
    39 version="NSSVERS"
    41 while getopts o:p:m:v: c
    42 do
    43    case $c in
    44    o)
    45       awk_script=$OPTARG
    46       ;;
    47    m)
    48       mach=$OPTARG
    49       ;;
    50    p)
    51       prodver=$OPTARG
    52       ;;
    53    v)
    54       version=$OPTARG
    55       ;;
    56    \?)
    57       usage
    58       exit 1
    59       ;;
    60    esac
    61 done
    63 if [[ ( -z $prodver ) || ( -z $mach ) || ( -z $awk_script ) ]]
    64 then
    65    usage
    66    exit 1
    67 fi
    69 if [[ -f $awk_script ]]
    70 then
    71 	rm -f $awk_script
    72 fi
    74 #
    75 # Build REV= field based on date
    76 #
    77 rev=$(date "+%Y.%m.%d.%H.%M")
    79 #
    80 # Build awk script which will process all the
    81 # pkginfo.tmpl files.
    82 #
    83 # the first VERSION pattern is replaced with a leading quotation mark
    84 #
    85 rm -f $awk_script
    86 cat << EOF > $awk_script
    87 /$VERSION1/ {
    88       sub(/\=[^=]*$/,"=\"$rev\"")
    89       print
    90       next
    91    }
    92 /$VERSION2/ {
    93       sub(/\=[^=]*$/,"=$rev\"")
    94       sub(/NSSVERS/,"$version")
    95       print
    96       next
    97    }
    98 /$PRODVERS/ { 
    99       printf "SUNW_PRODVERS=\"%s\"\n", "$prodver" 
   100       next
   101    }
   102 /$ARCH/ {
   103       printf "ARCH=\"%s\"\n", "$mach"
   104       next
   105    }
   106 { print }
   107 EOF

mercurial