Browse Source

bin/build-packages: fixing sources should not happen in the try-to-fix-the-build loop

Erich Eckner 3 months ago
parent
commit
ae247cfa1d
1 changed files with 62 additions and 66 deletions
  1. 62
    66
      bin/build-packages

+ 62
- 66
bin/build-packages View File

@@ -418,68 +418,6 @@ while [ "${count}" -ne 0 ] && \
418 418
 
419 419
         echo 'preparing' > "${tmp_dir}/.ping-build-master"
420 420
 
421
-        if echo "${straw}" | \
422
-          grep -qF ':mirrored_source:'; then
423
-          # maybe a missing source is/was the problem?
424
-          if makepkg --verifysource 2>/dev/null; then
425
-            # nope, sources are fine
426
-            continue
427
-          fi
428
-          # try to download them from sources.archlinux.org/sources/$repo/$source
429
-          source_name=$(
430
-            makepkg --printsrcinfo | \
431
-              sed -n '
432
-                /^\s*\(epoch\|pkg\(base\|ver\|rel\)\) = /{s|^\s\+||;p}
433
-                /^pkgname = /q
434
-              ' | \
435
-              sed '
436
-                s|^pkgbase = \(.*\)$|0 \1-|
437
-                s|^epoch = \(.*\)$|1 \1:|
438
-                s|^pkgver = \(.*\)$|2 \1-|
439
-                s|^pkgrel = \([^.]*\)\(\..*\)\?$|3 \1.src.tar.gz|
440
-              ' | \
441
-              sort -k1n,1 | \
442
-              sed '
443
-                s|^[0-9] ||
444
-                :a
445
-                  N
446
-                  s|\n[0-9] \(\S\+\)$|\1|
447
-                ta
448
-              '
449
-          )
450
-          if ! wget -q --timeout=15 -nc -nd "https://sources.archlinux.org/sources/${git_repo}/${source_name}"; then
451
-            # we can't improve anything
452
-            continue
453
-          fi
454
-          # shellcheck disable=SC2046
455
-          tar -xz --overwrite \
456
-            -f "${source_name}" \
457
-            --exclude PKGBUILD \
458
-            $(
459
-              if [ -n "${PKGBUILD_mod}" ]; then
460
-                git -C "${repo_paths__archlinux32}/${PKGBUILD_mod%/*}" archive "${mod_git_revision}" -- . | \
461
-                  tar -t | \
462
-                  sed 's/^/--exclude /'
463
-              fi
464
-            ) \
465
-            --strip-components=1 \
466
-            || true
467
-        fi
468
-
469
-        if echo "${straw}" | \
470
-          grep -qF ':mirrored_source_by_hash:'; then
471
-          # maybe a missing source is/was the problem?
472
-          if makepkg --verifysource 2>/dev/null; then
473
-            # nope, sources are fine
474
-            continue
475
-          fi
476
-          # download it from sources.archlinux32.org by its hash
477
-          if ! download_sources_by_hash; then
478
-            # we can't improve anything, if no source was downloadable
479
-            continue
480
-          fi
481
-        fi
482
-
483 421
         outerParameters="-r ${archbuild_chroots}"
484 422
         if echo "${straw}" | \
485 423
           grep -qF ':clean_chroot:'; then
@@ -548,14 +486,15 @@ while [ "${count}" -ne 0 ] && \
548 486
         echo 'checking-source' > "${tmp_dir}/.ping-build-master"
549 487
         success=false
550 488
         verifysource_trial=0
551
-        while [ ${verifysource_trial} -lt 3 ]; do
489
+        while [ ${verifysource_trial} -lt 5 ]; do
552 490
           verifysource_trial=$((verifysource_trial + 1))
553 491
           if CARCH="${arch}" makepkg --verifysource 2> "${tmp_dir}/verifysource.log"; then
554 492
             success=true
555 493
             break
556 494
           fi
495
+
496
+          # receive specific missing keys
557 497
           if [ ${verifysource_trial} -eq 1 ]; then
558
-            # receive specific missing keys
559 498
             missing_keys=$(
560 499
               sed -n '
561 500
                 s/^.* FAILED (unknown public key \([0-9A-F]\{16\}\)).*$/0x\1/
@@ -570,9 +509,10 @@ while [ "${count}" -ne 0 ] && \
570 509
             fi
571 510
             verifysource_trial=$((verifysource_trial + 1))
572 511
           fi
512
+
513
+          # download the repository key from github
573 514
           if [ ${verifysource_trial} -eq 2 ]; then
574 515
             if grep -q ' FAILED (unknown public key \([0-9A-F]\{16\}\))' -- "${tmp_dir}/verifysource.log"; then
575
-              # download the repository key from github
576 516
               # TODO: get the name of the key file from its finger print or
577 517
               # some other information inside the repository
578 518
               if makepkg --printsrcinfo | \
@@ -586,8 +526,64 @@ while [ "${count}" -ne 0 ] && \
586 526
                 continue
587 527
               fi
588 528
             fi
529
+            verifysource_trial=$((verifysource_trial + 1))
530
+          fi
531
+
532
+          # try to download source from sources.archlinux.org/sources/$repo/$source
533
+          if [ ${verifysource_trial} -eq 3 ]; then
534
+            if echo "${straw}" | \
535
+              grep -qF ':mirrored_source:'; then
536
+              source_name=$(
537
+                makepkg --printsrcinfo | \
538
+                  sed -n '
539
+                    /^\s*\(epoch\|pkg\(base\|ver\|rel\)\) = /{s|^\s\+||;p}
540
+                    /^pkgname = /q
541
+                  ' | \
542
+                  sed '
543
+                    s|^pkgbase = \(.*\)$|0 \1-|
544
+                    s|^epoch = \(.*\)$|1 \1:|
545
+                    s|^pkgver = \(.*\)$|2 \1-|
546
+                    s|^pkgrel = \([^.]*\)\(\..*\)\?$|3 \1.src.tar.gz|
547
+                  ' | \
548
+                  sort -k1n,1 | \
549
+                  sed '
550
+                    s|^[0-9] ||
551
+                    :a
552
+                      N
553
+                      s|\n[0-9] \(\S\+\)$|\1|
554
+                    ta
555
+                  '
556
+              )
557
+              if wget -q --timeout=15 -nc -nd "https://sources.archlinux.org/sources/${git_repo}/${source_name}"; then
558
+                # shellcheck disable=SC2046
559
+                tar -xz --overwrite \
560
+                  -f "${source_name}" \
561
+                  --exclude PKGBUILD \
562
+                  $(
563
+                    if [ -n "${PKGBUILD_mod}" ]; then
564
+                      git -C "${repo_paths__archlinux32}/${PKGBUILD_mod%/*}" archive "${mod_git_revision}" -- . | \
565
+                        tar -t | \
566
+                        sed 's/^/--exclude /'
567
+                    fi
568
+                  ) \
569
+                  --strip-components=1 \
570
+                  || true
571
+                continue
572
+              fi
573
+            fi
574
+            verifysource_trial=$((verifysource_trial + 1))
575
+          fi
576
+
577
+          # try to download source from sources.archlinux32.org by its hash
578
+          if [ ${verifysource_trial} -eq 4 ]; then
579
+            if echo "${straw}" | \
580
+              grep -qF ':mirrored_source_by_hash:'; then
581
+              if download_sources_by_hash; then
582
+                continue
583
+              fi
584
+            fi
585
+            verifysource_trial=$((verifysource_trial + 1))
589 586
           fi
590
-          break
591 587
         done
592 588
         rm "${tmp_dir}/verifysource.log"
593 589