17012: update calculation of python version number in run-library.sh
authorWard Vandewege <ward@curii.com>
Tue, 17 Nov 2020 15:26:58 +0000 (10:26 -0500)
committerWard Vandewege <ward@curii.com>
Tue, 17 Nov 2020 16:02:50 +0000 (11:02 -0500)
       (used by a few docker image scripts).

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

build/run-library.sh

index c598270ceba2beb4af967c9093e405b2531e57c0..c925cf1cdea587e0996558fa6b17b0af8f0e9d31 100755 (executable)
@@ -61,11 +61,12 @@ version_from_git() {
 }
 
 nohash_version_from_git() {
+    local subdir="$1"; shift
     if [[ -n "$ARVADOS_BUILDING_VERSION" ]]; then
         echo "$ARVADOS_BUILDING_VERSION"
         return
     fi
-    version_from_git | cut -d. -f1-4
+    version_from_git $subdir | cut -d. -f1-4
 }
 
 timestamp_from_git() {
@@ -76,11 +77,21 @@ timestamp_from_git() {
 calculate_python_sdk_cwl_package_versions() {
   python_sdk_ts=$(cd sdk/python && timestamp_from_git)
   cwl_runner_ts=$(cd sdk/cwl && timestamp_from_git)
+  build_ts=$(cd build && timestamp_from_git version-at-commit.sh)
+
+  ar=($python_sdk_ts $cwl_runner_ts $build_ts)
+  OLDIFS=$IFS
+  IFS=$'\n'
+  max=`echo "${ar[*]}" | sort -nr | head -n1`
+  IFS=$OLDIFS
 
   python_sdk_version=$(cd sdk/python && nohash_version_from_git)
   cwl_runner_version=$(cd sdk/cwl && nohash_version_from_git)
+  build_version=$(cd build && nohash_version_from_git version-at-commit.sh)
 
-  if [[ $python_sdk_ts -gt $cwl_runner_ts ]]; then
+  if [[ $max -eq $build_ts ]]; then
+    cwl_runner_version=$build_version
+  elif [[ $max -eq $python_sdk_ts ]]; then
     cwl_runner_version=$python_sdk_version
   fi
 }