17417: address review comments.
authorWard Vandewege <ward@curii.com>
Fri, 7 Jan 2022 18:51:39 +0000 (13:51 -0500)
committerWard Vandewege <ward@curii.com>
Fri, 7 Jan 2022 18:51:39 +0000 (13:51 -0500)
No issue #

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

build/run-build-packages-one-target.sh
build/run-build-packages.sh
build/run-build-test-packages-one-target.sh
build/run-library.sh

index 0c474d00fde7bd935dc97492462e8fbc29829b9b..e06a7329790e3dfa7b1430e33c52a2b86c383cc2 100755 (executable)
@@ -63,7 +63,6 @@ if [ $? -ne 0 ]; then
 fi
 
 TARGET=debian10
-ARCH=
 FORCE_BUILD=0
 COMMAND=
 DEBUG=
index 06328f82929eabda497684a8c15a84c5f834eb71..0cfe54cd139bb1540bc14ae4db0fceafaf6bb0a3 100755 (executable)
@@ -20,9 +20,9 @@ Options:
 --target <target>
     Distribution to build packages for (default: debian10)
 --only-build <package>
-    Build only a specific package (or $ONLY_BUILD from environment)
+    Build only a specific package (or ONLY_BUILD from environment)
 --arch <arch>
-    Build a specific architecture (or $ARCH from environment, defaults to native architecture)
+    Build a specific architecture (or ARCH from environment, defaults to native architecture)
 --force-build
     Build even if the package exists upstream or if it has already been
     built locally
index 2e2e3cdb4078069f9eb1408f1d927ba8c117ed56..e36c4e88c0d0bf146ac88a9d12587ef03b9a960e 100755 (executable)
@@ -12,7 +12,9 @@ Syntax:
 --target <target>
     Distribution to build packages for (default: debian10)
 --only-build <package>
-    Build only a specific package (or $ONLY_BUILD from environment)
+    Build only a specific package (or ONLY_BUILD from environment)
+--arch <arch>
+    Build a specific architecture (or ARCH from environment, defaults to native architecture)
 --upload
     If the build and test steps are successful, upload the packages
     to a remote apt repository (default: false)
@@ -46,7 +48,7 @@ if ! [[ -d "$WORKSPACE" ]]; then
 fi
 
 PARSEDOPTS=$(getopt --name "$0" --longoptions \
-    help,debug,upload,rc,target:,only-build:,build-version: \
+    help,debug,upload,rc,target:,only-build:,arch:,build-version: \
     -- "" "$@")
 if [ $? -ne 0 ]; then
     exit 1
@@ -73,6 +75,9 @@ while [ $# -gt 0 ]; do
         --only-build)
             ONLY_BUILD="$2"; shift
             ;;
+        --arch)
+            ARCH="$2"; shift
+            ;;
         --debug)
             DEBUG=" --debug"
             ;;
@@ -102,6 +107,10 @@ if [[ -n "$ONLY_BUILD" ]]; then
   build_args+=(--only-build "$ONLY_BUILD")
 fi
 
+if [[ -n "$ARCH" ]]; then
+  build_args+=(--arch "$ARCH")
+fi
+
 exit_cleanly() {
     trap - INT
     report_outcomes
index 8a228622afb8e09310b434f0df548a5babf80cba..b0d4daa722bd2440a4d471ea5b2a62cb1cbbe289 100755 (executable)
@@ -170,35 +170,48 @@ package_go_binary() {
   native_arch=$(get_native_arch)
 
   if [[ "$native_arch" != "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
-    echo "Error: no cross compilation support for Go on $native_arch yet, can not build $prog for $target_arch"
+    echo "Error: no cross compilation support for Go on $native_arch, can not build $prog for $target_arch"
     return 1
   fi
 
+  cross_compilation=1
+  if [[ "$TARGET" == "centos7" ]]; then
+    if [[ "$native_arch" == "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
+      echo "Error: no cross compilation support for Go on $native_arch for $TARGET, can not build $prog for $target_arch"
+      return 1
+    fi
+    cross_compilation=0
+  fi
+
+  if [[ "$package_format" == "deb" ]] &&
+     [[ "$TARGET" == "debian10" ]] || [[ "$TARGET" == "ubuntu1804" ]] || [[ "$TARGET" == "ubuntu2004" ]]; then
+    # Due to bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477 the libfuse-dev package for arm64 does
+    # not install properly side by side with the amd64 version before Debian 11.
+    if [[ "$native_arch" == "amd64" ]] && [[ -n "$target_arch" ]] && [[ "$native_arch" != "$target_arch" ]]; then
+      echo "Error: no cross compilation support for Go on $native_arch for $TARGET, can not build $prog for $target_arch"
+      return 1
+    fi
+    cross_compilation=0
+  fi
+
   if [[ -n "$target_arch" ]]; then
-    # A target architecture has been specified
-    package_go_binary_worker "$src_path" "$prog" "$package_format" "$description" "$native_arch" "$target_arch" "$license_file"
-    return $?
+    archs=($target_arch)
   else
-    # No target architecture specified, default to native target. When on amd64 also crosscompile arm64
-    # but only when building deb packages (centos does not have support for crosscompiling userspace).
+    # No target architecture specified, default to native target. When on amd64
+    # also crosscompile arm64 (when supported).
     archs=($native_arch)
-    if [[ "$native_arch" == "amd64" ]] &&
-       [[ "$package_format" == "deb" ]] &&
-       [[ "$TARGET" != "debian10" ]] &&
-       [[ "$TARGET" != "ubuntu1804" ]] &&
-       [[ "$TARGET" != "ubuntu2004" ]]; then
-      # Due to bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983477 the libfuse-dev package for arm64 does
-      # not install properly side by side with the amd64 version before Debian 11.
+    if [[ $cross_compilation -ne 0 ]]; then
       archs+=("arm64")
     fi
-    for ta in ${archs[@]}; do
-      package_go_binary_worker "$src_path" "$prog" "$package_format" "$description" "$native_arch" "$ta" "$license_file"
-      retval=$?
-      if [[ $retval -ne 0 ]]; then
-        return $retval
-      fi
-    done
   fi
+
+  for ta in ${archs[@]}; do
+    package_go_binary_worker "$src_path" "$prog" "$package_format" "$description" "$native_arch" "$ta" "$license_file"
+    retval=$?
+    if [[ $retval -ne 0 ]]; then
+      return $retval
+    fi
+  done
 }
 
 # Usage: package_go_binary services/foo arvados-foo deb "Compute foo to arbitrary precision" [amd64/arm64] [amd64/arm64] [apache-2.0.txt]
@@ -211,11 +224,6 @@ package_go_binary_worker() {
     local target_arch="${1:-amd64}"; shift
     local license_file="${1:-agpl-3.0.txt}"; shift
 
-    if [[ "$native_arch" != "$target_arch" ]] && [[ "$package_format" == "rpm" ]]; then
-      echo "Error: no cross compilation support for Go on $native_arch ($package_format), can not build $prog for $target_arch"
-      return 1
-    fi
-
     debug_echo "package_go_binary $src_path as $prog (native arch: $native_arch, target arch: $target_arch)"
     local basename="${src_path##*/}"
     calculate_go_package_version go_package_version $src_path