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 
  34 usage()
  35 {
  36    echo "usage: bld_awk_pkginfo -R <revision> -r <release> -m <mach> -o <awk_script>"
  37 }
  38 #
  39 # Awk strings
  40 #
  41 VERSION="VERSION\="
  42 PRODVERS="^PRODVERS\="
  43 ARCH='ARCH=\"ISA\"'
  44 
  45 
  46 #
  47 # parse command line
  48 #
  49 mach=""
  50 release=""
  51 awk_script=""
  52 revision=""
  53 
  54 while getopts DR:o:r:m: c
  55 do
  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
  74 done
  75 
  76 if [[ ( -z $release ) || ( -z $mach ) || ( -z $awk_script ) \
  77     || ( -z $revision) ]]
  78 then
  79    usage
  80    exit 1
  81 fi
  82 
  83 if [[ -f $awk_script ]]
  84 then
  85         rm -f $awk_script
  86 fi
  87 
  88 #
  89 # Build REV= field based on date
  90 #
  91 rev=$(date "+%y.%m.%d.%H.%M")
  92 
  93 #
  94 # Build PRODVERS string - same as in libconv/common/bld_vernote.ksh
  95 #
  96 prodver="${release}-${revision}"
  97 
  98 #
  99 # Build awk script which will process all the
 100 # pkginfo.tmpl files.
 101 #
 102 rm -f $awk_script
 103 cat << 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 }
 118 EOF
 119