mirror of
https://github.com/mihawk-99/PS5_RetroArch.git
synced 2026-10-18 23:09:29 -05:00
The checksums listed only *.tar*, so the two ICU source archives the frontends need (icu4c-78.3-sources.tgz, icu4c-78.3-data.zip) were written without one. They are now taken from every file the bundle writes, except the index files. Verified: python3 -m unittest tests.test_source_bundle fails before the change and passes after it; TMPDIR=$PWD/build/tmp bash tools/verify.sh -> verify: PASS (format unit build integration evidence); python3 tools/source-bundle.py dist/PPSA99169 dist/source-v0.6.7-alpha.6 -> 37 archives, 37 SHA256SUMS lines, sha256sum -c all OK.
49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
"""The release's source archives: SHA256SUMS lists every archive tools/source-bundle.py writes."""
|
|
|
|
import hashlib
|
|
import importlib.util
|
|
import json
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
|
|
spec = importlib.util.spec_from_file_location("source_bundle", ROOT / "tools/source-bundle.py")
|
|
bundle = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(bundle)
|
|
|
|
|
|
class SourceBundle(unittest.TestCase):
|
|
def test_every_archive_is_in_the_checksums(self):
|
|
# ICU's sources are downloaded as a .tgz and a .zip, not a .tar.gz: the
|
|
# checksums once listed only *.tar*, so those two shipped without one.
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
base = Path(directory)
|
|
downloads = base / "repo/downloads"
|
|
downloads.mkdir(parents=True)
|
|
archives = {"icu-sources.tgz": b"tgz", "icu-data.zip": b"zip", "lib-1.tar.gz": b"gz"}
|
|
for name, data in archives.items():
|
|
(downloads / name).write_bytes(data)
|
|
part = {"id": "lib", "name": "Library", "kind": "code",
|
|
"source": {"kind": "fixed", "revision": "1",
|
|
"extra": [{"tarball": f"downloads/{name}"} for name in archives]}}
|
|
table = base / "components.json"
|
|
table.write_text(json.dumps({"components": [part]}))
|
|
title = base / "title"
|
|
(title / "licenses").mkdir(parents=True)
|
|
staged = dict(part, source={"kind": "fixed", "revision": "1"})
|
|
(title / "licenses/components.json").write_text(json.dumps({"components": [staged]}))
|
|
out = base / "source"
|
|
with patch.object(bundle, "ROOT", base / "repo"), patch.object(bundle, "TABLE", table):
|
|
self.assertEqual(bundle.main([str(title), str(out)]), 0)
|
|
sums = dict(reversed(line.split(" ")) for line in
|
|
(out / "SHA256SUMS").read_text().splitlines())
|
|
self.assertEqual(sums, {name: hashlib.sha256(data).hexdigest()
|
|
for name, data in archives.items()})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|