Skip to content

Commit 99cbd52

Browse files
committed
Add build checksums (not reproducible yet)
This is an intermediate step towards reproducible static builds. It just sets up a workflow for generating build checksums. Those WILL vary after each build, since our scripts are still not ready to produce builds that are reproducible. This step is in a long walk towards better builds, more reproducible results and perhaps even releases outside of docker.
1 parent 7219903 commit 99cbd52

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# SPDX-FileCopyrightText: 2026 Alexandre Gomes Gaigalas <alganet@gmail.com>
2+
# SPDX-License-Identifier: ISC
3+
4+
name: Generate and upload build checksums
5+
description: Extracts /opt from the built image, generates build checksums into checksums/build/, ensures correct ownership and uploads the artifact
6+
runs:
7+
using: composite
8+
steps:
9+
- name: Extract image /opt
10+
shell: bash
11+
run: |
12+
set -ex
13+
container=$(docker create "${{ inputs.image }}")
14+
docker cp $container:/opt ./image_out
15+
docker rm $container
16+
17+
- name: Generate build checksums
18+
shell: bash
19+
env:
20+
SHVR_DIR_OUT: ${{ github.workspace }}/image_out
21+
SHVR_CHECKSUMS_DIR: ${{ github.workspace }}/checksums
22+
run: |
23+
set -ex
24+
sh shvr.sh generate_build_checksums
25+
26+
- name: Ensure ownership of checksums
27+
shell: bash
28+
run: |
29+
set -ex
30+
# Some runners may create files as root when using docker, ensure runner can upload
31+
sudo chown -R $(id -u):$(id -g) checksums/build || true
32+
33+
- name: Upload build checksums
34+
uses: actions/upload-artifact@v6
35+
with:
36+
name: ${{ inputs.artifact_name }}
37+
path: checksums/build
38+
39+
inputs:
40+
image:
41+
description: Docker image tag to extract (required)
42+
required: true
43+
artifact_name:
44+
description: Artifact name to upload
45+
required: false
46+
default: shvr-build-checksums

.github/workflows/docker-all.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ jobs:
4444
build-args: |
4545
TARGETS=${{ matrix.targets }}
4646
47+
- name: Generate and upload build checksums
48+
uses: ./.github/actions/generate-build-checksums
49+
with:
50+
image: ${{ matrix.tags }}
51+
artifact_name: shvr-build-checksums
52+
4753
strategy:
4854
fail-fast: true
4955
matrix:

.github/workflows/docker-latest.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ jobs:
4444
build-args: |
4545
TARGETS=${{ matrix.targets }}
4646
47+
- name: Generate and upload build checksums
48+
uses: ./.github/actions/generate-build-checksums
49+
with:
50+
image: ${{ matrix.tags }}
51+
artifact_name: shvr-build-checksums
52+
4753
strategy:
4854
fail-fast: true
4955
matrix:

.github/workflows/docker-test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ jobs:
4444
build-args: |
4545
TARGETS=${{ matrix.targets }}
4646
47+
- name: Generate and upload build checksums
48+
uses: ./.github/actions/generate-build-checksums
49+
with:
50+
image: ${{ matrix.tags }}
51+
artifact_name: shvr-build-checksums
52+
4753
strategy:
4854
fail-fast: false
4955
matrix:

shvr.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ shvr_build ()
3232
set -x
3333

3434
shvr_each build "${@:-}"
35+
shvr_generate_build_checksums "${@:-}"
3536
}
3637

3738

@@ -196,6 +197,41 @@ shvr_generate_checksums()
196197
done
197198
}
198199

200+
201+
# Generate checksums for build outputs under ${SHVR_DIR_OUT} and write them
202+
# to ${SHVR_CHECKSUMS_DIR}/build/<rel>.sha256sums mirroring the out layout.
203+
# Usage: shvr_generate_build_checksums [<shell>_<version> ...]
204+
shvr_generate_build_checksums()
205+
{
206+
if test -z "$*"
207+
then
208+
start_dir="${SHVR_DIR_OUT}"
209+
find "$start_dir" -type f | while read -r f
210+
do
211+
rel="${f#${SHVR_DIR_OUT}/}"
212+
dest_dir="$(dirname "${SHVR_CHECKSUMS_DIR}/build/${rel}.sha256sums")"
213+
mkdir -p "$dest_dir"
214+
sha256sum "$f" | sed "s/ .*/ $(basename "$f")/" > "${SHVR_CHECKSUMS_DIR}/build/${rel}.sha256sums"
215+
done
216+
else
217+
# Only generate checksums for specific targets (e.g., bash_5.3.9)
218+
for t in "$@"
219+
do
220+
dir="$SHVR_DIR_OUT/${t}"
221+
if test -d "$dir"
222+
then
223+
find "$dir" -type f | while read -r f
224+
do
225+
rel="${f#${SHVR_DIR_OUT}/}"
226+
dest_dir="$(dirname "${SHVR_CHECKSUMS_DIR}/build/${rel}.sha256sums")"
227+
mkdir -p "$dest_dir"
228+
sha256sum "$f" | sed "s/ .*/ $(basename "$f")/" > "${SHVR_CHECKSUMS_DIR}/build/${rel}.sha256sums"
229+
done
230+
fi
231+
done
232+
fi
233+
}
234+
199235
shvr_github_regen_downloads ()
200236
{
201237
set -- $(printf '%s ' $(shvr_targets | sort -t'_' -k1,1 -k2Vr))

0 commit comments

Comments
 (0)