+source /etc/profile.d/rvm.sh
+
+# 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
+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
+
+if [[ "$DEBUG" != 0 ]]; then
+ echo "umask is" `umask`
+fi
+
+# Ruby gems
+if [[ "$DEBUG" != 0 ]]; then
+ echo
+ echo "Ruby gems"
+ echo
+fi
+
+cd "$WORKSPACE"
+cd sdk/ruby
+# clean up old gems
+rm -f arvados-*gem
+
+if [[ "$DEBUG" != 0 ]]; then
+ gem build arvados.gemspec
+else
+ # -q appears to be broken in gem version 2.2.2
+ gem build arvados.gemspec -q >/dev/null
+fi
+
+if [[ "$UPLOAD" != 0 ]]; then
+ # publish new gem
+ gem push arvados-*gem
+fi
+
+# Build arvados-cli GEM
+cd "$WORKSPACE"
+cd sdk/cli
+# clean up old gems
+rm -f arvados-cli*gem
+
+if [[ "$DEBUG" != 0 ]]; then
+ gem build arvados-cli.gemspec
+else
+ # -q appears to be broken in gem version 2.2.2
+ gem build arvados-cli.gemspec -q >/dev/null
+fi
+
+if [[ "$UPLOAD" != 0 ]]; then
+ # publish new gem
+ gem push arvados-cli*gem
+fi
+
+# Python packages
+if [[ "$DEBUG" != 0 ]]; then
+ echo
+ echo "Python packages"
+ echo
+fi
+
+cd "$WORKSPACE"
+
+GIT_TIMESTAMP=`git log --first-parent --max-count=1 --format=format:%ct -n1 .`
+HUMAN_READABLE_TIMESTAMP=`TZ=UTC date -d @$GIT_TIMESTAMP +%Y%m%d%H%M%S`
+GIT_HASH=`git log --first-parent --max-count=1 --format=format:$HUMAN_READABLE_TIMESTAMP.%h -n1 .`
+
+cd sdk/python
+handle_python_package
+
+cd ../../services/fuse
+handle_python_package
+
+cd ../../services/nodemanager
+handle_python_package
+