12876: Merge branch 'master' into 12876-arvados-client
[arvados.git] / build / run-build-packages-one-target.sh
index cf60b5e2d9b3a365be3cca25ce33dd260d038725..c981b2a9ef679509bb24f7ecd25d005fb9d50920 100755 (executable)
@@ -21,8 +21,10 @@ Syntax:
     Build only a specific package
 --only-test <package>
     Test only a specific package
---version <string>
-    Version to build (default: \$ARVADOS_BUILDING_VERSION or 0.1.timestamp.commithash)
+--build-version <string>
+    Version to build (default:
+    \$ARVADOS_BUILDING_VERSION-\$ARVADOS_BUILDING_ITERATION or
+    0.1.timestamp.commithash)
 
 WORKSPACE=path         Path to the Arvados source tree to build packages from
 
@@ -47,7 +49,7 @@ if ! [[ -d "$WORKSPACE" ]]; then
 fi
 
 PARSEDOPTS=$(getopt --name "$0" --longoptions \
-    help,debug,test-packages,target:,command:,only-test:,only-build:,version: \
+    help,debug,test-packages,target:,command:,only-test:,only-build:,build-version: \
     -- "" "$@")
 if [ $? -ne 0 ]; then
     exit 1
@@ -85,8 +87,16 @@ while [ $# -gt 0 ]; do
         --test-packages)
             test_packages=1
             ;;
-        --version)
-            ARVADOS_BUILDING_VERSION="$2"
+        --build-version)
+            if [[ -z "$2" ]]; then
+                :
+            elif ! [[ "$2" =~ (.*)-(.*) ]]; then
+                echo >&2 "FATAL: --build-version '$2' does not include an iteration. Try '${2}-1'?"
+                exit 1
+            else
+                ARVADOS_BUILDING_VERSION="${BASH_REMATCH[1]}"
+                ARVADOS_BUILDING_ITERATION="${BASH_REMATCH[2]}"
+            fi
             shift
             ;;
         --)
@@ -101,12 +111,21 @@ done
 
 set -e
 
-IFS=- read ARVADOS_BUILDING_VERSION ARVADOS_BUILDING_ITERATION <<EOF
-$ARVADOS_BUILDING_VERSION
-EOF
+if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
+    echo "build version='$ARVADOS_BUILDING_VERSION', package iteration='$ARVADOS_BUILDING_ITERATION'"
+fi
 
 if [[ -n "$test_packages" ]]; then
     if [[ -n "$(find $WORKSPACE/packages/$TARGET -name '*.rpm')" ]] ; then
+       set +e
+       /usr/bin/which createrepo >/dev/null
+       if [[ "$?" != "0" ]]; then
+               echo >&2
+               echo >&2 "Error: please install createrepo. E.g. sudo apt-get install createrepo"
+               echo >&2
+               exit 1
+       fi
+       set -e
         createrepo $WORKSPACE/packages/$TARGET
     fi
 
@@ -142,6 +161,7 @@ popd
 
 if test -z "$packages" ; then
     packages="arvados-api-server
+        arvados-client
         arvados-docker-cleaner
         arvados-git-httpd
         arvados-node-manager
@@ -157,14 +177,10 @@ if test -z "$packages" ; then
         keep-rsync
         keepstore
         keep-web
-        libarvados-perl"
-
-    case "$TARGET" in
-        *)
-            packages="$packages python-arvados-fuse
-                  python-arvados-python-client python-arvados-cwl-runner"
-            ;;
-    esac
+        libarvados-perl
+        python-arvados-fuse
+        python-arvados-python-client
+        python-arvados-cwl-runner"
 fi
 
 FINAL_EXITCODE=0