make_release_packages
author Alan Coopersmith <Alan.Coopersmith@Sun.COM>
Tue, 12 Aug 2008 13:59:15 -0700
changeset 496 b88fb0eea032
parent 493 f43507b5737d
child 513 9c7b32aa7a41
permissions -rw-r--r--
Make download-tarballs more Indiana-compatible: Port to ksh93, force Solaris make first in PATH

#! /bin/ksh93
#
# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, provided that the above
# copyright notice(s) and this permission notice appear in all copies of
# the Software and that both the above copyright notice(s) and this
# permission notice appear in supporting documentation.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Except as contained in this notice, the name of a copyright holder
# shall not be used in advertising or otherwise to promote the sale, use
# or other dealings in this Software without prior written authorization
# of the copyright holder.
# 
# @(#)make_release_packages	1.60 08/08/08
#
#	Create and fill a package staging area for X
#
#	This script should be run from the base of the build tree.
#	It takes no parameters.
#
#	Example:
#	    cd /export/home/hammer1/WORKSPACES_S493_ALPHA2.1
#	    ./make_release_packages
#
#   To build a subset of packages
#	env PACKAGE_LIST="packages" ./make_release_packages
#

#   Make sure that we aren't affected by the personal environment of
#   whoever is running this script
PATH=/usr/bin:/usr/ccs/bin
SHELL=/bin/ksh93
export LC_NUMERIC=C

MACH="$(uname -p)"
DATE="$(date +0.%Y.%m.%d)"

# List of official (deliverable) X-window packages for all platforms
XW_PACKAGE_LIST="SUNWfontconfig SUNWfontconfig-docs SUNWfontconfig-root 
    SUNWfreetype2 SUNWi1of SUNWvncviewer SUNWxcursor-themes
    SUNWxorg-cfg SUNWxorg-client-docs SUNWxorg-client-programs
    SUNWxorg-clientlibs SUNWxorg-compatlinks SUNWxorg-devel-docs
    SUNWxorg-doc SUNWxorg-graphics-ddx SUNWxorg-headers
    SUNWxorg-server SUNWxorg-tsol-module SUNWxprint-server
    SUNWxscreensaver-hacks SUNWxscreensaver-hacks-gl SUNWxsun-server
    SUNWxvnc SUNWxwacx SUNWxwcft SUNWxwdem SUNWxwdim SUNWxwdxm
    SUNWxwfnt SUNWxwfs SUNWxwfsw SUNWxwhl SUNWxwice SUNWxwinc
    SUNWxwman SUNWxwmod SUNWxwoft SUNWxwopt SUNWxwpft SUNWxwplr
    SUNWxwplt SUNWxwpmn SUNWxwrtl SUNWxwslb SUNWxwsrv SUNWxwsvr
    SUNWxwts SUNWxwxft"

# Some packages are only built for certain platforms currently
case "${MACH}" in
    sparc)	
    	XW_PACKAGE_LIST="$XW_PACKAGE_LIST SUNWxwpsr" 
	;;
    i386)	
    	XW_PACKAGE_LIST="$XW_PACKAGE_LIST SUNWxorg-mesa" 
	;;
esac

# Localization template packages for delivery to translation teams
if [[ "$BUILD_L10N" != "no" ]]; then
    XW_L10N_PACKAGES="SUNW0xacx SUNW0xman SUNW0xpmn 
		      SUNW0xwplt SUNW0xwopt SUNW0xwsvr"
else
    XW_L10N_PACKAGES=" "
fi

#   To build a subset of packages
#	PACKAGE_LIST="packages" make_release_packages
#
: ${PACKAGE_LIST:="$XW_PACKAGE_LIST $EXTRA_PACKAGES $XW_L10N_PACKAGES"}

### Functions for use later
function print_and_run
{
    print "$@"
    "$@"
}

progname="$0"

function fatal_error
{
    print -u2 "${progname}: ERROR: $*"
    exit 1
}


# Which platform name do we use for 64-bit?
case "${MACH}" in
    sparc)	PLAT_64="sparcv9" ;;
    i386)	PLAT_64="amd64" ;;
    *)    	fatal_error "Unknown architecture - not SPARC nor i386." ;;
esac

: ${PACKAGE_DIR:="$(pwd)/proto-packages"}
SOURCE_DIR="$(pwd)"

cd ${SOURCE_DIR}/packages

# Get build version from pkgversion
if [[ -f pkgversion ]] ; then
    source ./pkgversion
else
    fatal_error "${SOURCE_DIR}/packages/pkgversion not found.  Cannot continue."
fi

