max / alloy
| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # preflight-gate.sh — run build/preflight.sh ahead of a mint, and decide what a |
| 4 | # finding means. Sourced by build/build-image.sh and build/build-iso.sh, so the |
| 5 | # policy exists once rather than in two places that drift. |
| 6 | # |
| 7 | # WHY THIS IS A GATE AND WAS NOT ONE ON DAY ONE. A gate that fires wrongly on |
| 8 | # its first day is worse than no gate, and the preflight had never been run in |
| 9 | # anger. It has since caught four things nobody predicted, one of them a recipe |
| 10 | # combination the Containerfile's own validator refuses, so the condition is met. |
| 11 | # |
| 12 | # WHAT REFUSES A BUILD, and this is the decision the gate exists to hold. |
| 13 | # preflight answers two different kinds of question, and only one of them is |
| 14 | # about the thing being built: |
| 15 | # |
| 16 | # dials, requires, var-payload about the medium. An image with one of these |
| 17 | # outstanding is wrong wherever it is built. |
| 18 | # These refuse. |
| 19 | # guards about this machine. It reads sibling repos |
| 20 | # under ~/Code that no image contains, so it |
| 21 | # predicts a failed AppImage on this host and |
| 22 | # says nothing about the medium. This warns. |
| 23 | # |
| 24 | # Refusing a mint because a repo next door is stale would make the gate a thing |
| 25 | # people route around, and routing around it is how the four findings above |
| 26 | # would have been missed. So the warning is loud and the build proceeds; the |
| 27 | # finding is still on the screen and still worth fixing before a release. |
| 28 | # |
| 29 | # HOW MUCH PREFLIGHT RUNS, which is the other half of the decision. The probe is |
| 30 | # one dnf transaction: seconds on the host's own architecture, minutes under |
| 31 | # emulation. Measured 2026-09-04, the astra probe took minutes on fw13 and |
| 32 | # seconds on astra. A gate that always builds it makes every cross-architecture |
| 33 | # mint slow to start, for an answer emulation is the worst way to get. So the |
| 34 | # gate runs the full preflight when the mint's architecture is this machine's, |
| 35 | # and --fast when it is not, saying which it chose and why. |
| 36 | # |
| 37 | # Usage: preflight_gate HOST ARCH SKIP |
| 38 | # HOST the recipe name, empty for a mint with no recipe |
| 39 | # ARCH the medium's architecture, empty for this machine's |
| 40 | # SKIP 1 to skip the gate entirely (--no-preflight) |
| 41 | # |
| 42 | # Returns 0 to proceed. On a finding about the image it does not return: it |
| 43 | # exits the calling script, because a caller that had to remember to check would |
| 44 | # eventually forget. |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | if [; then |
| 51 | |
| 52 | |
| 53 | fi |
| 54 | |
| 55 | # No recipe, nothing to check. preflight reads build/hosts/<name>.env and has |
| 56 | # nothing to say about a mint that takes the Containerfile's own defaults. |
| 57 | # Stated rather than silent, so a hostless mint does not read as a gated one. |
| 58 | if [; then |
| 59 | |
| 60 | |
| 61 | fi |
| 62 | |
| 63 | if [ && [; then |
| 64 | mode=(--fast) |
| 65 | |
| 66 | "" "" "" |
| 67 | else |
| 68 | |
| 69 | fi |
| 70 | |
| 71 | || rc= |
| 72 | |
| 73 | case "" in |
| 74 | 0) ;; |
| 75 | 4) |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | ;; |
| 81 | 2) |
| 82 | # Usage, not a finding: --host named a recipe preflight could not read. |
| 83 | # Saying "findings" here would send someone looking for a defect in an |
| 84 | # image that was never described. |
| 85 | |
| 86 | |
| 87 | |
| 88 | ;; |
| 89 | *) |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | ;; |
| 95 | esac |
| 96 | } |
| 97 |