Skip to main content

max / alloy

1.5 KB · 36 lines History Blame Raw
1 #!/usr/bin/env bash
2 #
3 # build-stamp.sh — the build stamp both image builders pass to the Containerfile.
4 #
5 # Sourced by build/build-image.sh and build/build-iso.sh, the same way
6 # build/privilege.sh is: they are the two scripts that turn the image into
7 # something installable, and an unstamped artifact is the one shape a support
8 # conversation cannot place.
9 #
10 # The Containerfile's ALLOY_BUILD_STAMP defaults empty and stamps nothing, so a
11 # bare `podman build` keeps its layer cache and honestly says nothing about a
12 # build number. These scripts always pass one. See the stamping block in the
13 # Containerfile for the three-clock scheme (product / build / Fedora base).
14 #
15 # Format is <YYYYMMDD>.<serial>, UTC. The serial is the time of day, which
16 # distinguishes same-day rebuilds without keeping a counter anywhere. UTC and
17 # not local time so two machines in two timezones cannot mint the same stamp
18 # from different days.
19
20 # Append the stamp to a BUILD_ARGS array, unless the caller already passed one
21 # by hand. Hand-passing wins: `--build-arg ALLOY_BUILD_STAMP=20260816.1` is how
22 # a release build pins a stamp it decided elsewhere, and a second value would
23 # leave which one podman honoured up to argument order.
24 #
25 # Usage: stamp_build_args BUILD_ARGS (the array's NAME, not its contents)
26 stamp_build_args() {
27 local -n args="$1"
28 local existing
29 for existing in "${args[@]}"; do
30 case "$existing" in
31 ALLOY_BUILD_STAMP=*) return 0 ;;
32 esac
33 done
34 args+=(--build-arg "ALLOY_BUILD_STAMP=$(date -u +%Y%m%d.%H%M%S)")
35 }
36