if [[ -z "${VERSION}" ]] ; then
    fatal_error "VERSION not set in ${SOURCE_DIR}/packages/pkgversion - run newPkRev"
fi

if [[ -z "${BUILD}" ]] ; then
    fatal_error "BUILD not set in ${SOURCE_DIR}/packages/pkgversion - run newPkRev"
fi

DECIMAL_BUILD=$(( ${BUILD} / 100.0 ))
print "Building packages for X11 version ${VERSION} build ${DECIMAL_BUILD}"

if [[ "${MACH}" = "sparc" ]]; then
    PROTODIR=${SOURCE_DIR}/proto-sun4-svr4
else
    PROTODIR=${SOURCE_DIR}/proto-${MACH}-svr4
fi

#   Next, create the staging area.
#
print 'Removing old proto-packages and recreating'
/bin/rm -rf ${PACKAGE_DIR}
/bin/mkdir ${PACKAGE_DIR} ${PACKAGE_DIR}/logs

#  Now copy the package description info
print 'Copying package descriptions'

/bin/cp copyright depend i.* r.* ${PACKAGE_DIR} >/dev/null 2>&1

for package in ${PACKAGE_LIST} common_files ; do
    cd ${package}

    /bin/mkdir ${PACKAGE_DIR}/${package}
    /bin/cp p* d* lib* i.* r.* M* ${PACKAGE_DIR}/${package} >/dev/null 2>&1

    # We keep the master copyright in the top-level copyright file
    # Packages that need additional copyright have copyright.add files
    # that we then merge here
    cp ../copyright ${PACKAGE_DIR}/${package}/copyright
    
    for F in copyright.add copyright.add.${MACH} ; do
	if [[ -f $F ]] ; then
	    chmod +w ${PACKAGE_DIR}/${package}/copyright
	    PROTODIR=${PROTODIR} nawk \
		'BEGIN   	{ PROTODIR = ENVIRON [ "PROTODIR" ]; }
		 /^include / 	{
				        system("cat " PROTODIR "/licenses/" $2)
				        next
				}
				{ print }' \
		    $F >> ${PACKAGE_DIR}/${package}/copyright
	fi
    done
    cd ..
done


#   Now move into the package staging area and build the packages.
cd ${PACKAGE_DIR}

for D in etc usr var lib licenses ; do
    /bin/rm -f $D
    /bin/ln -s ${PROTODIR}/$D $D
done

for D in openwin dt sfw bin ; do
    /bin/rm -f $D
    /bin/ln -s ${PROTODIR}/usr/$D $D
done

LOGfile=logs/package_build

print -- '---Building packages'

# Variables to pass to pkgmk for use in prototype files
# They must start with lowercase letters to be resolved at pkgmk time
PKGMK_VARS="plat_64=${PLAT_64} plat=${MACH}"

for package in ${PACKAGE_LIST} ; do
    cd ${package}
    date
    print "******** Making the ${package} package ********"

    sed -e '/ARCH/s/ISA/'${MACH}'/' -e 's/SUNW_PRODVERS=.*$/SUNW_PRODVERS='${VERSION}/ -e 's/VERSION=.*$/VERSION='${VERSION}.${BUILD},REV=${DATE}/ pkginfo.tmpl > pkginfo
    if [[ -f Makefile ]] ; then
	print_and_run /usr/ccs/bin/make SOURCEDIR=${SOURCE_DIR}/packages all
    fi

    if [[ -f prototype ]] ; then
	# Simple package with the same prototype on all platforms
	PROTOTYPE="prototype"
    else
    	# Package with some platform-specific settings in prototype
	if [[ ! -f prototype_${MACH} ]]; then
	    ln -s prototype_com prototype_${MACH}
	fi
	PROTOTYPE="prototype_${MACH}"
    fi

    print_and_run /usr/bin/pkgmk -d ${PACKAGE_DIR}/${package} -f ${PROTOTYPE} -o ${PKGMK_VARS}

    print "******** Done Making the ${package} package ********"
    cd ..
done >$LOGfile 2>&1

print result log is in ${PACKAGE_DIR}/$LOGfile

print -n "Packages built:  "
grep -c "Packaging complete" ${PACKAGE_DIR}/$LOGfile
print -n "Packages failed: "
grep -c "Packaging was not successful" ${PACKAGE_DIR}/$LOGfile

# Create an installdir with symlinks to SUNW* pkgs
cd ${PACKAGE_DIR}
mkdir installdir
cd installdir
ln -s ../SUNW*/SUNW* .
if [[ -f ${SOURCE_DIR}/packages/upgrade-X ]] ; then
    cp -p ${SOURCE_DIR}/packages/upgrade-X .
    chmod a+x upgrade-X
fi

exit 0