Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Tools: the notices in every desktop archive (refs #54) (#552)

Eyal Golan324200d55db6
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index 12e2e6426..e22bb8e9c 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -44,8 +44,9 @@ None of these is redistributed by this repository or shipped in a build: `UnityM
A build is a different artefact. It contains the Unity runtime, `YamlDotNet.dll`, the fonts, the portraits, the event
photographs (CC BY 4.0 credits in `NOTICE` and on the card) and the map data. Before a build is handed to anyone, it must carry `LICENSE`, `NOTICE`, this file, `LICENSES/` and
-`unity/Assets/UI/Fonts/OFL.txt`. `scripts/oss/package_web.sh` copies them into the build folder, has
-`tools/package_release.py` (the sensitivity gate) zip it, and refuses to finish unless the zip lists every one of them
+each font's licence: `unity/Assets/UI/Fonts/OFL.txt` as `OFL-EBGaramond.txt` and
+`unity/Assets/UI/Fonts/FrankRuhlLibre/OFL.txt` as `OFL-FrankRuhlLibre.txt`. `scripts/oss/package_web.sh` (WebGL) and
+`tools/release_build.py` (desktop) copy them in, and each refuses to finish unless the archive lists every one of them
(see [`docs/RELEASING.md`](docs/RELEASING.md)).
## Third-party trademarks
diff --git a/docs/RELEASING.md b/docs/RELEASING.md
index 03b90cea0..187a9099c 100644
--- a/docs/RELEASING.md
+++ b/docs/RELEASING.md
@@ -51,9 +51,12 @@ GitHub Releases page (and, from M4, on itch.io). Steps 1–3 are a normal pull r
```
Paste the SHA-256 from step 5 into the release notes.
-7. **Check every published artefact:** download each uploaded zip (GitHub Releases, and itch.io once used) into an empty
- folder, then run `unzip -Z1 <zip> | grep -E '^(LICENSE|NOTICE|THIRD-PARTY-NOTICES.md|OFL.txt)$'`. It must print four
- lines for each zip.
+7. **Check every published artefact:** download each uploaded archive (GitHub Releases, and itch.io once used) into an
+ empty folder, then list it and look for the notices: for a `.zip` (the web zip, the macOS and Windows players),
+ `unzip -Z1 <zip> | grep -E '^(LICENSE|NOTICE|THIRD-PARTY-NOTICES.md|OFL-EBGaramond.txt|OFL-FrankRuhlLibre.txt)$'`;
+ for the Linux `.tar.gz`,
+ `tar -tzf <archive> | grep -E '^(\./)?(LICENSE|NOTICE|THIRD-PARTY-NOTICES.md|OFL-EBGaramond.txt|OFL-FrankRuhlLibre.txt)$'`.
+ It must print five lines for each archive.
## Desktop builds (macOS, Linux, Windows)
@@ -77,11 +80,12 @@ Hub command. `--dev` makes a test build from any branch: not `-shareable`, no `-
Each build runs under `tools/machine_lock.py --shared --wait-unity`. The script runs the `-golden` check on the macOS
player, the only one the Mac can run; the Linux and Windows players are recorded as unchecked until the CI player check
runs them. It archives each player under the names that check expects (`statecraft-israel-vX.Y.Z-macos-universal.zip`,
-made with `ditto`; `-linux-x64.tar.gz`; `-windows-x64.zip`) and writes `build-record.json`, `build-record.md`, a
+made with `ditto`; `-linux-x64.tar.gz`; `-windows-x64.zip`), each with `LICENSE`, `NOTICE`, `THIRD-PARTY-NOTICES.md`, the two font
+licences (`OFL-EBGaramond.txt`, `OFL-FrankRuhlLibre.txt`) and `LICENSES/` beside the player (it lists the archive to check), and writes `build-record.json`, `build-record.md`, a
`files-<platform>.sha256` list of each archive's files and the build's `event-photos-<platform>.json` to
`~/statecraft-release/v<version>-<commit>-<UTC time>/` (or `--out`), and prints the path. It never commits, pushes or
-uploads: copy the record files to the build records repository by hand. Adding the notices to the archives, signing and
-Steam upload are later steps, not yet scripted.
+uploads: copy the record files to the build records repository by hand. Signing and Steam upload are later steps, not yet
+scripted.
## Refreshing the README screenshots
diff --git a/scripts/oss/package_web.sh b/scripts/oss/package_web.sh
index a55a383cd..7beef87a3 100755
--- a/scripts/oss/package_web.sh
+++ b/scripts/oss/package_web.sh
@@ -16,13 +16,15 @@ case "$zip_path" in /*) ;; *) zip_path="$PWD/$zip_path" ;; esac
mkdir -p "$build/LICENSES"
cp "$root/LICENSE" "$root/NOTICE" "$root/THIRD-PARTY-NOTICES.md" "$build/"
cp "$root/LICENSES/"*.txt "$build/LICENSES/"
-cp "$root/unity/Assets/UI/Fonts/OFL.txt" "$build/OFL.txt"
+# Each font's own OFL text travels with it (its copyright line differs), under the names site/public/fonts uses.
+cp "$root/unity/Assets/UI/Fonts/OFL.txt" "$build/OFL-EBGaramond.txt"
+cp "$root/unity/Assets/UI/Fonts/FrankRuhlLibre/OFL.txt" "$build/OFL-FrankRuhlLibre.txt"
rm -f "$zip_path" # a refusal must not leave an earlier zip behind
python3 "$packager" --build "$build" --zip "$zip_path"
listing="$(unzip -Z1 "$zip_path")"
-for f in LICENSE NOTICE THIRD-PARTY-NOTICES.md OFL.txt LICENSES/CC-BY-4.0.txt LICENSES/CC-BY-SA-4.0.txt \
+for f in LICENSE NOTICE THIRD-PARTY-NOTICES.md OFL-EBGaramond.txt OFL-FrankRuhlLibre.txt LICENSES/CC-BY-4.0.txt LICENSES/CC-BY-SA-4.0.txt \
LICENSES/CC0-1.0.txt LICENSES/YamlDotNet-MIT.txt index.html; do
printf '%s\n' "$listing" | grep -qxF "$f" || { echo "MISSING in zip: $f"; rm -f "$zip_path"; exit 1; }
done
diff --git a/scripts/oss/tests/test_release.py b/scripts/oss/tests/test_release.py
index 5d3cc77d2..dea3c9fd6 100644
--- a/scripts/oss/tests/test_release.py
+++ b/scripts/oss/tests/test_release.py
@@ -6,7 +6,7 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[3]
NOTICES = ["LICENSE", "NOTICE", "THIRD-PARTY-NOTICES.md", "LICENSES/CC-BY-4.0.txt", "LICENSES/CC-BY-SA-4.0.txt",
- "LICENSES/CC0-1.0.txt", "LICENSES/YamlDotNet-MIT.txt", "OFL.txt"]
+ "LICENSES/CC0-1.0.txt", "LICENSES/YamlDotNet-MIT.txt", "OFL-EBGaramond.txt", "OFL-FrankRuhlLibre.txt"]
# Stands in for tools/package_release.py (which needs dotnet and real content): zips the folder, index.html at the root.
STUB = """import argparse, zipfile
from pathlib import Path
diff --git a/tools/release_build.py b/tools/release_build.py
index 2e91d845e..ffc20f0fd 100644
--- a/tools/release_build.py
+++ b/tools/release_build.py
@@ -29,10 +29,13 @@ Usage: uv run tools/release_build.py [--platform mac|linux|windows|all] [--out D
`GOLDEN OK` lines carrying the hashes pinned in sim/Statecraft.Sim.Tests/golden/manifest.txt. The Linux and Windows
players are recorded as unchecked, for the CI player check (spec 6.3).
- Archives each player under the asset name the CI player check expects (PR #533's contract; ARCHIVES below):
- statecraft-israel-<tag>-macos-universal.zip (ditto --norsrc, the .app alone), statecraft-israel-<tag>-linux-x64.tar.gz and
- statecraft-israel-<tag>-windows-x64.zip. It checks first that the folder holds exactly one player executable. An
- archive holds the player only: not Unity's *_DoNotShip folders, and not event-photos.json, the build's photo manifest
- (packaging evidence the player never reads), which is copied beside the record as event-photos-<platform>.json.
+ statecraft-israel-<tag>-macos-universal.zip (the .app zipped by ditto --norsrc), statecraft-israel-<tag>-linux-x64.tar.gz
+ and statecraft-israel-<tag>-windows-x64.zip. It checks first that the folder holds exactly one player executable.
+ Every archive carries the notices at its top level, beside the player (RELEASING.md step 7): LICENSE, NOTICE,
+ THIRD-PARTY-NOTICES.md, OFL-EBGaramond.txt, OFL-FrankRuhlLibre.txt and LICENSES/, the web packager's list (REQUIRED_NOTICES). It refuses before
+ building when one is missing from the repository, and lists each archive afterwards to prove they are in it. An
+ archive leaves out Unity's *_DoNotShip folders and event-photos.json, the build's photo manifest (packaging
+ evidence the player never reads), which is copied beside the record as event-photos-<platform>.json.
- Writes build-record.json, build-record.md and files-<platform>.sha256: one `shasum -a 256` line per file the archive
holds, so `shasum -a 256 -c` run where the archive was unpacked checks every file. The record carries the SHA-256 and
size of each archive and file list, and whether the tree was still clean after the builds.
@@ -65,6 +68,17 @@ REPO = Path(__file__).resolve().parents[1]
LOCK_TIMEOUT = 30 * 24 * 3600 # machine_lock's own default gives up after an hour; a release waits for the machine
HUB = "/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"
METHOD = "Statecraft.Game.EditorTools.Build."
+# The licence and attribution files every archive carries beside the player (RELEASING.md step 7): the list
+# scripts/oss/package_web.sh copies into the web zip and checks (test_the_notice_list_is_the_web_packagers keeps them
+# one list). Archive name -> source in the repository; LICENSES/ is copied whole, as the web packager does.
+REQUIRED_NOTICES = ["LICENSE", "LICENSES/CC-BY-4.0.txt", "LICENSES/CC-BY-SA-4.0.txt", "LICENSES/CC0-1.0.txt",
+ "LICENSES/YamlDotNet-MIT.txt", "NOTICE", "OFL-EBGaramond.txt", "OFL-FrankRuhlLibre.txt",
+ "THIRD-PARTY-NOTICES.md"]
+# Each font's own OFL text (its copyright line differs), under the names site/public/fonts uses. Every OFL.txt under
+# unity/Assets/UI/Fonts must be here (test_every_shipped_fonts_licence_is_a_required_notice).
+FONT_LICENCES = {"OFL-EBGaramond.txt": "unity/Assets/UI/Fonts/OFL.txt",
+ "OFL-FrankRuhlLibre.txt": "unity/Assets/UI/Fonts/FrankRuhlLibre/OFL.txt"}
+NOTICE_TOPS = {"LICENSE", "LICENSES", "NOTICE", "THIRD-PARTY-NOTICES.md", *FONT_LICENCES}
PHOTOS = "event-photos.json" # Build.PhotoManifestName: written beside every player, read by packaging, not the player
# The release asset names: a contract with the CI player golden check (tools/player_golden_check.py, PR #533), in the
# form of the web zip (statecraft-israel-vX.Y.Z-web.zip, docs/RELEASING.md). {tag} carries the v.
@@ -265,13 +279,55 @@ def archive_name(tag: str, platform: str) -> str:
return ARCHIVES[platform].format(tag=tag)
+def notice_sources() -> dict[str, Path]:
+ """Archive name -> file in the repository: the three root files, each font's licence (FONT_LICENCES), and every
+ LICENSES/*.txt (as package_web.sh copies them)."""
+ sources = {name: REPO / name for name in ("LICENSE", "NOTICE", "THIRD-PARTY-NOTICES.md")}
+ sources.update({name: REPO / src for name, src in FONT_LICENCES.items()})
+ for f in sorted((REPO / "LICENSES").glob("*.txt")):
+ sources[f"LICENSES/{f.name}"] = f
+ for name in REQUIRED_NOTICES:
+ sources.setdefault(name, REPO / name) # a required licence text that is missing: reported by missing_sources
+ return sources
+
+
+def missing_sources() -> list[str]:
+ return [str(src.relative_to(REPO)) for src in notice_sources().values() if not src.is_file()]
+
+
+def add_notices(folder: Path) -> None:
+ """Copies the notices into the player folder, beside the player, so the archive and its file list carry them."""
+ for name, src in notice_sources().items():
+ (folder / name).parent.mkdir(parents=True, exist_ok=True)
+ (folder / name).write_bytes(src.read_bytes())
+
+
+def archive_names(archive: Path) -> list[str]:
+ if archive.name.endswith(".tar.gz"):
+ with tarfile.open(archive) as t:
+ return [m.name for m in t.getmembers() if not m.isdir()]
+ with zipfile.ZipFile(archive) as z:
+ return [n for n in z.namelist() if not n.endswith("/")]
+
+
+def missing_notices(archive: Path) -> list[str]:
+ """The required notices the archive itself lacks (the artefact is checked, as package_web.sh does)."""
+ names = set(archive_names(archive))
+ return sorted(n for n in REQUIRED_NOTICES if n not in names)
+
+
def make_archive(p: Platform, folder: Path, target: Path, dest: Path) -> None:
- """The release archive of one player folder. macOS: ditto keeps the bundle (modes, links), and the zip holds the
- .app alone. Linux: tar keeps the executable bit. Windows: a zip of the folder."""
+ """The release archive of one player folder, notices included. macOS: ditto keeps the bundle (modes, links) and
+ zips the .app; the notices are then added at the zip's top level. Linux: tar keeps the executable bit. Windows: a
+ zip of the folder."""
if p.name == "mac":
# --norsrc: no AppleDouble ._* entries, which unzip would leave as files the file list does not name.
if run(["ditto", "-c", "-k", "--norsrc", "--keepParent", str(target), str(dest)]).returncode != 0:
raise SystemExit(f"ditto failed for {target}")
+ with zipfile.ZipFile(dest, "a", zipfile.ZIP_DEFLATED) as z:
+ for path in shipped(folder, mac=True):
+ if path.is_file() and path.relative_to(folder).parts[0] in NOTICE_TOPS:
+ z.write(path, path.relative_to(folder).as_posix())
elif p.name == "linux":
with tarfile.open(dest, "w:gz") as t:
for path in shipped(folder):
@@ -307,20 +363,23 @@ def unity_seconds(log_text: str) -> int | None:
return int(m.group(1)) if m else None
-def shipped(folder: Path) -> list[Path]:
- """Every path under folder that is part of the player, sorted: Unity's own *_DoNotShip and
- *_ButDontShipItWithYourGame folders (IL2CPP sources, Burst debug data) and the photo manifest are left out."""
+def shipped(folder: Path, mac: bool = False) -> list[Path]:
+ """Every path under folder that the archive carries, sorted: Unity's own *_DoNotShip and
+ *_ButDontShipItWithYourGame folders (IL2CPP sources, Burst debug data) and the photo manifest are left out. For the
+ Mac (mac=True) only the .app and the notices are kept: the zip holds nothing else."""
def skip(path: Path) -> bool:
top = path.relative_to(folder).parts[0]
+ if mac:
+ return not (top.endswith(".app") or top in NOTICE_TOPS)
return top.endswith("_DoNotShip") or top.endswith("_ButDontShipItWithYourGame") or top == PHOTOS
return sorted(p for p in folder.rglob("*") if not skip(p))
-def tree_manifest(folder: Path) -> tuple[str, int, int]:
+def tree_manifest(folder: Path, mac: bool = False) -> tuple[str, int, int]:
"""`shasum -a 256` lines for every file under folder, sorted by path; a symlink is listed by its target, not
followed (`shasum -c` skips such a line with a warning); the do-not-ship folders are left out. Returns the text, the number of entries and the bytes of the regular files."""
rows, size = [], 0
- for path in shipped(folder):
+ for path in shipped(folder, mac):
rel = path.relative_to(folder).as_posix()
if path.is_symlink():
rows.append((rel, f"symlink {rel} -> {os.readlink(path)}"))
@@ -357,8 +416,9 @@ def markdown(r: dict) -> str:
out.extend(f" - `{line}`" for line in g["lines"])
out += ["", "The archive is the release asset. Each file list (`" + "`, `".join(a["file_list"] for a in r["artifacts"])
+ "`) names exactly the files its archive holds; `shasum -a 256 -c` on it, run where the archive was "
- "unpacked, checks every regular file (it skips `symlink` lines, which give a link's target instead). The build's photo manifest is kept beside the record "
- "(`event-photos-<platform>.json`), not in the archive.",
+ "unpacked, checks every regular file (it skips `symlink` lines, which give a link's target instead). Each archive "
+ "carries the licence and attribution files beside the player. The build's photo manifest is kept beside the "
+ "record (`event-photos-<platform>.json`), not in the archive.",
"Steam build ID: (added by the owner after an upload).", ""]
return "\n".join(out)
@@ -392,6 +452,10 @@ def main(argv: list[str] | None = None) -> int:
+ "\nAfter a Unity run, `git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.asset` "
"drops the settings churn (and the UNITY_MCP_* defines).", file=sys.stderr)
return 1
+ if missing := missing_sources():
+ print("REFUSED: notice files every archive must carry are missing from the repository: " + ", ".join(missing)
+ + " (RELEASING.md step 7).", file=sys.stderr)
+ return 1
commit = git("rev-parse", "HEAD").stdout.strip()
branch = git("rev-parse", "--abbrev-ref", "HEAD").stdout.strip()
@@ -470,7 +534,8 @@ def main(argv: list[str] | None = None) -> int:
print(f"FAILED: the {p.name} build (exit {code}); see {log}", file=sys.stderr)
return 1
folder = out / "players" / p.name
- text, files, size = tree_manifest(folder)
+ add_notices(folder)
+ text, files, size = tree_manifest(folder, mac=p.name == "mac")
listing = out / f"files-{p.name}.sha256"
listing.write_text(text)
photos = None
@@ -483,6 +548,9 @@ def main(argv: list[str] | None = None) -> int:
return 1
archive = out / archive_name(tag, p.name)
make_archive(p, folder, target, archive)
+ if lacking := missing_notices(archive):
+ print(f"FAILED: {archive.name} lacks the notices {', '.join(lacking)}", file=sys.stderr)
+ return 1
arch = None
if p.name == "mac":
arch = run(["lipo", "-archs", str(mac_executable(target))], capture=True).stdout.strip() or None
diff --git a/tools/tests/test_release_build.py b/tools/tests/test_release_build.py
index 0d422a4e3..c0e106e45 100644
--- a/tools/tests/test_release_build.py
+++ b/tools/tests/test_release_build.py
@@ -11,6 +11,11 @@ import release_build as rb
H1950 = "71e9904d0ee48083db9bbba281f3f046136482ba83ee056e48d57b62e76a5b07"
H1952 = "62f8ec61a14acff4eab503381994a7c94d7a2f786dcfde5c4c19439ac8b4c5e8"
SHA = "1b7a36cb" + "0" * 32
+LICENCE_TEXTS = ("CC-BY-4.0.txt", "CC-BY-SA-4.0.txt", "CC0-1.0.txt", "YamlDotNet-MIT.txt")
+NOTICES = ["LICENSE", "LICENSES/CC-BY-4.0.txt", "LICENSES/CC-BY-SA-4.0.txt", "LICENSES/CC0-1.0.txt",
+ "LICENSES/YamlDotNet-MIT.txt", "NOTICE", "OFL-EBGaramond.txt", "OFL-FrankRuhlLibre.txt", "THIRD-PARTY-NOTICES.md"]
+FONT_SOURCES = {"OFL-EBGaramond.txt": "unity/Assets/UI/Fonts/OFL.txt",
+ "OFL-FrankRuhlLibre.txt": "unity/Assets/UI/Fonts/FrankRuhlLibre/OFL.txt"}
@pytest.fixture
@@ -25,6 +30,14 @@ def repo(tmp_path):
(root / "sim/Statecraft.Sim/SimInfo.cs").write_text(' public const string Version = "0.1.0";\n')
(root / "sim/Statecraft.Sim.Tests/golden").mkdir(parents=True)
(root / "sim/Statecraft.Sim.Tests/golden/manifest.txt").write_text(f"# pinned\nhash1950 {H1950}\nhash1952 {H1952}\nsmoke5 abc\n")
+ for name in ("LICENSE", "NOTICE", "THIRD-PARTY-NOTICES.md"):
+ (root / name).write_text(f"{name} text\n")
+ (root / "LICENSES").mkdir()
+ for name in LICENCE_TEXTS:
+ (root / "LICENSES" / name).write_text(f"{name} text\n")
+ for name, src in FONT_SOURCES.items():
+ (root / src).parent.mkdir(parents=True, exist_ok=True)
+ (root / src).write_text(f"{name}: Copyright line of this font\n")
return root
@@ -102,7 +115,13 @@ class Fake:
log.write_text(f"boot\nGOLDEN OK 1950 {H1950}\n{second}\n")
code = 0 if self.golden_ok else 1
elif cmd[0] == "ditto":
- Path(cmd[-1]).write_bytes(b"PK mac zip of " + Path(cmd[-2]).name.encode())
+ # Plays `ditto -c -k --norsrc --keepParent SRC ZIP`: a real zip, SRC's name as the top folder.
+ import zipfile
+ src, dest = Path(cmd[-2]), Path(cmd[-1])
+ with zipfile.ZipFile(dest, "w") as z:
+ for p in sorted(src.rglob("*")):
+ if p.is_file():
+ z.write(p, (Path(src.name) / p.relative_to(src)).as_posix())
elif cmd[0] == "lipo":
out = "x86_64 arm64\n"
return rb.Result(code, out)
@@ -470,7 +489,8 @@ def test_the_record_holds_commit_unity_date_hashes_sizes_and_goldens(repo, edito
exe = out / "players/mac/Statecraft.app/Contents/MacOS/Statecraft Israel"
assert f"{hashlib.sha256(b'player').hexdigest()} Statecraft.app/Contents/MacOS/Statecraft Israel" in lines
assert not any(line.endswith("event-photos.json") for line in lines), "the list is exactly what the zip holds"
- assert all(line.split(" ", 1)[1].startswith("Statecraft.app/") for line in lines)
+ assert all(line.split(" ", 1)[1].startswith("Statecraft.app/") or line.split(" ", 1)[1] in NOTICES for line in lines)
+ assert [l.split(" ", 1)[1] for l in lines if not l.split(" ", 1)[1].startswith("Statecraft.app/")] == NOTICES
photos = out / mac["photo_manifest"]["file"]
assert photos.name == "event-photos-mac.json" and photos.read_text() == "{}\n"
assert mac["photo_manifest"]["sha256"] == hashlib.sha256(photos.read_bytes()).hexdigest()
@@ -483,7 +503,8 @@ def test_the_record_holds_commit_unity_date_hashes_sizes_and_goldens(repo, edito
assert arts[name]["archive"] == {"name": asset, "bytes": archive.stat().st_size,
"sha256": hashlib.sha256(archive.read_bytes()).hexdigest()}
assert mac["files"] == len(lines)
- assert mac["bytes"] == sum(p.stat().st_size for p in (out / "players/mac/Statecraft.app").rglob("*") if p.is_file())
+ assert mac["bytes"] == sum(p.stat().st_size for p in (out / "players/mac/Statecraft.app").rglob("*") if p.is_file()) \
+ + sum((out / "players/mac" / n).stat().st_size for n in NOTICES)
assert exe.is_file()
assert mac["golden"]["status"] == "pass"
@@ -565,9 +586,9 @@ def test_the_linux_and_windows_archives_hold_the_player_folder(repo, editor, mon
out = tmp_path / "out"
assert run_main(["--platform", "all", "--out", str(out)], repo, editor, Fake(), monkeypatch) == 0
with tarfile.open(out / "statecraft-israel-v0.1.0-linux-x64.tar.gz") as t:
- assert t.getnames() == ["Statecraft.x86_64"]
+ assert [m.name for m in t.getmembers() if m.isfile()] == sorted(NOTICES + ["Statecraft.x86_64"])
with zipfile.ZipFile(out / "statecraft-israel-v0.1.0-windows-x64.zip") as z:
- assert z.namelist() == ["Statecraft.exe"]
+ assert [n for n in z.namelist() if not n.endswith("/")] == sorted(NOTICES + ["Statecraft.exe"])
def test_the_linux_archive_keeps_the_executable_bit(tmp_path):
@@ -671,3 +692,99 @@ def test_a_dangling_symlink_into_the_repository_is_refused(repo, editor, monkeyp
def test_a_tag_with_non_ascii_digits_is_not_a_release_tag(tag):
"""\\d without re.ASCII matches Arabic-Indic and full-width digits; a tag reaches file names and the CI check."""
assert rb.TAG.fullmatch(tag) is None
+
+
+# --- the notices in every desktop archive (RELEASING.md step 7; P47) -------------------------------------------------------
+
+def archive_files(path):
+ import tarfile
+ import zipfile
+ if path.name.endswith(".tar.gz"):
+ with tarfile.open(path) as t:
+ return sorted(m.name for m in t.getmembers() if m.isfile() or m.issym())
+ with zipfile.ZipFile(path) as z:
+ return sorted(n for n in z.namelist() if not n.endswith("/"))
+
+
+def test_every_archive_carries_the_notices_and_matches_its_file_list(repo, editor, monkeypatch, tmp_path):
+ out = tmp_path / "out"
+ assert run_main(["--platform", "all", "--out", str(out)], repo, editor, Fake(), monkeypatch) == 0
+ record = json.loads((out / "build-record.json").read_text())
+ for a in record["artifacts"]:
+ names = archive_files(out / a["archive"]["name"])
+ for notice in NOTICES:
+ assert notice in names, (a["platform"], notice)
+ assert (zip_text(out / a["archive"]["name"], notice)) == (repo / FONT_SOURCES.get(notice, notice)).read_text()
+ listed = sorted(l.split(" ", 1)[1].split(" -> ")[0] for l in (out / a["file_list"]).read_text().splitlines())
+ assert listed == names, f"{a['platform']}: the file list is exactly the archive"
+
+
+def zip_text(path, name):
+ import tarfile
+ import zipfile
+ if path.name.endswith(".tar.gz"):
+ with tarfile.open(path) as t:
+ return t.extractfile(name).read().decode()
+ with zipfile.ZipFile(path) as z:
+ return z.read(name).decode()
+
+
+def test_the_mac_zip_keeps_the_app_whole_with_the_notices_beside_it_and_no_appledouble(repo, editor, monkeypatch, tmp_path):
+ out = tmp_path / "out"
+ fake = Fake()
+ assert run_main(["--platform", "mac", "--out", str(out)], repo, editor, fake, monkeypatch) == 0
+ names = archive_files(out / "statecraft-israel-v0.1.0-macos-universal.zip")
+ assert not [n for n in names if Path(n).name.startswith("._")]
+ tops = sorted({n.split("/")[0] for n in names})
+ assert tops == sorted({"Statecraft.app", "LICENSE", "LICENSES", "NOTICE", "OFL-EBGaramond.txt", "OFL-FrankRuhlLibre.txt",
+ "THIRD-PARTY-NOTICES.md"})
+ ditto = next(c for c in fake.calls if c[0] == "ditto")
+ assert "--norsrc" in ditto and ditto[-2].endswith("Statecraft.app"), "the bundle is still zipped by ditto"
+
+
+def test_the_one_player_rule_still_holds_with_the_notices(repo, editor, monkeypatch, tmp_path):
+ out = tmp_path / "out"
+ assert run_main(["--platform", "all", "--out", str(out)], repo, editor, Fake(), monkeypatch) == 0
+ for name in ("mac", "linux", "windows"):
+ assert rb.player_problem(rb.PLATFORMS[name], out / "players" / name) is None
+
+
[email protected]("missing", ["NOTICE", "LICENSES/CC-BY-4.0.txt", "unity/Assets/UI/Fonts/OFL.txt",
+ "unity/Assets/UI/Fonts/FrankRuhlLibre/OFL.txt"])
+def test_a_missing_notice_file_is_refused_before_any_build(repo, editor, monkeypatch, tmp_path, capsys, missing):
+ (repo / missing).unlink()
+ fake = Fake()
+ assert run_main(["--platform", "linux", "--out", str(tmp_path / "o")], repo, editor, fake, monkeypatch) == 1
+ assert unity_calls(fake) == []
+ assert missing in capsys.readouterr().err
+
+
+def test_an_archive_without_its_notices_is_caught(tmp_path):
+ import zipfile
+ z = tmp_path / "a.zip"
+ with zipfile.ZipFile(z, "w") as f:
+ f.writestr("Statecraft.exe", "x")
+ f.writestr("LICENSE", "x")
+ assert "NOTICE" in rb.missing_notices(z)
+ assert rb.missing_notices(z) == sorted(set(NOTICES) - {"LICENSE"})
+
+
+def test_the_notice_list_is_the_web_packagers():
+ """One list: the files scripts/oss/package_web.sh copies and checks in the web zip (index.html aside)."""
+ import re
+ script = (Path(rb.__file__).resolve().parents[1] / "scripts/oss/package_web.sh").read_text()
+ loop = re.search(r"for f in (.*?); do", script, re.S).group(1).replace("\\\n", " ")
+ web = sorted(set(loop.split()) - {"index.html"})
+ assert sorted(rb.REQUIRED_NOTICES) == web == NOTICES
+
+
+def test_every_shipped_fonts_licence_is_a_required_notice():
+ """The OFL asks that each font's copyright notice and licence travel with it: every OFL.txt under
+ unity/Assets/UI/Fonts (one per font folder) is shipped under its own name, so the next font cannot be missed."""
+ root = Path(rb.__file__).resolve().parents[1]
+ found = sorted(p.relative_to(root).as_posix() for p in (root / "unity/Assets/UI/Fonts").rglob("OFL.txt"))
+ assert found == sorted(FONT_SOURCES.values())
+ assert sorted(rb.FONT_LICENCES.values()) == found
+ for name in rb.FONT_LICENCES:
+ assert name in rb.REQUIRED_NOTICES
+ assert rb.FONT_LICENCES == FONT_SOURCES, "the names site/public/fonts already uses"