Browse Source

bin/build-packages: store name of log file in variable. After build failure, search inside log file for reference to other log files and append them to the log (which gets uploaded)

Erich Eckner 3 months ago
parent
commit
3181e6826a
1 changed files with 25 additions and 4 deletions
  1. 25
    4
      bin/build-packages

+ 25
- 4
bin/build-packages View File

@@ -606,15 +606,36 @@ while [ "${count}" -ne 0 ] && \
606 606
             "${repository}" \
607 607
             "${straw}" \
608 608
             "${arch}"
609
+          log_file="${tmp_dir}/$(
610
+            date -u --iso-8601=seconds | \
611
+              cut -d+ -f1
612
+          ).build-log"
609 613
           # by piping the log, we don't see anything in the terminal,
610 614
           # but all ways to duplicate the logs seem pretty elaborate
611 615
           # shellcheck disable=SC2024,SC2086
612 616
           if ! "${build_command}" ${outerParameters} -- ${middleParameters} -- ${innerParameters} > \
613
-            "$(
614
-              date -u --iso-8601=seconds | \
615
-                cut -d+ -f1
616
-            ).build-log" 2>&1; then
617
+            "${log_file}" 2>&1; then
617 618
             success=false
619
+            build_dir="/var/lib/archbuild/${build_command%-build}/$(whoami)"
620
+            if [ -d "${build_dir}" ]; then
621
+              sed '
622
+                s/^Full log written to\s\+\(\S\+\)\s*$/\1/
623
+                t
624
+                /# An error report file with more information is saved as:/ {
625
+                  N
626
+                  s/^.*\n#\s\+//
627
+                  t
628
+                  d
629
+                }
630
+                s/^See also "\(\S\+\)"\.\s*$/\1/
631
+                t
632
+                d
633
+              ' "${log_file}" | \
634
+                while read -r extra_log_file; do
635
+                  grep -HF '' "${build_dir}/${extra_log_file}" || true
636
+                done | \
637
+                sponge -a "${log_file}"
638
+            fi
618 639
           fi
619 640
         fi
620 641