21863: Run piprepo only when building a distro package
[arvados.git] / build / run-library.sh
index 2082dc94a0272d42d673de795ca244588f85a3a8..08aa2e5b6728878ec63ef01b3787cbfa667d83d3 100755 (executable)
@@ -532,15 +532,19 @@ handle_rails_package() {
         # gems that are already available system-wide... and then it complains
         # that your bundle is incomplete. Work around this by fetching gems
         # manually.
+        # TODO: Once all our supported distros have Ruby 3+, we can modify
+        # the awk script to print "NAME:VERSION" output, and pipe that directly
+        # to `xargs -0r gem fetch` for reduced overhead.
         mkdir -p vendor/cache
         awk -- '
-BEGIN { OFS=":"; ORS="\0"; }
-(/^[[:space:]]*$/) { level=0; }
-($0 == "GEM" || $0 == "  specs:") { level+=1; }
-(level == 2 && NF == 2 && $1 ~ /^[[:alpha:]][-_[:alnum:]]*$/ && $2 ~ /^\([[:digit:]]+[-_+.[:alnum:]]*\)$/) {
-    print $1, substr($2, 2, length($2) - 2);
+BEGIN { OFS="\0"; ORS="\0"; }
+(/^[A-Z ]*$/) { level1=$0; }
+(/^  [[:alpha:]]+:$/) { level2=substr($0, 3, length($0) - 3); next; }
+(/^ {0,3}[[:alpha:]]/) { level2=""; next; }
+(level1 == "GEM" && level2 == "specs" && NF == 2 && $1 ~ /^[[:alpha:]][-_[:alnum:]]*$/ && $2 ~ /\([[:digit:]]+[-_+.[:alnum:]]*\)$/) {
+    print "--version", substr($2, 2, length($2) - 2), $1;
 }
-' Gemfile.lock | env -C vendor/cache xargs -0r gem fetch
+' Gemfile.lock | env -C vendor/cache xargs -0r --max-args=3 gem fetch
         # Despite the bug, we still run `bundle cache` to make sure Bundler is
         # happy for later steps.
         bundle cache
@@ -713,13 +717,13 @@ fpm_build_virtualenv_worker () {
   if [[ $? -ne 0 ]]; then
     printf "Error, unable to download/build wheel for %s @ %s" "$PKG" "$PKG_DIR"
     exit 1
-  elif ! "$PYTHON_BUILDROOT/venv/bin/piprepo" build "$PYTHON_BUILDROOT/wheelhouse"; then
-    printf "Error, unable to update local wheel repository"
-    exit 1
   fi
 
   if [[ -n "$ONLY_BUILD" ]] && [[ "$PYTHON_PKG" != "$ONLY_BUILD" ]] && [[ "$PKG" != "$ONLY_BUILD" ]]; then
     return 0
+  elif ! "$PYTHON_BUILDROOT/venv/bin/piprepo" build "$PYTHON_BUILDROOT/wheelhouse"; then
+    printf "Error, unable to update local wheel repository"
+    exit 1
   fi
 
   local venv_dir="$PYTHON_BUILDROOT/$PYTHON_PKG"