make_release_packages revision 791
1056N/A#! /bin/ksh93
1056N/A#
1276N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
1276N/A# Use is subject to license terms.
1276N/A#
1276N/A# Permission is hereby granted, free of charge, to any person obtaining a
1276N/A# copy of this software and associated documentation files (the
1276N/A# "Software"), to deal in the Software without restriction, including
1276N/A# without limitation the rights to use, copy, modify, merge, publish,
1276N/A# distribute, and/or sell copies of the Software, and to permit persons
1276N/A# to whom the Software is furnished to do so, provided that the above
1276N/A# copyright notice(s) and this permission notice appear in all copies of
1276N/A# the Software and that both the above copyright notice(s) and this
1276N/A# permission notice appear in supporting documentation.
1276N/A#
1276N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1276N/A# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1276N/A# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
1276N/A# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
1276N/A# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
1276N/A# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
1276N/A# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1276N/A# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1276N/A# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1276N/A#
1276N/A# Except as contained in this notice, the name of a copyright holder
1276N/A# shall not be used in advertising or otherwise to promote the sale, use
1276N/A# or other dealings in this Software without prior written authorization
1276N/A# of the copyright holder.
1276N/A#
1276N/A# ident "@(#)make_release_packages 1.76 09/09/22 SMI"
1276N/A#
1276N/A# Create and fill a package staging area for X
1276N/A#
1276N/A# This script should be run from the base of the build tree.
1276N/A# It takes no parameters.
1276N/A#
1276N/A# Example:
1276N/A# cd /export/home/hammer1/WORKSPACES_S493_ALPHA2.1
1276N/A# ./make_release_packages
1276N/A#
1276N/A# To build a subset of packages
1276N/A# ./make_release_packages packages
1276N/A# or
1276N/A# env PACKAGE_LIST="packages" ./make_release_packages
1276N/A#
1276N/A
1276N/A# Make sure that we aren't affected by the personal environment of
1276N/A# whoever is running this script
1276N/APATH=/usr/bin:/usr/ccs/bin
1276N/ASHELL=/bin/ksh93
1276N/Aexport LC_NUMERIC=C
1276N/A
1276N/AMACH="$(uname -p)"
1276N/ADATE="$(date +0.%Y.%m.%d)"
1276N/A
1276N/A# List of official (deliverable) X-window packages for all platforms
1276N/AXW_PACKAGE_LIST="SUNWfontconfig SUNWfontconfig-docs SUNWfontconfig-root
1276N/A SUNWsynergy
1276N/A SUNWttf-google-droid
1276N/A SUNWpciaccess SUNWpixman SUNWfreetype2 SUNWvncviewer SUNWxcursor-themes
1276N/A SUNWxorg-client-docs SUNWxorg-client-programs
1276N/A SUNWxorg-clientlibs SUNWxorg-compatlinks
1276N/A SUNWxorg-graphics-ddx SUNWxorg-headers
1276N/A SUNWxorg-server SUNWxorg-tsol-module
1276N/A SUNWxvnc SUNWxwacx SUNWxwcft SUNWxwdem SUNWxwdxm
1276N/A SUNWxwfnt SUNWxwfs SUNWxwfsw SUNWxwice SUNWxwinc
1276N/A SUNWxwman SUNWxwmod SUNWxwoft SUNWxwopt SUNWxwplr
1276N/A SUNWxwplt SUNWxwpmn SUNWxwrtl SUNWxwslb
1276N/A SUNWxwxft"
1276N/A
1276N/AXSUN_PACKAGE_LIST="SUNWxsun-headers SUNWxsun-server SUNWxwts"
1276N/A
1276N/A# Some packages are only built for certain platforms currently
1276N/Acase "${MACH}" in
1276N/A sparc)
1276N/A XW_PACKAGE_LIST="$XW_PACKAGE_LIST $XSUN_PACKAGE_LIST SUNWxwpsr"
1276N/A ;;
1276N/A i386)
1276N/A XW_PACKAGE_LIST="$XW_PACKAGE_LIST SUNWxorg-mesa"
1276N/A ;;
1276N/Aesac
1276N/A
1276N/A# Localization template packages for delivery to translation teams
1276N/Aif [[ "$BUILD_L10N" != "no" ]]; then
1276N/A XW_L10N_PACKAGES="SUNW0xacx SUNW0xman SUNW0xpmn
1276N/A SUNW0xwplt SUNW0xwopt"
1276N/Aelse
1276N/A XW_L10N_PACKAGES=" "
1276N/Afi
1276N/A
1276N/A# FSW* packages are built for the OpenSolaris (Project Indiana) deliveries
1276N/AFSW_PACKAGE_LIST="
1276N/A FSWxorg-fonts-core
1276N/A FSWxorg-fonts-cyrillic
1276N/A FSWxorg-fonts-daewoo
1276N/A FSWxorg-fonts-ethiopic
1276N/A FSWxorg-fonts-iso8859-2
1276N/A FSWxorg-fonts-iso8859-3
1276N/A FSWxorg-fonts-iso8859-4
1276N/A FSWxorg-fonts-iso8859-9
1276N/A FSWxorg-fonts-iso8859-10
1276N/A FSWxorg-fonts-iso8859-13
1276N/A FSWxorg-fonts-iso8859-14
1276N/A FSWxorg-fonts-iso8859-16
1276N/A FSWxorg-fonts-jiskan
1276N/A FSWxorg-fonts-syriac
1276N/A FSWxorg-fonts-vera
1276N/A"
1276N/A
1276N/Aif [[ "$BUILD_FSW" != "no" ]]; then
1276N/A EXTRA_PACKAGES+="${FSW_PACKAGE_LIST}"
1276N/Afi
1276N/A
1276N/A# To build a subset of packages:
1276N/A# make_release_packages packages
1276N/A# or
1276N/A# env PACKAGE_LIST="packages" make_release_packages
1276N/A#
1276N/Aif (( $# > 0 )) ; then
1276N/A PACKAGE_LIST="$*"
1276N/Aelse
1276N/A : ${PACKAGE_LIST:="$XW_PACKAGE_LIST $EXTRA_PACKAGES $XW_L10N_PACKAGES"}
1276N/Afi
1276N/A
1276N/A### Functions for use later
1276N/Afunction print_and_run
1276N/A{
1276N/A print "$@"
1276N/A "$@"
1276N/A}
1276N/A
1276N/Aprogname="$0"
1276N/A
1276N/Afunction fatal_error
1276N/A{
1276N/A print -u2 "${progname}: ERROR: $*"
1276N/A exit 1
1276N/A}
1276N/A
1276N/Afunction process_includes
1276N/A{
1276N/A nawk \
1276N/A "/^include / {
1276N/A system(\"cat $1/\" \$2)
1276N/A next
1276N/A }
1276N/A { print }" $2
1276N/A}
1276N/A
1276N/A# Which platform name do we use for 64-bit?
1276N/Acase "${MACH}" in
1276N/A sparc) PLAT_64="sparcv9" ;;
1276N/A i386) PLAT_64="amd64" ;;
1276N/A *) fatal_error "Unknown architecture - not SPARC nor i386." ;;
1276N/Aesac
1276N/A
1276N/A: ${PACKAGE_DIR:="$(pwd)/proto-packages"}
1276N/ASOURCE_DIR="$(pwd)"
1276N/APKG_SOURCE_DIR=${SOURCE_DIR}/packages
1276N/A
1276N/Acd ${PKG_SOURCE_DIR}
1276N/A
1276N/A# Get build version from pkgversion
1276N/Aif [[ -f pkgversion ]] ; then
1276N/A source ./pkgversion
1276N/Aelse
1276N/A fatal_error "${PKG_SOURCE_DIR}/pkgversion not found. Cannot continue."
1276N/Afi
1276N/A
1276N/Aif [[ -z "${VERSION}" ]] ; then
1276N/A fatal_error "VERSION not set in ${PKG_SOURCE_DIR}/pkgversion - run newPkRev"
1276N/Afi
1276N/A
1276N/Aif [[ -z "${BUILD}" ]] ; then
1276N/A fatal_error "BUILD not set in ${PKG_SOURCE_DIR}/pkgversion - run newPkRev"
1276N/Afi
1276N/A
1276N/ADECIMAL_BUILD=$(( ${BUILD} / 100.0 ))
1276N/Aprint "Building packages for X11 version ${VERSION} build ${DECIMAL_BUILD}"
1276N/A
1276N/Aif [[ "${MACH}" = "sparc" ]]; then
1276N/A PROTODIR=${SOURCE_DIR}/proto-sun4-svr4
1276N/Aelse
1276N/A PROTODIR=${SOURCE_DIR}/proto-${MACH}-svr4
1276N/Afi
1276N/A
1276N/A# Next, create the staging area.
1276N/A#
1276N/Aprint 'Removing old proto-packages and recreating'
1276N/A/bin/rm -rf ${PACKAGE_DIR}
1276N/A/bin/mkdir ${PACKAGE_DIR} ${PACKAGE_DIR}/logs
1276N/A
1276N/A# Now copy the package description info
1276N/Aprint 'Copying package descriptions'
1276N/A
1276N/A/bin/cp copyright depend i.* r.* ${PACKAGE_DIR} >/dev/null 2>&1
1276N/A
1276N/Afor package in ${PACKAGE_LIST} common_files ; do
1276N/A if [[ ! -d ${package} ]] ; then
1276N/A print "packages/${package} not found ; skipping"
1276N/A continue
1276N/A fi
1276N/A
1276N/A cd ${package}
1276N/A
1276N/A /bin/mkdir ${PACKAGE_DIR}/${package}
1276N/A /bin/cp p* d* lib* i.* r.* M* ${PACKAGE_DIR}/${package} >/dev/null 2>&1
1276N/A
1276N/A # We keep the master copyright in the top-level copyright file
1276N/A # Packages that need additional copyright have copyright.add files
1276N/A # that we then merge here
1276N/A cp ../copyright ${PACKAGE_DIR}/${package}/copyright
1276N/A
1276N/A for F in copyright.add copyright.add.${MACH} ; do
1276N/A if [[ -f $F ]] ; then
1276N/A chmod +w ${PACKAGE_DIR}/${package}/copyright
1276N/A process_includes "${PROTODIR}/licenses" $F \
1276N/A >> ${PACKAGE_DIR}/${package}/copyright
1276N/A fi
1276N/A done
1276N/A cd ..
1276N/Adone
1276N/A
1276N/A
1276N/A# Now move into the package staging area and build the packages.
1276N/Acd ${PACKAGE_DIR}
1276N/A
1276N/Afor D in etc usr var lib licenses kernel ; do
1276N/A /bin/rm -f $D
1276N/A /bin/ln -s ${PROTODIR}/$D $D
1276N/Adone
1276N/A
1276N/Afor D in openwin ; do
1276N/A /bin/rm -f $D
1276N/A /bin/ln -s ${PROTODIR}/usr/$D $D
1276N/Adone
1276N/A
1276N/ALOGfile=logs/package_build
1276N/A
1276N/Aprint -- '---Building packages'
1276N/A
1276N/A# Variables to pass to pkgmk for use in prototype files
1276N/A# They must start with lowercase letters to be resolved at pkgmk time
1276N/APKGMK_VARS="plat_64=${PLAT_64} plat=${MACH}"
1276N/A
1276N/Afor package in ${PACKAGE_LIST} ; do
1276N/A print "******** Making the ${package} package ********"
1276N/A if [[ ! -d ${package} ]] ; then
1276N/A print "${PACKAGE_DIR}/${package} was not found ; skipping"
1276N/A continue
1276N/A fi
1276N/A
1276N/A cd ${package}
1276N/A date
1276N/A
1276N/A sed -e '/ARCH/s/ISA/'${MACH}'/' -e 's/SUNW_PRODVERS=.*$/SUNW_PRODVERS='${VERSION}/ -e 's/VERSION=.*$/VERSION='${VERSION}.${BUILD},REV=${DATE}/ pkginfo.tmpl > pkginfo
1276N/A if [[ -f Makefile ]] ; then
1276N/A print_and_run /usr/ccs/bin/make SOURCEDIR=${PKG_SOURCE_DIR} all
1276N/A else
1276N/A for pf in preinstall preremove postinstall postremove ; do
1276N/A # If filename.tmpl exists, but filename does not,
1276N/A # build filename from the .tmpl
1276N/A if [[ -f "${pf}.tmpl" && ! -f "${pf}" ]] ; then
1276N/A SOURCEDIR=${PKG_SOURCE_DIR} \
1276N/A nawk -f ${PKG_SOURCE_DIR}/awk_procedure \
1276N/A ${pf}.tmpl > ${pf}
1276N/A fi
1276N/A done
1276N/A fi
1276N/A
1276N/A for df in depend depend_${MACH} ; do
1276N/A # If filename.tmpl exists, but filename does not,
1276N/A # build filename from the .tmpl
1276N/A if [[ -f "${df}.tmpl" && ! -f "${df}" ]] ; then
1276N/A process_includes "${PKG_SOURCE_DIR}/${package}" ${df}.tmpl > ${df}
1276N/A fi
1276N/A done
1276N/A
1276N/A if [[ -f prototype ]] ; then
1276N/A # Simple package with the same prototype on all platforms
1276N/A PROTOTYPE="prototype"
1276N/A else
1276N/A # Package with some platform-specific settings in prototype
1276N/A if [[ ! -f prototype_${MACH} ]]; then
1276N/A ln -s prototype_com prototype_${MACH}
1276N/A fi
1276N/A PROTOTYPE="prototype_${MACH}"
1276N/A fi
1276N/A
1276N/A print_and_run /usr/bin/pkgmk -d ${PACKAGE_DIR}/${package} -f ${PROTOTYPE} -o ${PKGMK_VARS}
1276N/A
1276N/A print "******** Done Making the ${package} package ********"
1276N/A cd ..
1276N/Adone >$LOGfile 2>&1
1276N/A
1276N/Aprint result log is in ${PACKAGE_DIR}/$LOGfile
1276N/A
1276N/Aprint -n "Packages built: "
1276N/Agrep -c "Packaging complete" ${PACKAGE_DIR}/$LOGfile
1276N/Aprint -n "Packages failed: "
1276N/Agrep -c "Packaging was not successful" ${PACKAGE_DIR}/$LOGfile
1276N/A
1276N/A# Create an installdir with symlinks to built packages
1276N/Acd ${PACKAGE_DIR}
1276N/Amkdir installdir
1056N/Acd installdir
1056N/Afor package in ${PACKAGE_LIST} ; do
1056N/A if [[ -d ../${package}/${package} ]] ; then
1276N/A ln -s ../${package}/${package} .
1056N/A fi
1056N/Adone
1056N/Aif [[ -f ${PKG_SOURCE_DIR}/upgrade-X ]] ; then
1276N/A cp -p ${PKG_SOURCE_DIR}/upgrade-X .
1056N/A chmod a+x upgrade-X
1056N/Afi
1056N/A
1056N/Aexit 0
1056N/A