3793: Build Docker cleaner service in run-build-packages.sh.
[arvados-dev.git] / jenkins / run-build-packages.sh
index 105f74d25ae1adfea27d78af5c30559a56ed3241..3b9fc15ef67a297f018da099e01be10cff4b33e7 100755 (executable)
@@ -81,6 +81,16 @@ if [[ "$?" != 0 ]]; then
   exit 1
 fi
 
+if ! easy_install3 --version >/dev/null; then
+  cat >&2 <<EOF
+$helpmessage
+
+Error: easy_install3 (from python3-setuptools) not found
+
+EOF
+  exit 1
+fi
+
 if [[ "$DEBUG" != 0 ]]; then
   echo "Workspace is $WORKSPACE"
 fi
@@ -94,6 +104,15 @@ version_from_git() {
   echo "0.1.$(date -ud "@$git_ts" +%Y%m%d%H%M%S).$git_hash"
 }
 
+timestamp_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 $(TZ=UTC git log -n1 --first-parent --max-count=1 \
+      --format=format:"git_ts=%ct git_hash=%h" .)
+  echo "$git_ts"
+}
+
 handle_python_package () {
   # This function assumes the current working directory is the python package directory
   if [[ "$UPLOAD" != 0 ]]; then
@@ -121,27 +140,28 @@ build_and_scp_deb () {
   PACKAGE=$1
   shift
   # The name of the package to build.  Defaults to $PACKAGE.
-  PACKAGE_NAME=$1
+  PACKAGE_NAME=${1:-$PACKAGE}
   shift
   # Optional: the vendor of the package.  Should be "Curoverse, Inc." for
   # packages of our own software.  Passed to fpm --vendor.
   VENDOR=$1
   shift
   # The type of source package.  Passed to fpm -s.  Default "python".
-  PACKAGE_TYPE=$1
+  PACKAGE_TYPE=${1:-python}
   shift
+
+  if [ "python3" = "$PACKAGE_TYPE" ]; then
+      # fpm does not actually support this package type.  Instead we recognize
+      # it as a convenience shortcut to add several necessary arguments to
+      # fpm's command line later.
+      PACKAGE_TYPE=python
+      set -- "$@" --python-bin python3 --python-easyinstall easy_install3 \
+          --python-package-name-prefix python3
+  fi
   # Optional: the package version number.  Passed to fpm -v.
   VERSION=$1
   shift
 
-  if [[ "$PACKAGE_NAME" == "" ]]; then
-    PACKAGE_NAME=$PACKAGE
-  fi
-
-  if [[ "$PACKAGE_TYPE" == "" ]]; then
-    PACKAGE_TYPE='python'
-  fi
-
   declare -a COMMAND_ARR=("fpm" "--maintainer=Ward Vandewege <ward@curoverse.com>" "-s" "$PACKAGE_TYPE" "-t" "deb" "-x" "usr/local/lib/python2.7/dist-packages/tests")
 
   if [[ "$PACKAGE_NAME" != "$PACKAGE" ]]; then
@@ -199,7 +219,9 @@ build_and_scp_deb () {
   fi
 }
 
-source /etc/profile.d/rvm.sh
+if [[ -f /etc/profile.d/rvm.sh ]]; then
+  source /etc/profile.d/rvm.sh
+fi
 
 # Make all files world-readable -- jenkins runs with umask 027, and has checked
 # out our git tree here
@@ -367,13 +389,56 @@ go get "git.curoverse.com/arvados.git/services/keepstore"
 cd $WORKSPACE/debs
 build_and_scp_deb $GOPATH/bin/keepstore=/usr/bin/keepstore keepstore 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Keepstore is the Keep storage daemon, accessible to clients on the LAN"
 
+# Get GO SDK version
+cd "$GOPATH/src/git.curoverse.com/arvados.git/sdk/go"
+GO_SDK_VERSION=$(version_from_git)
+GO_SDK_TIMESTAMP=$(timestamp_from_git)
+
 # keepproxy
 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/keepproxy"
-PKG_VERSION=$(version_from_git)
+KEEPPROXY_VERSION=$(version_from_git)
+KEEPPROXY_TIMESTAMP=$(timestamp_from_git)
+
+if [[ "$GO_SDK_TIMESTAMP" -gt "$KEEPPROXY_TIMESTAMP" ]]; then
+  PKG_VERSION=$GO_SDK_VERSION
+else
+  PKG_VERSION=$KEEPPROXY_VERSION
+fi
+
 go get "git.curoverse.com/arvados.git/services/keepproxy"
 cd $WORKSPACE/debs
 build_and_scp_deb $GOPATH/bin/keepproxy=/usr/bin/keepproxy keepproxy 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Keepproxy makes a Keep cluster accessible to clients that are not on the LAN"
 
+# datamanager
+cd "$GOPATH/src/git.curoverse.com/arvados.git/services/datamanager"
+DATAMANAGER_VERSION=$(version_from_git)
+DATAMANAGER_TIMESTAMP=$(timestamp_from_git)
+
+if [[ "$GO_SDK_TIMESTAMP" -gt "$DATAMANAGER_TIMESTAMP" ]]; then
+  PKG_VERSION=$GO_SDK_VERSION
+else
+  PKG_VERSION=$DATAMANAGER_VERSION
+fi
+
+go get "git.curoverse.com/arvados.git/services/datamanager"
+cd $WORKSPACE/debs
+build_and_scp_deb $GOPATH/bin/datamanager=/usr/bin/arvados-data-manager arvados-data-manager 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Datamanager ensures block replication levels, reports on disk usage and determines which blocks should be deleted when space is needed."
+
+# arv-git-httpd
+cd "$GOPATH/src/git.curoverse.com/arvados.git/services/arv-git-httpd"
+ARVGITHTTPD_VERSION=$(version_from_git)
+ARVGITHTTPD_TIMESTAMP=$(timestamp_from_git)
+
+if [[ "$GO_SDK_TIMESTAMP" -gt "$ARVGITHTTPD_TIMESTAMP" ]]; then
+  PKG_VERSION=$GO_SDK_VERSION
+else
+  PKG_VERSION=$ARVGITHTTPD_VERSION
+fi
+
+go get "git.curoverse.com/arvados.git/services/arv-git-httpd"
+cd $WORKSPACE/debs
+build_and_scp_deb $GOPATH/bin/arv-git-httpd=/usr/bin/arvados-git-httpd arvados-git-httpd 'Curoverse, Inc.' 'dir' "$PKG_VERSION" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=Provides authenticated http access to Arvados-hosted git repositories."
+
 # crunchstat
 cd "$GOPATH/src/git.curoverse.com/arvados.git/services/crunchstat"
 PKG_VERSION=$(version_from_git)
@@ -389,24 +454,36 @@ build_and_scp_deb $GOPATH/bin/crunchstat=/usr/bin/crunchstat crunchstat 'Curover
 # whip up a patch and send it upstream, but that will be for another day. Ward,
 # 2014-05-15
 cd $WORKSPACE/debs
-build_and_scp_deb $WORKSPACE/sdk/python python-arvados-python-client 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/sdk/python/arvados_python_client.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados Python SDK"
+# Python version numbering is obscure. Strip dashes and replace them with dots
+# to match our other version numbers. Cf. commit 4afcb8c, compliance with PEP-440.
+build_and_scp_deb $WORKSPACE/sdk/python python-arvados-python-client 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){ gsub(/-/,".",$2); print $2 }' $WORKSPACE/sdk/python/arvados_python_client.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados Python SDK"
 
 # The FUSE driver
-# Please seem comment about --no-python-fix-name above; we stay consistent and do
+# Please see comment about --no-python-fix-name above; we stay consistent and do
 # not omit the python- prefix first.
 cd $WORKSPACE/debs
-build_and_scp_deb $WORKSPACE/services/fuse python-arvados-fuse 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/services/fuse/arvados_fuse.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Keep FUSE driver"
+# Python version numbering is obscure. Strip dashes and replace them with dots
+# to match our other version numbers. Cf. commit 4afcb8c, compliance with PEP-440.
+build_and_scp_deb $WORKSPACE/services/fuse python-arvados-fuse 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){ gsub(/-/,".",$2); print $2 }' $WORKSPACE/services/fuse/arvados_fuse.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Keep FUSE driver"
 
 # The node manager
 cd $WORKSPACE/debs
