#! /bin/ksh93
#
# Copyright (c) 1996, 2011, Oracle and/or its affiliates. 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, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# 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. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#
# Create and fill a package staging area for X
#
# This script should be run from the base of the build tree.
#
# Arguments:
# -v Enable verbose mode
# -p <publisher> Set publisher name in built repo to <publisher>
#
# Make sure that we aren't affected by the personal environment of
# whoever is running this script
PATH=/usr/bin:/usr/ccs/bin:/opt/onbld/bin:${PATH}
SHELL=/bin/ksh93
export PATH
progname="$0"
function fatal_error
{
print -u2 "${progname}: ERROR: $*"
exit 1
}
# Path to directory in build tree containing build tools
BUILD_TOOLS="$(pwd)/open-src/util/build-tools/"
VERBOSE_FLAGS="" # verbosity flags passed to make
PUBLISHER_FLAGS="" # publisher flags passed to make
set -- $(getopt p:v $*)
if [ $? != 0 ] ; then
print -u2 USAGE: $0 [-v]
exit 2
fi
for i in $* ; do
case $i in
-p) PUBLISHER_FLAGS="PKGPUBLISHER=$2"; shift 2;;
-v) VERBOSE_FLAGS="-v"; shift;;
esac
done
[ -d log ] || mkdir log
LOG="$(pwd)/log/make-pkgs"
CHECK_LOG="$(pwd)/log/check-pkgs"
# Get build version from hg by searching for most recent tag matching s11u*
BUILD_TAG="$(hg parent --template '{latesttag}\n' | \
perl -l -n -e 'if ($_ =~ m/^s11u\d+_\d+/) {print $_}')"
if [[ -z "${BUILD_TAG}" ]] ; then
fatal_error "BUILD_TAG could not be found from hg parent"
fi
print "Building packages for X Consolidation, build ${BUILD_TAG}"
MACH="$(uname -p)"
# Remove old packages
/bin/rm -rf "proto/pkg_${MACH}"
XMAKE="${BUILD_TOOLS}/xmake ${VERBOSE_FLAGS} -k"
cd pkg
${XMAKE} clean > "${LOG}" 2>&1
${XMAKE} install "${PUBLISHER_FLAGS}" > "${LOG}" 2>&1
print "Result log is in ${LOG}"
print "Checking built packages"
${XMAKE} check > "${CHECK_LOG}" 2>&1
print "Package check log is in ${CHECK_LOG}"
"${BUILD_TOOLS}/find-build-errors" -s "${LOG}"
exit 0