Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 342 lines (301 sloc) 10.938 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
#!/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} || 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/gcc/4.4.4/bin/gcc"
if [ ! -f "/opt/gcc/4.4.4/bin/gcc" ]; then
if [ ! -z "${GCC44_URL}" ]; then
cd /opt
    curl -k ${GCC44_URL} | bzcat | ${ROOTCMD} tar -xf -
    cd - >/dev/null
  else
echo "FATAL: unable to download gcc 4.4.4, no URL is set. Please set GCC44_URL in configure."
    exit 1
  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 && 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"

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
if [[ -z "${HUDSON_SERVER_COOKIE}" ]]; then
LOCKNAME="\`whoami\`_\`basename \$CODEMGR_WS\`_nightly.lock"; export LOCKNAME
else
LOCKNAME="\`whoami\`_\`basename \$CODEMGR_WS\`_nightly-${HUDSON_SERVER_COOKIE}.lock"; export LOCKNAME
fi
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
export GCC_ROOT=/opt/gcc/4.4.4; # 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

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
Something went wrong with that request. Please try again.