Home | History | Annotate | Download | only in pkgdefs
      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/CDDL.txt
     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/CDDL.txt.
     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 #
     24 # ident	"@(#)bld_awk_pkginfo.ksh	1.7	07/11/18 SMI"
     25 #
     26 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
     27 # Use is subject to license terms.
     28 #
     29 # Simple script which builds the awk_pkginfo awk script.  This awk script
     30 # is used to convert the pkginfo.tmpl files into pkginfo files
     31 # for the build.
     32 #
     33 
     34 
     35 usage()
     36 {
     37    echo "usage: bld_awk_pkginfo [-d] -p <prodver> -m <mach> -o <awk_script>"
     38 }
     39 
     40 MACH=`uname -p`
     41 
     42 #
     43 # Awk strings
     44 #
     45 # VERSION1 for Dewey plus ,REV=n that has two or more '=', and is used
     46 # for new packages whose REV is "0.0.0".
     47 # VERSION_21 is for the packages that shipped in Release 2.1 (SC3.2).
     48 #
     49 VERSION1="VERSION=[^=]*,REV=0\.0\.0\"$"
     50 VERSION_21="VERSION=[^=]*,REV=2\.1\.0\"$"
     51 PRODVERS="^SUNW_PRODVERS="
     52 ARCH='ARCH=\"ISA\"'
     53 
     54 #
     55 # parse command line
     56 #
     57 mach=""
     58 prodver=""
     59 awk_script=""
     60 debug=""
     61 
     62 while getopts o:p:m:d c
     63 do
     64    case $c in
     65    o)
     66       awk_script=$OPTARG
     67       ;;
     68    m)
     69       mach=$OPTARG
     70       ;;
     71    p)
     72       prodver=$OPTARG
     73       ;;
     74    d)
     75       debug=",debug"
     76       ;;
     77    \?)
     78       usage
     79       exit 1
     80       ;;
     81    esac
     82 done
     83 
     84 if [[ ( -z "$prodver" ) || ( -z "$mach" ) || ( -z "$awk_script" ) ]]
     85 then
     86    usage
     87    exit 1
     88 fi
     89 
     90 #
     91 # Build REV= field based on date. Used for new packages.
     92 #
     93 rev=$(date "+%Y.%m.%d.%H.%M")
     94 
     95 #
     96 # Rev for different OS build. Used for packages that have already shipped.
     97 #
     98 if [[ ( "${OS}" == "5.9" ) && ( "${MACH}" == "sparc" ) ]]; then
     99 	rev_21="2006.11.15.10.25"
    100 elif [[ ( "${OS}" == "5.10" ) && ( "${MACH}" == "sparc" ) ]]; then
    101 	rev_21="2006.11.15.10.25"
    102 elif [[ ( "${OS}" == "5.10" ) && ( "${MACH}" == "i386" ) ]]; then
    103 	rev_21="2006.11.15.10.33"
    104 else
    105 	rev_21=$rev
    106 fi
    107 
    108 #
    109 # Build awk script which will process all the
    110 # pkginfo.tmpl files.
    111 #
    112 rm -f $awk_script
    113 cat << EOF > $awk_script
    114 /$VERSION1/ {
    115       sub(/\=[^=]*$/,"=${rev}${debug}\"")
    116       print
    117       next
    118    }
    119 /$VERSION_21/ {
    120       sub(/\=[^=]*$/,"=${rev_21}${debug}\"")
    121       print
    122       next
    123    }
    124 /$PRODVERS/ { 
    125       printf "SUNW_PRODVERS=\"%s\"\n", "$prodver" 
    126       next
    127    }
    128 /$ARCH/ {
    129       printf "ARCH=\"%s\"\n", "$mach"
    130       next
    131    }
    132 { print }
    133 EOF
    134 
    135