build_osnet.sh revision ead1f93ee620d7580f7e53350fe5a884fc4f158a
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# This script can be used to build the ON component of the source product.
# It should _not_ be used by developers, since it does not work with
# workspaces, or do many of the features that 'nightly' uses to help you
# (like detection errors and warnings, and send mail on completion).
#
# examine arguments. Source customers probably use no arguments, which just
# the -B flag, but the others are for use internally for testing the
# compressed cpio archives we deliver to the folks who build the source product.
#
#
# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
# under certain circumstances, which can really screw things up; unset it.
#
unset CDPATH
USAGE='build_osnet [-B dir] [-E export_archive ] [-C crypt_archive ]
[ -H binary_archive ] [-D] [-P]
where:
-B dir - set build directory
-E export_archive - create build directory from export_archive
-C crypt_archive - extract crypt_archive on top of build area
-H binary_archive - extract binary_archive on top of build area
-D - do a DEBUG build
-P - do not copy packages to /pkgs
'
BUILDAREA=`pwd`
DEBUGFLAG="n"
PKGCPFLAG="y"
OPTIND=1
do
;;
E ) EXPORT_CPIO="$OPTARG"
;;
C ) CRYPT_CPIO="$OPTARG"
;;
H ) BINARY_CPIO="$OPTARG"
;;
D ) DEBUGFLAG="y"
;;
P ) PKGCPFLAG="n"
;;
\? ) echo "$USAGE"
exit 1
;;
esac
done
# extract source
# verify you are root
if [ "$?" != "0" ]; then
exit 1
fi
if [ ! -z "${EXPORT_CPIO}" -a ! -f "${EXPORT_CPIO}" ]; then
echo "${EXPORT_CPIO} does not exist - aborting."
exit 1
fi
if [ -z "${BUILDAREA}" ]; then
echo "BUILDAREA must be set - aborting."
exit 1
fi
if [ -z "${SPRO_ROOT}" ]; then
echo
echo "If your compilers are located at a different location,"
echo "you will need to set the SPRO_ROOT variable before"
echo "you execute this script."
echo
fi
if [ -z "${JAVA_ROOT}" ]; then
fi
# in case you use dmake. Note that dmake on ON has only been
# tested in parallel make mode.
if [ -z "${DMAKE_MAX_JOBS}" ]; then
export DMAKE_MAX_JOBS
fi
################################################################
# Uncomment the line below to change to a parallel make using
# dmake. Be sure to put a "#" in front of the other make line.
# dmake can help create builds much faster, though if
# you have problems you should go back to serial make.
################################################################
#MAKE=dmake; export MAKE
#
# force locale to C
LC_COLLATE=C; export LC_COLLATE
LC_MESSAGES=C; export LC_MESSAGES
LC_MONETARY=C; export LC_MONETARY
LC_NUMERIC=C; export LC_NUMERIC
# clear environment variables we know to be bad for the build
unset LD_PRELOAD LD_PROFILE
unset CONFIG
unset GROUP
unset OWNER
unset REMOTE
unset ENV
unset ARCH
unset CLASSPATH
# set magic variables
unset RELEASE RELEASE_DATE
ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
ENVCPPFLAGS1="-I$ROOT/usr/include"
export ENVLDLIBS1 ENVLDLIBS2
export INTERNAL_RELEASE_BUILD ; INTERNAL_RELEASE_BUILD=
export RELEASE_BUILD ; RELEASE_BUILD=
unset EXTRA_OPTIONS
unset EXTRA_CFLAGS
if [ "${DEBUGFLAG}" = "y" ]; then
unset RELEASE_BUILD
fi
export PATH
if [ -z "${ROOT}" ]; then
echo "ROOT must be set - aborting."
exit 1
fi
if [ -z "${PKGARCHIVE}" ]; then
echo "PKGARCHIVE must be set - aborting."
exit 1
fi
if [ -d "${BUILDAREA}" ]; then
if [ -z "${EXPORT_CPIO}" ]; then
# clobber doesn't work on the free source product,
# since it will destroy the preinstalled object modules
# so we just comment it out for now
echo "\n==== Not clobbering in ${BUILDAREA} ====\n"
#echo "\n==== Clobbering in ${BUILDAREA} ====\n"
#cd $SRC
#rm -f clobber.out
#/bin/time ${MAKE} -e clobber | tee -a clobber.out
#find . -name SCCS -prune -o \
# \( -name '.make.*' -o -name 'lib*.a' -o -name 'lib*.so*' -o \
# -name '*.o' \) \
# -exec rm -f {} \;
else
echo "\n==== Removing ${BUILDAREA} ====\n"
sleep 15
fi
fi
if [ -d "${ROOT}" ]; then
echo "\n==== Removing ${ROOT} ====\n"
sleep 15
fi
if [ -d "${PKGARCHIVE}" ]; then
echo "\n==== Removing ${PKGARCHIVE} ====\n"
sleep 15
fi
cd ${BUILDAREA}
if [ ! -z "${EXPORT_CPIO}" ]; then
echo "\n==== Extracting export source ====\n"
fi
# hack
VERSION="Source"
else
VERSION="MODIFIED_SOURCE_PRODUCT"
fi
if [ ! -z "${CRYPT_CPIO}" -a -f "${CRYPT_CPIO}" ]; then
echo "\n==== Extracting crypt source ====\n"
VERSION="Source:Crypt"
echo "\n==== Performing crypt build ====\n"
elif [ ! -z "${BINARY_CPIO}" -a -f "${BINARY_CPIO}" ]; then
echo "\n==== Extracting binary modules ====\n"
VERSION="MODIFIED_SOURCE_PRODUCT"
echo "\n==== Performing hybrid build ====\n"
else
VERSION="Source:Export"
echo "\n==== Performing export build ====\n"
fi
export VERSION
echo "\n==== Disk space used (Source) ====\n"
cd ${BUILDAREA}
mkdir -p ${PKGARCHIVE}
echo "\n==== Building osnet tools ====\n"
rm -f install.out
export PATH
echo "\n==== Build environment ====\n"
if [ "${DEBUGFLAG}" = "y" ]; then
echo "\n==== Building osnet (DEBUG) ====\n"
else
echo "\n==== Building osnet ====\n"
fi
cd $SRC
rm -f install.out
echo "\n==== Build errors ====\n"
egrep -e "(${MAKE}:|[ ]error[: \n])" | \
echo "\n==== Building osnet packages ====\n"
rm -f install.out
echo "\n==== Package build errors ====\n"
grep ':' | \
cd ${BUILDAREA}
#
# Copy packages into /pkgs location
#
if [ "${PKGCPFLAG}" = "y" ]; then
echo "\n==== Copying newly built packages into /pkgs ====\n"
fi