[ARVADOS-DEV] created: d9b63321261cbc98a50166981213342b7c0b91f1

git at public.curoverse.com git at public.curoverse.com
Mon Aug 31 17:05:28 EDT 2015


        at  d9b63321261cbc98a50166981213342b7c0b91f1 (commit)


commit d9b63321261cbc98a50166981213342b7c0b91f1
Author: Ward Vandewege <ward at curoverse.com>
Date:   Mon Aug 31 17:04:23 2015 -0400

    Add build script for the new Arvados SSO server package.
    
    Also make the run-build-packages-all-targets.sh script a bit smarter so
    that we can use it to build the SSO server package.
    
    Add a run-build-packages-one-target.sh script to build any of our
    Arvados packages for just one target.
    
    refs #6939

diff --git a/jenkins/arvados-sso-server-extras/arvados-sso-server-upgrade.sh b/jenkins/arvados-sso-server-extras/arvados-sso-server-upgrade.sh
new file mode 100755
index 0000000..1a377dc
--- /dev/null
+++ b/jenkins/arvados-sso-server-extras/arvados-sso-server-upgrade.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+set -e
+
+if [ -e /etc/redhat-release ]; then
+    WWW_OWNER=nginx:nginx
+else
+    # Assume we're on a Debian-based system for now.
+    WWW_OWNER=www-data:www-data
+fi
+
+NGINX_SERVICE=${NGINX_SERVICE:-$(service --status-all 2>/dev/null \
+    | grep -Eo '\bnginx[^[:space:]]*' || true)}
+if [ -z "$NGINX_SERVICE" ]; then
+    cat >&2 <<EOF
+Error: nginx service not found. Aborting.
+Set NGINX_SERVICE to the name of the service hosting the Rails server.
+EOF
+    exit 1
+elif [ "$NGINX_SERVICE" != "$(echo "$NGINX_SERVICE" | head -n 1)" ]; then
+    cat >&2 <<EOF
+Error: multiple nginx services found. Aborting.
+Set NGINX_SERVICE to the name of the service hosting the Rails server.
+EOF
+    exit 1
+fi
+
+RELEASE_PATH=/var/www/arvados-sso/current
+SHARED_PATH=/var/www/arvados-sso/shared
+CONFIG_PATH=/etc/arvados/sso/
+
+echo
+echo "Assumption: $NGINX_SERVICE is configured to serve your SSO server URL from"
+echo "            /var/www/arvados-sso/current"
+echo "Assumption: configuration files are in /etc/arvados/sso/"
+echo "Assumption: $NGINX_SERVICE and passenger run as $WWW_OWNER"
+echo
+
+echo "Copying files from $CONFIG_PATH ..."
+cp -f $CONFIG_PATH/database.yml $RELEASE_PATH/config/database.yml
+cp -f $RELEASE_PATH/config/environments/production.rb.example $RELEASE_PATH/config/environments/production.rb
+cp -f $CONFIG_PATH/application.yml $RELEASE_PATH/config/application.yml
+echo "... done."
+
+# Before we do anything else, make sure some directories and files are in place
+if [[ ! -e $SHARED_PATH/log ]]; then mkdir -p $SHARED_PATH/log; fi
+if [[ ! -e $RELEASE_PATH/tmp ]]; then mkdir -p $RELEASE_PATH/tmp; fi
+if [[ ! -e $RELEASE_PATH/log ]]; then ln -s $SHARED_PATH/log $RELEASE_PATH/log; fi
+if [[ ! -e $SHARED_PATH/log/production.log ]]; then touch $SHARED_PATH/log/production.log; fi
+
+cd "$RELEASE_PATH"
+export RAILS_ENV=production
+
+echo "Running bundle install ..."
+bundle install --path $SHARED_PATH/vendor_bundle --quiet
+echo "... done."
+
+echo "Ensuring directory and file permissions ..."
+# Ensure correct ownership of a few files
+chown "$WWW_OWNER" $RELEASE_PATH/config/environment.rb
+chown "$WWW_OWNER" $RELEASE_PATH/config.ru
+chown "$WWW_OWNER" $RELEASE_PATH/config/database.yml
+chown "$WWW_OWNER" $RELEASE_PATH/Gemfile.lock
+chown -R "$WWW_OWNER" $RELEASE_PATH/tmp
+chown -R "$WWW_OWNER" $SHARED_PATH/log
+chown "$WWW_OWNER" $RELEASE_PATH/db/schema.rb
+chmod 644 $SHARED_PATH/log/*
+echo "... done."
+
+# If we use `grep -q`, rake will write a backtrace on EPIPE.
+if bundle exec rake db:migrate:status | grep '^database: ' >/dev/null; then
+    echo "Starting db:migrate ..."
+    bundle exec rake db:migrate
+elif [ 0 -eq ${PIPESTATUS[0]} ]; then
+    # The database exists, but the migrations table doesn't.
+    echo "Setting up database ..."
+    bundle exec rake db:schema:load db:seed
+else
+    echo "Error: Database is not ready to set up. Aborting." >&2
+    exit 1
+fi
+echo "... done."
+
+echo "Precompiling assets ..."
+# precompile assets; thankfully this does not take long
+bundle exec rake assets:precompile -q -s
+echo "... done."
+
+echo "Restarting nginx ..."
+service "$NGINX_SERVICE" restart
+echo "... done."
diff --git a/jenkins/arvados-sso-server-extras/postinst.sh b/jenkins/arvados-sso-server-extras/postinst.sh
new file mode 100755
index 0000000..ffd9b14
--- /dev/null
+++ b/jenkins/arvados-sso-server-extras/postinst.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+cd /var/www/arvados-sso
+
+chown -R www-data:www-data tmp >/dev/null 2>&1
+chown -R www-data:www-data log >/dev/null 2>&1
+chown www-data:www-data db/schema.rb >/dev/null 2>&1
+chmod 644 log/* >/dev/null 2>&1
+
+# Errors above are not serious
+exit 0
+
diff --git a/jenkins/arvados-sso-server-extras/prerm.sh b/jenkins/arvados-sso-server-extras/prerm.sh
new file mode 100755
index 0000000..b1280b8
--- /dev/null
+++ b/jenkins/arvados-sso-server-extras/prerm.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+RELEASE_PATH=/var/www/arvados-sso/current
+rm -f $RELEASE_PATH/config/database.yml
+rm -f $RELEASE_PATH/config/environments/production.rb
+rm -f $RELEASE_PATH/config/application.yml
+rm -rf $RELEASE_PATH/public/assets/
+rm -rf $RELEASE_PATH/tmp
+rm $RELEASE_PATH/log
+
diff --git a/jenkins/run-build-packages-all-targets.sh b/jenkins/run-build-packages-all-targets.sh
index 2761f9f..3ddb4ba 100755
--- a/jenkins/run-build-packages-all-targets.sh
+++ b/jenkins/run-build-packages-all-targets.sh
@@ -4,10 +4,13 @@ read -rd "\000" helpmessage <<EOF
 $(basename $0): Orchestrate run-build-packages.sh for every target
 
 Syntax:
-        WORKSPACE=/path/to/arvados $(basename $0)
+        WORKSPACE=/path/to/arvados $(basename $0) [options]
 
 WORKSPACE=path         Path to the Arvados source tree to build packages from
 
+--command
+    Build command to execute (default: use built-in Docker image command)
+
 EOF
 
 if ! [[ -n "$WORKSPACE" ]]; then
@@ -18,15 +21,60 @@ if ! [[ -n "$WORKSPACE" ]]; then
   exit 1
 fi
 
+if ! [[ -d "$WORKSPACE" ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: $WORKSPACE is not a directory"
+  echo >&2
+  exit 1
+fi
+
 set -e
 
+PARSEDOPTS=$(getopt --name "$0" --longoptions \
+    help,command: \
+    -- "" "$@")
+if [ $? -ne 0 ]; then
+    exit 1
+fi
+
+COMMAND=
+
+eval set -- "$PARSEDOPTS"
+while [ $# -gt 0 ]; do
+    case "$1" in
+        --help)
+            echo >&2 "$helpmessage"
+            echo >&2
+            exit 1
+            ;;
+        --command)
+            COMMAND="$2"; shift
+            ;;
+        --)
+            if [ $# -gt 1 ]; then
+                echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
+                exit 1
+            fi
+            ;;
+    esac
+    shift
+done
+
+if [[ "$COMMAND" != "" ]]; then
+  COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND"
+fi
+
 FINAL_EXITCODE=0
 JENKINS_DIR=$(dirname "$(readlink -e "$0")")
 
 run_docker() {
     local tag=$1; shift
+    if [[ "$COMMAND" != "" ]]; then
+      COMMAND="$COMMAND --target $tag"
+    fi
     if docker run -v "$JENKINS_DIR:/jenkins" -v "$WORKSPACE:/arvados" \
-          --env ARVADOS_DEBUG=1 "arvados/build:$tag"; then
+          --env ARVADOS_DEBUG=1 "arvados/build:$tag" $COMMAND; then
         # Success - nothing more to do.
         true
     else
diff --git a/jenkins/run-build-packages-one-target.sh b/jenkins/run-build-packages-one-target.sh
new file mode 100755
index 0000000..ea0718e
--- /dev/null
+++ b/jenkins/run-build-packages-one-target.sh
@@ -0,0 +1,104 @@
+#!/bin/bash
+
+read -rd "\000" helpmessage <<EOF
+$(basename $0): Orchestrate run-build-packages.sh for one target
+
+Syntax:
+        WORKSPACE=/path/to/arvados $(basename $0) [options]
+
+--target <target>
+    Distribution to build packages for (default: debian7)
+--command
+    Build command to execute (default: use built-in Docker image command)
+
+WORKSPACE=path         Path to the Arvados source tree to build packages from
+
+EOF
+
+if ! [[ -n "$WORKSPACE" ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: WORKSPACE environment variable not set"
+  echo >&2
+  exit 1
+fi
+
+if ! [[ -d "$WORKSPACE" ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: $WORKSPACE is not a directory"
+  echo >&2
+  exit 1
+fi
+
+PARSEDOPTS=$(getopt --name "$0" --longoptions \
+    help,target:,command: \
+    -- "" "$@")
+if [ $? -ne 0 ]; then
+    exit 1
+fi
+
+TARGET=debian7
+COMMAND=
+
+eval set -- "$PARSEDOPTS"
+while [ $# -gt 0 ]; do
+    case "$1" in
+        --help)
+            echo >&2 "$helpmessage"
+            echo >&2
+            exit 1
+            ;;
+        --target)
+            TARGET="$2"; shift
+            ;;
+        --command)
+            COMMAND="$2"; shift
+            ;;
+        --)
+            if [ $# -gt 1 ]; then
+                echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
+                exit 1
+            fi
+            ;;
+    esac
+    shift
+done
+
+set -e
+
+if [[ "$COMMAND" != "" ]]; then
+  COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET"
+fi
+
+FINAL_EXITCODE=0
+JENKINS_DIR=$(dirname "$(readlink -e "$0")")
+
+run_docker() {
+    local tag=$1; shift
+    if docker run -v "$JENKINS_DIR:/jenkins" -v "$WORKSPACE:/arvados" \
+          --env ARVADOS_DEBUG=1 "arvados/build:$tag" $COMMAND; then
+        # Success - nothing more to do.
+        true
+    else
+        FINAL_EXITCODE=$?
+        echo "ERROR: $tag build failed with exit status $FINAL_EXITCODE." >&2
+    fi
+}
+
+# In case it's needed, build the container. This costs just a few
+# seconds when the container already exist, so it's not a big deal to
+# do it on each run.
+cd "$JENKINS_DIR/dockerfiles"
+echo $TARGET
+cd $TARGET
+time docker build -t arvados/build:$TARGET .
+cd ..
+
+run_docker $TARGET
+
+#for dockerfile_path in $(find -name Dockerfile); do
+#    run_docker "$(basename $(dirname "$dockerfile_path"))"
+#done
+
+exit $FINAL_EXITCODE
diff --git a/jenkins/run-build-packages-sso.sh b/jenkins/run-build-packages-sso.sh
new file mode 100755
index 0000000..141db2b
--- /dev/null
+++ b/jenkins/run-build-packages-sso.sh
@@ -0,0 +1,277 @@
+#!/bin/bash
+
+
+read -rd "\000" helpmessage <<EOF
+$(basename $0): Build Arvados SSO package
+
+Syntax:
+        WORKSPACE=/path/to/arvados-sso $(basename $0) [options]
+
+Options:
+
+--build-bundle-packages  (default: false)
+    Build package with vendor/bundle included
+--debug
+    Output debug information (default: false)
+--target
+    Distribution to build packages for (default: debian7)
+
+WORKSPACE=path         Path to the Arvados SSO source tree to build packages from
+
+EOF
+
+EXITCODE=0
+DEBUG=${ARVADOS_DEBUG:-0}
+BUILD_BUNDLE_PACKAGES=0
+TARGET=debian7
+
+PARSEDOPTS=$(getopt --name "$0" --longoptions \
+    help,build-bundle-packages,debug,target: \
+    -- "" "$@")
+if [ $? -ne 0 ]; then
+    exit 1
+fi
+
+eval set -- "$PARSEDOPTS"
+while [ $# -gt 0 ]; do
+    case "$1" in
+        --help)
+            echo >&2 "$helpmessage"
+            echo >&2
+            exit 1
+            ;;
+        --target)
+            TARGET="$2"; shift
+            ;;
+        --debug)
+            DEBUG=1
+            ;;
+        --build-bundle-packages)
+            BUILD_BUNDLE_PACKAGES=1
+            ;;
+        --)
+            if [ $# -gt 1 ]; then
+                echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
+                exit 1
+            fi
+            ;;
+    esac
+    shift
+done
+
+STDOUT_IF_DEBUG=/dev/null
+STDERR_IF_DEBUG=/dev/null
+DASHQ_UNLESS_DEBUG=-q
+if [[ "$DEBUG" != 0 ]]; then
+    STDOUT_IF_DEBUG=/dev/stdout
+    STDERR_IF_DEBUG=/dev/stderr
+    DASHQ_UNLESS_DEBUG=
+fi
+
+debug_echo () {
+    echo "$@" >"$STDOUT_IF_DEBUG"
+}
+
+case "$TARGET" in
+    debian7)
+        FORMAT=deb
+        ;;
+    debian8)
+        FORMAT=deb
+        ;;
+    ubuntu1204)
+        FORMAT=deb
+        ;;
+    ubuntu1404)
+        FORMAT=deb
+        ;;
+    centos6)
+        FORMAT=rpm
+        ;;
+    *)
+        echo -e "$0: Unknown target '$TARGET'.\n" >&2
+        exit 1
+        ;;
+esac
+
+
+if ! [[ -n "$WORKSPACE" ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: WORKSPACE environment variable not set"
+  echo >&2
+  exit 1
+fi
+
+if ! [[ -d "$WORKSPACE" ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: $WORKSPACE is not a directory"
+  echo >&2
+  exit 1
+fi
+
+# Test for fpm
+fpm --version >/dev/null 2>&1
+
+if [[ "$?" != 0 ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: fpm not found"
+  echo >&2
+  exit 1
+fi
+
+RUN_BUILD_PACKAGES_PATH="`dirname \"$0\"`"
+RUN_BUILD_PACKAGES_PATH="`( cd \"$RUN_BUILD_PACKAGES_PATH\" && pwd )`"  # absolutized and normalized
+if [ -z "$RUN_BUILD_PACKAGES_PATH" ] ; then
+  # error; for some reason, the path is not accessible
+  # to the script (e.g. permissions re-evaled after suid)
+  exit 1  # fail
+fi
+
+debug_echo "$0 is running from $RUN_BUILD_PACKAGES_PATH"
+debug_echo "Workspace is $WORKSPACE"
+
+format_last_commit_here() {
+    local format=$1; shift
+    TZ=UTC git log -n1 --first-parent "--format=format:$format" .
+}
+
+version_from_git() {
+  # Generates a version number from the git log for the current working
+  # directory, and writes it to stdout.
+  local git_ts git_hash
+  declare $(format_last_commit_here "git_ts=%ct git_hash=%h")
+  echo "0.1.$(date -ud "@$git_ts" +%Y%m%d%H%M%S).$git_hash"
+}
+
+nohash_version_from_git() {
+    version_from_git | cut -d. -f1-3
+}
+
+timestamp_from_git() {
+    format_last_commit_here "%ct"
+}
+
+# verify build results
+fpm_verify () {
+  FPM_EXIT_CODE=$1
+  shift
+  FPM_RESULTS=$@
+
+  FPM_PACKAGE_NAME=''
+  if [[ $FPM_RESULTS =~ ([A-Za-z0-9_\.-]*\.)(deb|rpm) ]]; then
+    FPM_PACKAGE_NAME=${BASH_REMATCH[1]}${BASH_REMATCH[2]}
+  fi
+
+  if [[ "$FPM_PACKAGE_NAME" == "" ]]; then
+    EXITCODE=1
+    echo "Error: $PACKAGE: Unable to figure out package name from fpm results:"
+    echo
+    echo $FPM_RESULTS
+    echo
+  elif [[ "$FPM_RESULTS" =~ "File already exists" ]]; then
+    echo "Package $FPM_PACKAGE_NAME exists, not rebuilding"
+  elif [[ 0 -ne "$FPM_EXIT_CODE" ]]; then
+    echo "Error building package for $1:\n $FPM_RESULTS"
+  fi
+}
+
+if [[ -f /etc/profile.d/rvm.sh ]]; then
+    source /etc/profile.d/rvm.sh
+    GEM="rvm-exec default gem"
+else
+    GEM=gem
+fi
+
+# Make all files world-readable -- jenkins runs with umask 027, and has checked
+# out our git tree here
+chmod o+r "$WORKSPACE" -R
+
+# More cleanup - make sure all executables that we'll package are 755
+# No executables in the sso server package
+#find -type d -name 'bin' |xargs -I {} find {} -type f |xargs -I {} chmod 755 {}
+
+# Now fix our umask to something better suited to building and publishing
+# gems and packages
+umask 0022
+
+debug_echo "umask is" `umask`
+
+if [[ ! -d "$WORKSPACE/packages/$TARGET" ]]; then
+  mkdir -p $WORKSPACE/packages/$TARGET
+fi
+
+# Build the SSO server package
+
+cd "$WORKSPACE"
+
+SSO_VERSION=$(version_from_git)
+PACKAGE_NAME=arvados-sso
+
+if [[ ! -d "$WORKSPACE/tmp" ]]; then
+  mkdir $WORKSPACE/tmp
+fi
+
+if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
+  bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
+fi
+
+/usr/bin/git rev-parse HEAD > git-commit.version
+
+cd $WORKSPACE/packages/$TARGET
+
+# Annoyingly, we require a database.yml file for rake assets:precompile to work. So for now,
+# we do that in the upgrade script.
+# TODO: add bogus database.yml file so we can precompile the assets and put them in the
+# package. Then remove that database.yml file again. It has to be a valid file though.
+#RAILS_ENV=production RAILS_GROUPS=assets bundle exec rake assets:precompile
+
+# Append --depends X and other arguments specified by fpm-info.sh in
+# the package source dir. These are added last so they can override
+# the arguments added by this script.
+declare -a fpm_args=()
+declare -a fpm_depends=()
+FPM_INFO="$WORKSPACE/fpm-info.sh"
+if [[ -e "$FPM_INFO" ]]; then
+  debug_echo "Loading fpm overrides from $FPM_INFO"
+  source "$FPM_INFO"
+fi
+
+# This is the complete package with vendor/bundle included.
+# It's big, so we do not build it by default.
+if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
+  declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward at curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados SSO server - Arvados is a free and open source platform for big data science.'" "--license='Expat License'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}-with-bundle" "-v" "$SSO_VERSION" "-x" "var/www/arvados-sso/current/.git" "-x" "var/www/arvados-sso/current/tmp" "-x" "var/www/arvados-sso/current/log" "-x" "var/www/arvados-sso/current/vendor/cache/*" "-x" "var/www/arvados-sso/current/packages" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-sso-server-extras/postinst.sh")
+
+  for i in "${fpm_depends[@]}"; do
+    COMMAND_ARR+=('--depends' "$i")
+  done
+  COMMAND_ARR+=("${fpm_args[@]}")
+  COMMAND_ARR+=("$WORKSPACE/=/var/www/arvados-sso/current" "$RUN_BUILD_PACKAGES_PATH/arvados-sso-server-extras/arvados-sso-server-upgrade.sh=/usr/local/bin/arvados-sso-server-upgrade.sh")
+
+  debug_echo -e "\n${COMMAND_ARR[@]}\n"
+
+  FPM_RESULTS=$("${COMMAND_ARR[@]}")
+  FPM_EXIT_CODE=$?
+  fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
+fi
+
+# Build the 'bare' package without vendor/bundle.
+declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward at curoverse.com>" "--vendor='Curoverse, Inc.'" "--url='https://arvados.org'" "--description='Arvados SSO server - Arvados is a free and open source platform for big data science.'" "--license='Expat License'" "-s" "dir" "-t" "$FORMAT" "-n" "${PACKAGE_NAME}" "-v" "$SSO_VERSION" "-x" "var/www/arvados-sso/current/.git" "-x" "var/www/arvados-sso/current/tmp" "-x" "var/www/arvados-sso/current/log" "-x" "var/www/arvados-sso/current/vendor/bundle" "-x" "var/www/arvados-sso/current/vendor/cache/*" "-x" "var/www/arvados-sso/current/packages" "--after-install=$RUN_BUILD_PACKAGES_PATH/arvados-sso-server-extras/postinst.sh")
+
+
+for i in "${fpm_depends[@]}"; do
+  COMMAND_ARR+=('--depends' "$i")
+done
+COMMAND_ARR+=("${fpm_args[@]}")
+COMMAND_ARR+=("$WORKSPACE/=/var/www/arvados-sso/current" "$RUN_BUILD_PACKAGES_PATH/arvados-sso-server-extras/arvados-sso-server-upgrade.sh=/usr/local/bin/arvados-sso-server-upgrade.sh")
+debug_echo -e "\n${COMMAND_ARR[@]}\n"
+
+FPM_RESULTS=$("${COMMAND_ARR[@]}")
+FPM_EXIT_CODE=$?
+fpm_verify $FPM_EXIT_CODE $FPM_RESULTS
+
+# SSO server package build done
+
+exit $EXITCODE
diff --git a/jenkins/run-build-packages.sh b/jenkins/run-build-packages.sh
index fbd5fa5..9f7c37f 100755
--- a/jenkins/run-build-packages.sh
+++ b/jenkins/run-build-packages.sh
@@ -15,6 +15,9 @@ Options:
     Output debug information (default: false)
 --target
     Distribution to build packages for (default: debian7)
+--command
+    Build command to execute (defaults to the run command defined in the
+    Docker image)
 
 WORKSPACE=path         Path to the Arvados source tree to build packages from
 
@@ -49,6 +52,9 @@ while [ $# -gt 0 ]; do
         --build-bundle-packages)
             BUILD_BUNDLE_PACKAGES=1
             ;;
+        --command)
+            COMMAND="$2"; shift
+            ;;
         --)
             if [ $# -gt 1 ]; then
                 echo >&2 "$0: unrecognized argument '$2'. Try: $0 --help"
@@ -59,6 +65,10 @@ while [ $# -gt 0 ]; do
     shift
 done
 
+if [[ "$COMMAND" != "" ]]; then
+  COMMAND="/usr/local/rvm/bin/rvm-exec default bash /jenkins/$COMMAND --target $TARGET"
+fi
+
 STDOUT_IF_DEBUG=/dev/null
 STDERR_IF_DEBUG=/dev/null
 DASHQ_UNLESS_DEBUG=-q

commit b8568977a1c6f7ff82900291814699617f8547b1
Author: Ward Vandewege <ward at curoverse.com>
Date:   Fri Aug 28 11:37:35 2015 -0400

    Optimization: do not run bundle install for the API server package when
    we aren't including the vendor directory in the package we're building.
    
    No issue #

diff --git a/jenkins/run-build-packages.sh b/jenkins/run-build-packages.sh
index cd83513..fbd5fa5 100755
--- a/jenkins/run-build-packages.sh
+++ b/jenkins/run-build-packages.sh
@@ -584,7 +584,9 @@ if [[ ! -d "$WORKSPACE/services/api/tmp" ]]; then
 fi
 
 
-bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
+if [[ "$BUILD_BUNDLE_PACKAGES" != 0 ]]; then
+  bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
+fi
 
 /usr/bin/git rev-parse HEAD > git-commit.version
 
@@ -630,6 +632,8 @@ if [[ ! -d "$WORKSPACE/apps/workbench/tmp" ]]; then
   mkdir $WORKSPACE/apps/workbench/tmp
 fi
 
+# We need to bundle to be ready even when we build a package without vendor directory
+# because asset compilation requires it.
 bundle install --path vendor/bundle >"$STDOUT_IF_DEBUG"
 
 /usr/bin/git rev-parse HEAD > git-commit.version

commit 8379e4d518e9351212004e1d4155d8b869e727f1
Author: Ward Vandewege <ward at curoverse.com>
Date:   Fri Aug 28 09:51:43 2015 -0400

    run-build-packages-all-targets.sh should abort of WORKSPACE is not set.
    
    No issue #

diff --git a/jenkins/run-build-packages-all-targets.sh b/jenkins/run-build-packages-all-targets.sh
index a1052a9..2761f9f 100755
--- a/jenkins/run-build-packages-all-targets.sh
+++ b/jenkins/run-build-packages-all-targets.sh
@@ -1,6 +1,22 @@
 #!/bin/bash
 
-# Orchestrate run-build-packages.sh for every target.
+read -rd "\000" helpmessage <<EOF
+$(basename $0): Orchestrate run-build-packages.sh for every target
+
+Syntax:
+        WORKSPACE=/path/to/arvados $(basename $0)
+
+WORKSPACE=path         Path to the Arvados source tree to build packages from
+
+EOF
+
+if ! [[ -n "$WORKSPACE" ]]; then
+  echo >&2 "$helpmessage"
+  echo >&2
+  echo >&2 "Error: WORKSPACE environment variable not set"
+  echo >&2
+  exit 1
+fi
 
 set -e
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list