diff options
Diffstat (limited to 'omnibus/jenkins/build')
-rwxr-xr-x | omnibus/jenkins/build | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/omnibus/jenkins/build b/omnibus/jenkins/build new file mode 100755 index 0000000000..4df8bbe657 --- /dev/null +++ b/omnibus/jenkins/build @@ -0,0 +1,122 @@ +#!/bin/sh +# WARNING: REQUIRES /bin/sh +# +# - must run on /bin/sh on solaris 9 +# - must run on /bin/sh on AIX 6.x +# - if you think you are a bash wizard, you probably do not understand +# this programming language. do not touch. +# - if you are under 40, get peer review from your elders. +# +# Build you some jenkins +# + +set -e +set -x + +os=`uname -s` + +# Return truthy (which is zero) if a command does not exist +# (this is deliberately inverted because /bin/sh on Solaris does not support "if ! exists" syntax) +not_exists() { + if command -v $1 >/dev/null 2>&1; then + return 1 + else + return 0 + fi +} + +exists() { + if command -v $1 >/dev/null 2>&1; then + return 0 + else + return 1 + fi +} + +# The key used to sign RPM packages is passphrase-less +OMNIBUS_RPM_SIGNING_PASSPHRASE=notset +export OMNIBUS_RPM_SIGNING_PASSPHRASE + +if [ "x$os" = "xAIX" ]; then + # need to unset LIBPATH on AIX (like LD_LIBRARY_PATH on Solaris, Jenkins sets this (wrongly) on AIX) + unset LIBPATH +fi + +if [ -z $OMNIBUS_PROJECT_NAME ]; then + echo "OMNIBUS_PROJECT_NAME environment variable is not set!" + exit 1 +fi + +# create the build timestamp file for fingerprinting if it doesn't exist (manual build execution) +if [ ! -f build_timestamp ]; then + date > build_timestamp + echo "$BUILD_TAG / $BUILD_ID" > build_timestamp +fi + +PATH=/opt/ruby-2.1.2/bin:/opt/ruby1.9/bin:/usr/local/bin:$PATH +export PATH + +if [ "x$os" = "xAIX" ]; then + # AIX is hateful and requires a bunch of root stuff to build BFF packages + sudo rm -rf /.info || true + sudo mkdir /.info || true + sudo chown root /.info || true + sudo rm -rf /tmp/bff || true + # deinstall the bff if it got installed, can't build if it is installed + sudo installp -u $OMNIBUS_PROJECT_NAME || true + # AIX needs /opt/freeware/bin and /usr/sbin + if [ -d "/opt/freeware/bin" ]; then + PATH=/opt/freeware/bin:$PATH:/usr/sbin + export PATH + fi +fi + +# clean up our target directory +sudo rm -rf "/opt/${OMNIBUS_PROJECT_NAME}" || true +sudo mkdir -p "/opt/${OMNIBUS_PROJECT_NAME}" +# and any old package cruft from prior builds +sudo rm -f pkg/* || true + +if [ "$CLEAN" = "true" ]; then + # nuke everything, including the git cache + sudo rm -rf /var/cache/omnibus/* || true +else + # we need to nuke these from old builds in order to reliably use + # the git caching + sudo rm -rf /var/cache/omnibus/pkg/* || true + sudo rm -rf /var/cache/omnibus/src/* || true + sudo rm -f /var/cache/omnibus/build/*/*.manifest || true +fi + +# always fix up permissions +if [ "x$os" = "xAIX" ]; then + sudo chown -R root "/opt/${OMNIBUS_PROJECT_NAME}" + sudo chown -R root "/var/cache/omnibus" +else + sudo chown -R jenkins-node "/opt/${OMNIBUS_PROJECT_NAME}" || sudo chown -R jenkins "/opt/${OMNIBUS_PROJECT_NAME}" + sudo chown -R jenkins-node "/var/cache/omnibus" || sudo chown -R jenkins "/var/cache/omnibus" +fi + +# horrible hack for solaris 9 to get ffi to compile in the bundle +if [ -f "/etc/release" ]; then + # solaris /bin/sh needs the stupid || true or set -x bombs here + release=`cat /etc/release | grep 'Solaris 9' || true` + if [ "x$release" != "x" ]; then + # magic CONFIGURE_ARGS to get CFLAGS through bundle/gem install + CONFIGURE_ARGS="--with-cflags='-U__STRICT_ANSI__'" + export CONFIGURE_ARGS + fi +fi + +# docs do not install on solaris 9 +bundle install --without development + +if [ "$RELEASE_BUILD" = "true" ]; then + bundle exec omnibus build $OMNIBUS_PROJECT_NAME -l internal --override append_timestamp:false +else + bundle exec omnibus build $OMNIBUS_PROJECT_NAME -l internal +fi + +# Dump the build-generated version so the Omnitruck release script uses the +# correct version string format. +echo "`awk -v p=$OMNIBUS_PROJECT_NAME '$1 == p {print $2}' /opt/${OMNIBUS_PROJECT_NAME}/version-manifest.txt`" > pkg/BUILD_VERSION |