From 03bfb6ca7d65efb313ea9874fa555a1322162aa1 Mon Sep 17 00:00:00 2001
From: Liraz Siri <liraz@liraz.org>
Date: Tue, 27 Oct 2026 20:21:24 +0800
Subject: [PATCH] Publish bootstrap checksums beside archives with the Trixie
 key

TKLDev setup downloads a bootstrap and its signed checksum from the same
images/bootstrap directory, but publication placed the checksum only in the
metadata tree. Publish both image assets while retaining the metadata copies.
Use the official Trixie image key in the 19.x default configuration so a fresh
client imports the same key used to sign its bootstrap.

Reproduced the missing adjacent checksum with the actual publication block.
The regression test verifies both image assets and all three metadata assets;
Bash syntax and diff checks pass. Release validation exercises the fresh
configuration and real signature verifier against the signed artifact.
---
 bt-bootstrap                        |  2 +-
 config.example/common.cfg           |  2 +-
 tests/test_bootstrap_publication.py | 37 +++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 tests/test_bootstrap_publication.py

diff --git a/bt-bootstrap b/bt-bootstrap
index 3fc4f33..029c28d 100755
--- a/bt-bootstrap
+++ b/bt-bootstrap
@@ -190,7 +190,7 @@ mv "build/bootstrap-$FAB_ARCH.tar.gz" "$O/$BOOTSTRAP_TARBALL"
 
 if [[ "$publish" == "yes" ]]; then
     export PUBLISH_DEST=${BT_PUBLISH_IMGS}/bootstrap/
-    "$BT/bin/publish-files" "$O/$BOOTSTRAP_TARBALL"
+    "$BT/bin/publish-files" "$O/$BOOTSTRAP_TARBALL"{,.hash}
 
     export PUBLISH_DEST=${BT_PUBLISH_META}/
     "$BT/bin/publish-files" "$O/$BOOTSTRAP_TARBALL"{.manifest,.hash,.buildenv}
diff --git a/config.example/common.cfg b/config.example/common.cfg
index ae47498..5ea5df4 100644
--- a/config.example/common.cfg
+++ b/config.example/common.cfg
@@ -4,7 +4,7 @@ export BT_PUBLISH_IMGS="s3://${BUCKET}/images"
 export BT_PUBLISH_META="s3://${BUCKET}/metadata"
 export BT_PUBLISH_SCREENS="s3://${BUCKET}/screens"
 export BT_PUBLISH_PROFILES="s3://${BUCKET}/profiles"
-export BT_GPGKEY=26147592087C0EDE42143B637761DEBABBCFBA7C
+export BT_GPGKEY=DEE90D9970AE35D55B7C6C2DC6D254B76A9D9430
 export BT_ISOS=/mnt/isos
 export BT_IMGS=/mnt/imgs
 export BT_QEMU=/mnt/qemu
diff --git a/tests/test_bootstrap_publication.py b/tests/test_bootstrap_publication.py
new file mode 100644
index 0000000..03e35a5
--- /dev/null
+++ b/tests/test_bootstrap_publication.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+"""The setup client downloads the checksum next to the bootstrap archive."""
+import os
+from pathlib import Path
+import subprocess
+import tempfile
+import unittest
+
+
+class BootstrapPublicationTest(unittest.TestCase):
+    def test_archive_and_checksum_share_the_image_destination(self):
+        source = (Path(__file__).resolve().parents[1] / 'bt-bootstrap').read_text()
+        block = 'if [[ "$publish" == "yes" ]]; then' + source.rsplit(
+            'if [[ "$publish" == "yes" ]]; then', 1)[1].split('\nfi', 1)[0] + '\nfi\n'
+        with tempfile.TemporaryDirectory() as tmp:
+            root = Path(tmp)
+            output = root / 'build'
+            output.mkdir()
+            filename = 'bootstrap-trixie-amd64.tar.gz'
+            for suffix in ['', '.hash', '.manifest', '.buildenv']:
+                (output / (filename + suffix)).write_text('fixture' + suffix)
+            (root / 'bin').mkdir()
+            publisher = root / 'bin/publish-files'
+            publisher.write_text('#!/bin/bash\nset -e\nmkdir -p "$PUBLISH_DEST"\ncp "$@" "$PUBLISH_DEST"\n')
+            publisher.chmod(0o755)
+            env = dict(os.environ, publish='yes', BT=str(root), O=str(output),
+                       BOOTSTRAP_TARBALL=filename, BT_PUBLISH_IMGS=str(root / 'images'),
+                       BT_PUBLISH_META=str(root / 'metadata'))
+            subprocess.run(['bash', '-ec', block], env=env, check=True)
+            self.assertEqual((root / 'images/bootstrap' / filename).read_text(), 'fixture')
+            self.assertEqual((root / 'images/bootstrap' / (filename + '.hash')).read_text(), 'fixture.hash')
+            for suffix in ['.hash', '.manifest', '.buildenv']:
+                self.assertEqual((root / 'metadata' / (filename + suffix)).read_text(), 'fixture' + suffix)
+
+
+if __name__ == '__main__':
+    unittest.main()
-- 
2.53.0

