Make theme pack archives reproducible across build hosts
Gitea/canvas-pilot/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-11-17 17:45:11 +01:00
parent bc2844c931
commit f12df5897b
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
21 changed files with 27 additions and 1 deletions

View File

@ -6,6 +6,10 @@
### v0.9.36
- Fixed theme-pack reproducibility checks across build hosts by using stored ZIP
entries and fixed Unix metadata, avoiding zlib-dependent compressed bytes.
Regenerated all 17 downloads without changing manifests; regression coverage
rebuilds them without zlib and with simulated Windows platform metadata.
- Added extra-themes.zip: one import installs all 16 themes, with individual ZIPs
still available. Added Dracula, Nord, Gruvbox Dark, Solarized Dark/Light, One Dark,
GitHub Dark/Light, Monokai and original Dispatch, Helldivers and Deep Rock Galactic

View File

@ -96,6 +96,11 @@ and `python3 scripts/build-theme-packs.py --check`. Lifecycle tests cover startu
selection persistence, live updates, overwrite review/cancellation, changed-file
protection, removal, limits, malformed colors/archives and context isolation.
Distributed example ZIPs use stored (uncompressed) entries with a fixed timestamp
and Unix file metadata so exact rebuilds do not depend on the host or zlib version.
Their manifest bytes, pack revisions and version-1 representation are unchanged;
the importer continues to accept both stored and DEFLATE-compressed packs.
## Bundled collection
`docs/theme-packs/extra-themes.zip` is a normal version-1 pack (`extra-themes`,

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,9 @@ def archive(manifest):
buffer = io.BytesIO()
with zipfile.ZipFile(buffer, 'w') as output:
info = zipfile.ZipInfo('manifest.json', (2026, 1, 1, 0, 0, 0))
info.compress_type = zipfile.ZIP_DEFLATED
# DEFLATE bytes vary with zlib versions, even for identical input.
info.compress_type = zipfile.ZIP_STORED
info.create_system = 3 # Fixed Unix metadata on every build host.
info.external_attr = 0o100644 << 16
output.writestr(info, manifest)
return buffer.getvalue()

View File

@ -4,6 +4,7 @@ import io
import json
from pathlib import Path
import unittest
from unittest import mock
import zipfile
ROOT = Path(__file__).resolve().parents[1]
@ -13,6 +14,20 @@ spec.loader.exec_module(module)
class ThemePackExamples(unittest.TestCase):
def test_rebuild_does_not_depend_on_zlib_or_host_platform(self):
sources = sorted((ROOT / 'docs/theme-packs').glob('*/manifest.json'))
manifests = [source.read_bytes() for source in sources]
manifests.append(module.collection(sources))
for manifest in manifests:
expected = module.archive(manifest)
with mock.patch.object(zipfile, 'zlib', None), mock.patch('sys.platform', 'win32'):
self.assertEqual(module.archive(manifest), expected)
with zipfile.ZipFile(io.BytesIO(expected)) as archive:
info = archive.getinfo('manifest.json')
self.assertEqual(info.compress_type, zipfile.ZIP_STORED)
self.assertEqual(info.create_system, 3)
self.assertEqual(archive.read(info), manifest)
def test_archives_match_sources_and_rebuild_exactly(self):
manifests = list((ROOT / 'docs/theme-packs').glob('*/manifest.json'))
self.assertEqual(len(manifests), 16)