Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tag: 20121115
Fetching contributors…

Cannot retrieve contributors at this time

executable file 332 lines (290 sloc) 10.645 kB
#!/usr/bin/env bash
#
# Copyright (c) 2010-2012 Joyent Inc.
#
set -o errexit
GLOBAL_ZONE=1
if [[ $(uname -s) != "SunOS" ]]; then
echo "FATAL: This only works with SunOS/SmartOS"
exit 1
fi
if [[ $(zonename) != "global" ]]; then
echo "NOTICE: Building in a zone, workarounds enabled!"
GLOBAL_ZONE=0
fi
INSTALL_BIN_LINK_DIR=/usr/bin
HAVE_PKG="true"
ROOTCMD=pfexec
# illumos-extra is now in github but git's ssl doesn't always work in our build machines.
export GIT_SSL_NO_VERIFY=true
# Load all site-specific configure files
for file in `ls configure.*`; do
source ${file}
done
if [ "${HAVE_PKG}" == "true" ]; then
echo "==> Installing illumos build dependencies..."
if [[ ${GLOBAL_ZONE} -eq 1 ]]; then
${ROOTCMD} pkg install \
text/groff \
system/zones/internal \
library/libxml2 \
developer/gnome/gettext \
library/python-2/setuptools-26 \
library/gnome/gnome-vfs \
runtime/perl-510 \
runtime/perl-510/extra \
developer/build/gnu-make \
developer/build/onbld \
developer/gcc-3 \
developer/astdev \
developer/lexer/flex \
library/nspr/header-nspr \
system/library/mozilla-nss/header-nss \
data/docbook \
text/gnu-gettext \
developer/java/jdk \
|| /bin/true
else
# nonglobal Zone
for pkg in gmake binutils autoconf automake \
bison flex libtool-base python24 p5-XML-Parser \
libxslt gcc-compiler sun-jre6 sun-jdk6 gmp mpfr nodejs; do
pkg_info -qe ${pkg} || ${ROOTCMD} pkgin -y install ${pkg}
done
fi
fi
# TODO: move this to illumos-extra itself
if [ "${HAVE_PKG}" == "true" ]; then
echo "==> Installing illumos-extra dependencies..."
if [[ ${GLOBAL_ZONE} -eq 1 ]]; then
${ROOTCMD} pkg install \
compatibility/ucb \
developer/build/autoconf \
developer/build/automake-19 \
developer/build/automake-110 \
developer/build/cmake \
developer/build/libtool \
developer/parser/bison \
library/libevent \
|| /bin/true
else
# nonglobal Zone
/bin/true
fi
fi
echo "==> Checking for /opt/SUNWspro/bin/cc..."
echo " +--> Ensuring SUNWspro installed in /opt/SUNWspro..."
if [ ! -f "/opt/SUNWspro/prod/bin/cc" ]; then
if [ ! -z "${SUNW_SPRO12_URL}" ]; then
(cd /opt/ \
&& curl -k "${SUNW_SPRO12_URL}" \
| ${ROOTCMD} gtar -jxf -)
else
echo "FATAL: unable to download sunstudio12, no URL is set. Please set SUNW_SPRO12_URL in configure.*"
exit 1
fi
fi
[[ -e /opt/SUNWspro/sunstudio12.1 ]] || (cd /opt/SUNWspro && ${ROOTCMD} ln -s . sunstudio12.1)
if [[ ${GLOBAL_ZONE} -eq 1 ]]; then
echo "==> Creating the missing symlinks..."
test -f /usr/bin/aclocal || ${ROOTCMD} ln -s /usr/bin/aclocal-1.10 /usr/bin/aclocal
test -f /usr/bin/automake || ${ROOTCMD} ln -s /usr/bin/automake-1.10 /usr/bin/automake
# so builds can use --mode and such
test -f /usr/bin/install || ${ROOTCMD} ln -s /usr/bin/ginstall /usr/bin/install
test -f /usr/bin/pod2man || ${ROOTCMD} ln -s /usr/perl5/5.10.0/bin/pod2man /usr/bin/pod2man
else
# nonglobal Zone
/bin/true
fi
echo "==> Populating projects/ directories..."
[ ! -d "projects" ] && mkdir -p projects
if [ ! -d "projects" ] ; then
echo "FATAL: unable to create projects/ directory."
exit 1
fi
if [ ! -f "projects/illumos/usr/src/tools/env/illumos.sh" ]; then
echo " +--> Getting illumos source tree..."
if [ -z "${GET_ILLUMOS}" ]; then
echo "FATAL: No GET_ILLUMOS defined in configure.*, can't get illumos!"
exit 1
fi
/bin/bash -c "cd projects && ${GET_ILLUMOS} && cd -"
if [ ! -f "projects/illumos/usr/src/tools/env/illumos.sh" ]; then
echo "FATAL: GET_ILLUMOS command failed to get illumos!"
exit 1
fi
fi
#
# The adjunct tarball contains headers and libraries against which runtime
# dependencies will be encoded into our delivered objects. It should not
# exist but is essential until illumos becomes self-contained.
#
if [[ -z "${ILLUMOS_ADJUNCT_TARBALL_URL}" ]]; then
echo "FATAL: No ILLUMOS_ADJUNCT_TARBALL_URL defined in configure.*"
exit 1
fi
ADJUNCT_TARBALL="$(curl -k ${ILLUMOS_ADJUNCT_TARBALL_URL} | \
grep href | tail -n1 | cut -d '"' -f2)"
if [[ -z "${ADJUNCT_TARBALL}" ]]; then
echo "FATAL: Unable to list adjunct from ILLUMOS_ADJUNCT_TARBALL_URL"
exit 1
fi
curl -k -O ${ILLUMOS_ADJUNCT_TARBALL_URL}/${ADJUNCT_TARBALL}
if [[ $? != 0 ]]; then
echo "FATAL: Unable to get adjuncts from ILLUMOS_ADJUNCT_TARBALL_URL"
exit 1
fi
if [[ ! -f "projects/illumos-extra/Makefile" ]]; then
echo " +--> Getting illumos-extra source tree..."
if [ -z "${GET_ILLUMOS_EXTRA}" ]; then
echo "FATAL: No GET_ILLUMOS_EXTRA defined in configure.*, can't get illumos-extra!"
exit 1
fi
/bin/bash -c "cd projects && ${GET_ILLUMOS_EXTRA} && cd -"
if [ ! -f "projects/illumos-extra/Makefile" ]; then
echo "FATAL: GET_ILLUMOS_EXTRA command failed to get illumos-extra!"
exit 1
fi
fi
ROOT=`pwd`
echo "==> Setting up overlay"
if [ -z "${OVERLAYS}" ]; then
echo "FATAL: overlay order not specified"
exit 1
fi
rm -f ${ROOT}/overlay/order
touch ${ROOT}/overlay/order
for entry in ${OVERLAYS}; do
echo -n "${ROOT}/overlay/${entry} " >> ${ROOT}/overlay/order
done
echo "==> Setting up illumos-gate"
cd ${ROOT}/projects/illumos
if [ ! -f on-closed-bins.i386.tar.bz2 ]; then
if [ -z "${ON_CLOSED_BINS_URL}" ]; then
curl -O http://dlc.sun.com/osol/on/downloads/20100817/on-closed-bins.i386.tar.bz2
else
curl -k -O "${ON_CLOSED_BINS_URL}"
fi
tar xvpf on-closed-bins.i386.tar.bz2
fi
if [ ! -f on-closed-bins-nd.i386.tar.bz2 ]; then
if [ -z "${ON_CLOSED_BINS_ND_URL}" ]; then
curl -O http://dlc.sun.com/osol/on/downloads/20100817/on-closed-bins-nd.i386.tar.bz2
else
curl -k -O "${ON_CLOSED_BINS_ND_URL}"
fi
tar xvpf on-closed-bins-nd.i386.tar.bz2
fi
#
# Use environment variables to determine if we should be building debug or not,
# etc.
#
# ILLUMOS_ENABLE_LINT
# ILLUMOS_ENABLE_DEBUG=yes|exclusive
#
# ENABLE_LINT implies ENABLE_DEBUG=yes
#
NIGHTLY_OPTIONS_BASE="-CimNnt"
NIGHTLY_EXTRA=""
NIGHTLY_DEBUG=0
ENABLE_LINT=0
if [[ "$ILLUMOS_ENABLE_LINT" != "" ]]; then
ENABLE_LINT=1
ENABLE_DEBUG=1
fi
if [[ "$ILLUMOS_ENABLE_DEBUG" == "yes" ]]; then
ENABLE_DEBUG=1
elif [[ "$ILLUMOS_ENABLE_DEBUG" == "exclusive" ]]; then
ENABLE_DEBUG=2
elif [[ "$ILLUMOS_ENABLE_DEBUG" != "" ]]; then
echo "Unknown value for ILLUMOS_ENABLE_DEBUG: $ILLUMOS_ENABLE_DEBUG"
echo "Aborting configure."
exit 1
fi
[[ $ENABLE_LINT -eq 1 ]] && NIGHTLY_EXTRA="l"
[[ $ENABLE_DEBUG -eq 1 ]] && NIGHTLY_EXTRA=$NIGHTLY_EXTRA"D"
[[ $ENABLE_DEBUG -eq 2 ]] && NIGHTLY_EXTRA=$NIGHTLY_EXTRA"DF"
LOCKUNIQ=$(echo ${ROOT} | tr / _)
cat <<EOF> illumos.sh
NIGHTLY_OPTIONS="$NIGHTLY_OPTIONS_BASE$NIGHTLY_EXTRA"; export NIGHTLY_OPTIONS
GATE="${RELEASE_VER}"; export GATE
CODEMGR_WS="${ROOT}/projects/illumos"; export CODEMGR_WS
maxjobs() {
ncpu=\`kstat -p cpu_info:::state | grep -c on-line\`
expr \$ncpu + 2
}
DMAKE_MAX_JOBS=\`maxjobs\`; export DMAKE_MAX_JOBS
ONBLD_BIN="/opt/onbld/bin"
PARENT_WS=""; export PARENT_WS
CLONE_WS="http://hg.illumos.org/illumos-gate"
export CLONE_WS
STAFFER=nobody; export STAFFER
MAILTO=$STAFFER; export MAILTO
BUILD_PROJECT=; export BUILD_PROJECT
LOCKNAME="\`whoami\`_${LOCKUNIQ}_nightly.lock"; export LOCKNAME
ATLOG="\$CODEMGR_WS/log"; export ATLOG
LOGFILE="\$ATLOG/nightly.log"; export LOGFILE
MACH=\`uname -p\`; export MACH
ON_CLOSED_BINS="\$CODEMGR_WS/closed"; export ON_CLOSED_BINS
ON_CRYPTO_BINS="\$CODEMGR_WS/on-crypto.\$MACH.tar.bz2"; export ON_CRYPTO_BINS
REF_PROTO_LIST=\$PARENT_WS/usr/src/proto_list_\${MACH}; export REF_PROTO_LIST
ROOT="${ROOT}/proto"; export ROOT
ADJUNCT_PROTO="${ROOT}/proto.strap"; export ADJUNCT_PROTO
NATIVE_ADJUNCT="/opt/local"; export NATIVE_ADJUNCT
SRC="\$CODEMGR_WS/usr/src"; export SRC
VERSION="\$GATE"; export VERSION
PARENT_ROOT="${ROOT}/proto"; export PARENT_ROOT
PARENT_TOOLS_ROOT=\$PARENT_WS/usr/src/tools/proto/root_\$MACH-nd; export PARENT_TOOLS_ROOT
PKGARCHIVE="\${CODEMGR_WS}/packages/\${MACH}/nightly"; export PKGARCHIVE
PKGPUBLISHER_REDIST="${PUBLISHER}"; export PKGPUBLISHER_REDIST
MAKEFLAGS=k; export MAKEFLAGS
UT_NO_USAGE_TRACKING="1"; export UT_NO_USAGE_TRACKING
CW_NO_SHADOW="1"; export CW_NO_SHADOW
BUILD_TOOLS="\${CODEMGR_WS}/usr/src/tools/proto/root_\${MACH}-nd/opt"; export BUILD_TOOLS
SPRO_ROOT=/opt/SUNWspro; export SPRO_ROOT
SPRO_VROOT=\$SPRO_ROOT; export SPRO_VROOT
GNU_ROOT="${ROOT}/proto.strap/usr/gnu" export GNU_ROOT
export GCC_ROOT=${ROOT}/proto.strap/usr; # Where to find GCC4.x
export CW_GCC_DIR=\${GCC_ROOT}/bin; # A temporary hack to allow bootstrap of cw(1)
export __GNUC=""; # Use GCC as the primary compiler
export __GNUC4=""; # Use GCC4 specific flags
JAVA_ROOT=/opt/local/java/sun6; export JAVA_ROOT
FLEX=/opt/local/bin/flex; export FLEX
EOF
# For some reason this disappeared before
touch ${ROOT}/projects/illumos/usr/src/tools/findunref/exception_list.unknown
function update_branch
{
target_dir=$1
target=$2
oldwd=$(pwd)
cd ${target_dir}
current=$(git branch | grep "^*" | cut -d' ' -f2)
if [[ "${current}" != "${target}" ]]; then
git checkout ${target}
fi
cd ${oldwd}
return 0
}
# Setup branches
if [[ -f ${ROOT}/configure-branches ]]; then
branch=$(grep "^illumos-live: " ${ROOT}/configure-branches | cut -d' ' -f2)
[[ -z ${branch} ]] && update_branch "${ROOT}" ${branch}
branch=$(grep "^illumos-extra: " ${ROOT}/configure-branches | cut -d' ' -f2)
[[ -z ${branch} ]] && update_branch "${ROOT}/projects/illumos-extra" ${branch}
branch=$(grep "^illumos-joyent: " ${ROOT}/configure-branches | cut -d' ' -f2)
[[ -z ${branch} ]] && update_branch "${ROOT}/projects/illumos" ${branch}
branch=$(grep "^kvm: " ${ROOT}/configure-branches | cut -d' ' -f2)
[[ -z ${branch} ]] && update_branch "${ROOT}/projects/local/kvm" ${branch}
branch=$(grep "^kvm-cmd: " ${ROOT}/configure-branches | cut -d' ' -f2)
[[ -z ${branch} ]] && update_branch "${ROOT}/projects/local/kvm-cmd" ${branch}
else
echo ""
echo "WARNING! No configure-branches file!!! Using master branch for everything!"
echo ""
sleep 3
fi
echo ""
echo "Configuration complete. You should now be able to build a live image using 'gmake world && gmake live'"
echo ""
exit 0
Jump to Line
Something went wrong with that request. Please try again.