-build_and_scp_deb $WORKSPACE/services/nodemanager arvados-node-manager 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/services/nodemanager/arvados_node_manager.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados node manager"
+# Python version numbering is obscure. Strip dashes and replace them with dots
+# to match our other version numbers. Cf. commit 4afcb8c, compliance with PEP-440.
+build_and_scp_deb $WORKSPACE/services/nodemanager arvados-node-manager 'Curoverse, Inc.' 'python' "$(awk '($1 == "Version:"){ gsub(/-/,".",$2); print $2}' $WORKSPACE/services/nodemanager/arvados_node_manager.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados node manager"
+
+# The Docker image cleaner
+cd $WORKSPACE/debs
+build_and_scp_deb $WORKSPACE/services/dockercleaner arvados-docker-cleaner 'Curoverse, Inc.' 'python3' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/services/dockercleaner/arvados_docker_cleaner.egg-info/PKG-INFO)" "--url=https://arvados.org" "--description=The Arvados Docker image cleaner"
 
 # A few dependencies
 for deppkg in python-gflags pyvcf google-api-python-client oauth2client \
       pyasn1 pyasn1-modules rsa uritemplate httplib2 ws4py virtualenv \
-      pykka apache-libcloud requests six pyexecjs jsonschema; do
+      pykka apache-libcloud requests six pyexecjs jsonschema ciso8601 \
+      pycrypto backports.ssl_match_hostname; do
     build_and_scp_deb "$deppkg"
 done
+build_and_scp_deb docker-py python3-docker-py python3
 
 # cwltool from common-workflow-language. We use this in arv-run-pipeline-instance.
 # We use $WORKSPACE/common-workflow-language as the clean directory from which to build the cwltool package
@@ -435,8 +512,9 @@ CWLTOOL_VERSION=`git log --first-parent --max-count=1 --format='format:0.1.%ct.%
 
 # Build cwltool package
 cd $WORKSPACE/debs
-
-build_and_scp_deb $WORKSPACE/common-workflow-language/reference cwltool 'Common Workflow Language Working Group' 'python' "$(awk '($1 == "Version:"){print $2}' $WORKSPACE/common-workflow-language/reference/cwltool.egg-info/PKG-INFO)"
+# Python version numbering is obscure. Strip dashes and replace them with dots
+# to match our other version numbers. Cf. commit 4afcb8c, compliance with PEP-440.
+build_and_scp_deb $WORKSPACE/common-workflow-language/reference cwltool 'Common Workflow Language Working Group' 'python' "$(awk '($1 == "Version:"){ gsub(/-/,".",$2); print $2 }' $WORKSPACE/common-workflow-language/reference/cwltool.egg-info/PKG-INFO)"
 
 # Finally, publish the packages, if necessary
 if [[ "$UPLOAD" != 0 && "$CALL_FREIGHT" != 0 ]]; then