standards-sync 0.0.9__tar.gz → 0.0.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {standards_sync-0.0.9 → standards_sync-0.0.11}/CHANGELOG.md +31 -0
  2. {standards_sync-0.0.9 → standards_sync-0.0.11}/PKG-INFO +5 -1
  3. {standards_sync-0.0.9 → standards_sync-0.0.11}/README.md +4 -0
  4. {standards_sync-0.0.9 → standards_sync-0.0.11}/pyproject.toml +1 -1
  5. standards_sync-0.0.11/scripts/check_lock.py +76 -0
  6. standards_sync-0.0.11/scripts/pkg.py +142 -0
  7. standards_sync-0.0.11/tests/test_check_lock.py +66 -0
  8. standards_sync-0.0.11/tests/test_pkg.py +95 -0
  9. {standards_sync-0.0.9 → standards_sync-0.0.11}/.gitignore +0 -0
  10. {standards_sync-0.0.9 → standards_sync-0.0.11}/LICENSE-APACHE +0 -0
  11. {standards_sync-0.0.9 → standards_sync-0.0.11}/LICENSE-MIT +0 -0
  12. {standards_sync-0.0.9 → standards_sync-0.0.11}/fuzz/corpus/blanks +0 -0
  13. {standards_sync-0.0.9 → standards_sync-0.0.11}/fuzz/corpus/empty +0 -0
  14. {standards_sync-0.0.9 → standards_sync-0.0.11}/fuzz/corpus/one-path +0 -0
  15. {standards_sync-0.0.9 → standards_sync-0.0.11}/fuzz/corpus/two-paths +0 -0
  16. {standards_sync-0.0.9 → standards_sync-0.0.11}/fuzz/corpus/whitespace-component +0 -0
  17. {standards_sync-0.0.9 → standards_sync-0.0.11}/fuzz/fuzz_atheris.py +0 -0
  18. {standards_sync-0.0.9 → standards_sync-0.0.11}/fuzz/test_fuzz_sync.py +0 -0
  19. {standards_sync-0.0.9 → standards_sync-0.0.11}/scripts/check_api.py +0 -0
  20. {standards_sync-0.0.9 → standards_sync-0.0.11}/scripts/check_complexity.py +0 -0
  21. {standards_sync-0.0.9 → standards_sync-0.0.11}/scripts/check_docs.py +0 -0
  22. {standards_sync-0.0.9 → standards_sync-0.0.11}/scripts/release.py +0 -0
  23. {standards_sync-0.0.9 → standards_sync-0.0.11}/scripts/sync.py +0 -0
  24. {standards_sync-0.0.9 → standards_sync-0.0.11}/tests/conftest.py +0 -0
  25. {standards_sync-0.0.9 → standards_sync-0.0.11}/tests/smoke.py +0 -0
  26. {standards_sync-0.0.9 → standards_sync-0.0.11}/tests/test_check_api.py +0 -0
  27. {standards_sync-0.0.9 → standards_sync-0.0.11}/tests/test_check_complexity.py +0 -0
  28. {standards_sync-0.0.9 → standards_sync-0.0.11}/tests/test_check_docs.py +0 -0
  29. {standards_sync-0.0.9 → standards_sync-0.0.11}/tests/test_release.py +0 -0
  30. {standards_sync-0.0.9 → standards_sync-0.0.11}/tests/test_sync.py +0 -0
@@ -7,6 +7,35 @@ All notable changes to Standards are recorded here, in the form of
7
7
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follow
8
8
  [AGENTS.md](AGENTS.md) section 3.
9
9
 
10
+ ## [0.0.11] - 2026-11-25
11
+
12
+ ### Changed
13
+
14
+ - Dependencies: the dev container's base image moves from Python 3.13 to
15
+ 3.15 (Dependabot #16), and `cachix/install-nix-action`, which builds the
16
+ Nix package in CI, from 31.11.3 to 32.0.0 (Dependabot #17).
17
+
18
+ ## [0.0.10] - 2026-11-25
19
+
20
+ ### Added
21
+
22
+ - Distribution packages. `make pkg` packs the installed tree as a
23
+ reproducible `standards-sync-<version>-unix.tar.gz` and renders the
24
+ recipes in `pkg/` against it: a Debian package root, an RPM spec, an
25
+ AUR `PKGBUILD` and `.SRCINFO`, a Homebrew formula and a Nix expression.
26
+ CI builds and installs each one (apt on Ubuntu, dnf on Fedora 44,
27
+ pacman on Arch, brew on macOS, nix-build on nixpkgs 26.05), and every
28
+ release attaches the `.deb`, the `.rpm` and the recipes.
29
+ - A dependency provenance policy (`docs/POLICIES.md`), enforced by
30
+ `scripts/check_lock.py` in `make lint`: every locked package from PyPI
31
+ with a SHA-256 for every file, and every `uv` call in the Makefiles and
32
+ workflows frozen to the lock.
33
+
34
+ ### Changed
35
+
36
+ - The dev container's base image is pinned by digest, in
37
+ `.devcontainer/Dockerfile`, which Dependabot now updates.
38
+
10
39
  ## [0.0.9] - 2026-11-25
11
40
 
12
41
  ### Changed
@@ -201,6 +230,8 @@ All notable changes to Standards are recorded here, in the form of
201
230
  - Canonical README Standard (`README-TEMPLATE.md`).
202
231
  - Repository Gold Standard (`REPO-STANDARD.md`).
203
232
 
233
+ [0.0.11]: https://github.com/sebastienrousseau/standards/compare/v0.0.10...v0.0.11
234
+ [0.0.10]: https://github.com/sebastienrousseau/standards/compare/v0.0.9...v0.0.10
204
235
  [0.0.9]: https://github.com/sebastienrousseau/standards/compare/v0.0.8...v0.0.9
205
236
  [0.0.8]: https://github.com/sebastienrousseau/standards/compare/v0.0.7...v0.0.8
206
237
  [0.0.7]: https://github.com/sebastienrousseau/standards/compare/v0.0.6...v0.0.7
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: standards-sync
3
- Version: 0.0.9
3
+ Version: 0.0.11
4
4
  Summary: Keep the canonical code standards in sync with the workspace root and dotfiles copies.
5
5
  Project-URL: Homepage, https://github.com/sebastienrousseau/standards
6
6
  Project-URL: Documentation, https://sebastienrousseau.com/standards/
@@ -99,6 +99,10 @@ From a clone, with the manpage and bash, zsh and fish completions:
99
99
  make PREFIX="$HOME/.local" install
100
100
  ```
101
101
 
102
+ Each [release](https://github.com/sebastienrousseau/standards/releases)
103
+ also carries a `.deb` and a `.rpm`, and the recipes for Arch (AUR),
104
+ Homebrew and Nix; [docs/packaging.md](docs/packaging.md) lists them.
105
+
102
106
  The [dotfiles](https://github.com/sebastienrousseau/dotfiles) also install
103
107
  it as `~/.local/bin/standards-sync`, and link `~/Code`'s standards to a
104
108
  clone of this repository.
@@ -77,6 +77,10 @@ From a clone, with the manpage and bash, zsh and fish completions:
77
77
  make PREFIX="$HOME/.local" install
78
78
  ```
79
79
 
80
+ Each [release](https://github.com/sebastienrousseau/standards/releases)
81
+ also carries a `.deb` and a `.rpm`, and the recipes for Arch (AUR),
82
+ Homebrew and Nix; [docs/packaging.md](docs/packaging.md) lists them.
83
+
80
84
  The [dotfiles](https://github.com/sebastienrousseau/dotfiles) also install
81
85
  it as `~/.local/bin/standards-sync`, and link `~/Code`'s standards to a
82
86
  clone of this repository.
@@ -3,7 +3,7 @@
3
3
 
4
4
  [project]
5
5
  name = "standards-sync"
6
- version = "0.0.9"
6
+ version = "0.0.11"
7
7
  description = "Keep the canonical code standards in sync with the workspace root and dotfiles copies."
8
8
  readme = "README.md"
9
9
  license = "Apache-2.0 OR MIT"
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: 2026 Sebastien Rousseau
3
+ # SPDX-License-Identifier: Apache-2.0 OR MIT
4
+ """Hold the dependency provenance policy of docs/POLICIES.md.
5
+
6
+ - Every package in uv.lock comes from PyPI, apart from this project itself:
7
+ no git, URL or path source.
8
+ - Every sdist and wheel in uv.lock carries a SHA-256, which uv checks on
9
+ install.
10
+ - Every `uv run` and `uv sync` in the Makefiles and workflows is `--frozen`
11
+ or `--locked`, so CI installs exactly the locked, hashed set.
12
+
13
+ uv.lock is read line by line, not with tomllib, so this runs on every
14
+ Python the dev tools support (3.10 has no tomllib).
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import re
20
+ import sys
21
+ from pathlib import Path
22
+
23
+ ROOT = Path(__file__).resolve().parents[1]
24
+ PYPI = 'source = { registry = "https://pypi.org/simple" }'
25
+ SELF = 'source = { editable = "." }'
26
+ ARTIFACT = re.compile(r'\burl = "([^"]+)"')
27
+ HASH = re.compile(r'\bhash = "sha256:[0-9a-f]{64}"')
28
+ UV_CALL = re.compile(r"(?:\buv|\$\(UV\))\s+(?:run|sync)\b[^\n]*")
29
+ FROZEN = re.compile(r"--(?:frozen|locked)\b")
30
+
31
+
32
+ def _packages(lock: str) -> list[str]:
33
+ return lock.split("\n[[package]]\n")[1:]
34
+
35
+
36
+ def lock_errors(lock: str) -> list[str]:
37
+ """Sources other than PyPI, and artifacts without a SHA-256."""
38
+ errors = []
39
+ for block in _packages(lock):
40
+ name = re.search(r'(?m)^name = "([^"]+)"', block)
41
+ label = name.group(1) if name else "?"
42
+ source = re.search(r"(?m)^source = .*$", block)
43
+ if not source or source.group(0) not in (PYPI, SELF):
44
+ errors.append(f"uv.lock: {label}: source is not PyPI: {source.group(0) if source else 'none'}")
45
+ for line in block.splitlines():
46
+ url = ARTIFACT.search(line)
47
+ if url and not HASH.search(line):
48
+ errors.append(f"uv.lock: {label}: no SHA-256 for {url.group(1)}")
49
+ return errors
50
+
51
+
52
+ def unfrozen_calls(path: Path, text: str) -> list[str]:
53
+ """`uv run` or `uv sync` calls that may re-resolve instead of using the lock."""
54
+ errors = []
55
+ for number, line in enumerate(text.splitlines(), 1):
56
+ for call in UV_CALL.findall(line):
57
+ if not FROZEN.search(call):
58
+ errors.append(f"{path}:{number}: uv call without --frozen or --locked: {call.strip()}")
59
+ return errors
60
+
61
+
62
+ def main(root: Path = ROOT) -> int:
63
+ """Check uv.lock and every uv call; print each failure."""
64
+ errors = lock_errors((root / "uv.lock").read_text(encoding="utf-8"))
65
+ files = [root / "Makefile", root / "GNUmakefile", *sorted((root / ".github" / "workflows").glob("*.yml"))]
66
+ for path in files:
67
+ errors += unfrozen_calls(path.relative_to(root), path.read_text(encoding="utf-8"))
68
+ for error in errors:
69
+ print(error)
70
+ if not errors:
71
+ print("lock: every dependency from PyPI, hashed, installed frozen")
72
+ return 1 if errors else 0
73
+
74
+
75
+ if __name__ == "__main__":
76
+ sys.exit(main())
@@ -0,0 +1,142 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: 2026 Sebastien Rousseau
3
+ # SPDX-License-Identifier: Apache-2.0 OR MIT
4
+ """Generate the distribution packages' inputs from an installed tree.
5
+
6
+ `make pkg` installs standards-sync into build/pkg/stage/standards-sync-<v>
7
+ (the install contract of GNUmakefile, with the licences), then runs this:
8
+
9
+ - the tree becomes standards-sync-<v>-unix.tar.gz, byte-identical for the
10
+ same SOURCE_DATE_EPOCH;
11
+ - every template in pkg/<format>/ is rendered into build/pkg/<format>/ with
12
+ the version, the tarball's URL and its SHA-256 (hex and SRI);
13
+ - build/pkg/deb/ gets a package root that `dpkg-deb --build` turns into a
14
+ .deb.
15
+
16
+ Every template token must resolve; an unknown @TOKEN@ is an error.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import argparse
22
+ import base64
23
+ import gzip
24
+ import hashlib
25
+ import os
26
+ import re
27
+ import shutil
28
+ import sys
29
+ import tarfile
30
+ from pathlib import Path
31
+
32
+ ROOT = Path(__file__).resolve().parents[1]
33
+ NAME = "standards-sync"
34
+ RELEASES = "https://github.com/sebastienrousseau/standards/releases/download"
35
+ TOKEN = re.compile(r"@[A-Z0-9_]+@")
36
+
37
+
38
+ def project_version(pyproject: Path) -> str:
39
+ """The version in pyproject.toml's [project] table."""
40
+ match = re.search(r'(?m)^version = "([^"]+)"', pyproject.read_text(encoding="utf-8"))
41
+ if not match:
42
+ raise SystemExit(f"{pyproject}: no version")
43
+ return match.group(1)
44
+
45
+
46
+ def _normalised(info: tarfile.TarInfo, mtime: int) -> tarfile.TarInfo:
47
+ info.uid = info.gid = 0
48
+ info.uname = info.gname = ""
49
+ info.mtime = mtime
50
+ info.mode = 0o755 if info.isdir() or info.mode & 0o111 else 0o644
51
+ return info
52
+
53
+
54
+ def write_tarball(tree: Path, out: Path, mtime: int) -> None:
55
+ """Pack `tree` as out, with sorted entries, root ownership and one mtime."""
56
+ paths = [tree, *sorted(tree.rglob("*"))]
57
+ with (
58
+ out.open("wb") as raw,
59
+ gzip.GzipFile(filename="", fileobj=raw, mode="wb", mtime=0) as gz,
60
+ tarfile.open(fileobj=gz, mode="w", format=tarfile.PAX_FORMAT) as tar,
61
+ ):
62
+ for path in paths:
63
+ info = _normalised(tar.gettarinfo(str(path), path.relative_to(tree.parent).as_posix()), mtime)
64
+ if info.isfile():
65
+ with path.open("rb") as data:
66
+ tar.addfile(info, data)
67
+ else:
68
+ tar.addfile(info)
69
+
70
+
71
+ def render(text: str, values: dict[str, str]) -> str:
72
+ """Replace each @KEY@ in text; fail on a token with no value."""
73
+ for key, value in values.items():
74
+ text = text.replace(f"@{key}@", value)
75
+ left = sorted(set(TOKEN.findall(text)))
76
+ if left:
77
+ raise SystemExit(f"unresolved template tokens: {', '.join(left)}")
78
+ return text
79
+
80
+
81
+ def render_templates(templates: Path, out: Path, values: dict[str, str]) -> list[Path]:
82
+ """Render every file under templates/<format>/ into out/<format>/."""
83
+ written = []
84
+ for template in sorted(p for p in templates.rglob("*") if p.is_file()):
85
+ target = out / template.relative_to(templates)
86
+ target.parent.mkdir(parents=True, exist_ok=True)
87
+ target.write_text(render(template.read_text(encoding="utf-8"), values), encoding="utf-8")
88
+ written.append(target)
89
+ return written
90
+
91
+
92
+ def deb_root(tree: Path, out: Path, version: str) -> Path:
93
+ """A dpkg-deb package root: the tree under /usr, control and copyright."""
94
+ root = out / "deb" / f"{NAME}_{version}-1_all"
95
+ shutil.rmtree(root, ignore_errors=True)
96
+ shutil.copytree(tree, root / "usr")
97
+ shutil.rmtree(root / "usr" / "share" / "licenses")
98
+ (root / "DEBIAN").mkdir()
99
+ shutil.move(str(out / "deb" / "control"), root / "DEBIAN" / "control")
100
+ doc = root / "usr" / "share" / "doc" / NAME
101
+ doc.mkdir(parents=True)
102
+ shutil.move(str(out / "deb" / "copyright"), doc / "copyright")
103
+ return root
104
+
105
+
106
+ def build_parser() -> argparse.ArgumentParser:
107
+ """The command line: the staged tree, the output and the download URL."""
108
+ parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
109
+ parser.add_argument("--stage", type=Path, required=True, help="directory holding standards-sync-<version>/")
110
+ parser.add_argument("--out", type=Path, required=True, help="where to write the tarball and the recipes")
111
+ parser.add_argument("--templates", type=Path, default=ROOT / "pkg", help="the pkg/ template directory")
112
+ parser.add_argument("--url-base", help=f"where the tarball is served (default: {RELEASES}/v<version>)")
113
+ return parser
114
+
115
+
116
+ def main(argv: list[str] | None = None) -> int:
117
+ """Pack the staged tree, render the recipes and prepare the .deb root."""
118
+ args = build_parser().parse_args(argv)
119
+ version = project_version(ROOT / "pyproject.toml")
120
+ tree = args.stage / f"{NAME}-{version}"
121
+ if not tree.is_dir():
122
+ raise SystemExit(f"{tree}: not found; run make pkg")
123
+ tarball = args.out / f"{NAME}-{version}-unix.tar.gz"
124
+ args.out.mkdir(parents=True, exist_ok=True)
125
+ write_tarball(tree, tarball, int(os.environ.get("SOURCE_DATE_EPOCH", "0")))
126
+ digest = hashlib.sha256(tarball.read_bytes()).digest()
127
+ values = {
128
+ "VERSION": version,
129
+ "TARBALL": tarball.name,
130
+ "URL": f"{args.url_base or f'{RELEASES}/v{version}'}/{tarball.name}",
131
+ "SHA256": digest.hex(),
132
+ "SRI": "sha256-" + base64.b64encode(digest).decode(),
133
+ }
134
+ for path in render_templates(args.templates, args.out, values):
135
+ print(path)
136
+ print(deb_root(tree, args.out, version))
137
+ print(tarball)
138
+ return 0
139
+
140
+
141
+ if __name__ == "__main__":
142
+ sys.exit(main())
@@ -0,0 +1,66 @@
1
+ # SPDX-FileCopyrightText: 2026 Sebastien Rousseau
2
+ # SPDX-License-Identifier: Apache-2.0 OR MIT
3
+ """Tests for scripts/check_lock.py: the dependency provenance policy."""
4
+
5
+ from __future__ import annotations
6
+
7
+ from pathlib import Path
8
+
9
+ import check_lock
10
+
11
+ HASH = "sha256:" + "a" * 64
12
+ GOOD = f"""version = 1
13
+
14
+ [[package]]
15
+ name = "ruff"
16
+ version = "1.0"
17
+ source = {{ registry = "https://pypi.org/simple" }}
18
+ sdist = {{ url = "https://files.pythonhosted.org/r.tar.gz", hash = "{HASH}", size = 1 }}
19
+ wheels = [
20
+ {{ url = "https://files.pythonhosted.org/r.whl", hash = "{HASH}", size = 1 }},
21
+ ]
22
+
23
+ [[package]]
24
+ name = "standards-sync"
25
+ version = "0.0.1"
26
+ source = {{ editable = "." }}
27
+ """
28
+
29
+
30
+ def test_a_hashed_pypi_lock_passes() -> None:
31
+ assert check_lock.lock_errors(GOOD) == []
32
+
33
+
34
+ def test_a_git_source_fails() -> None:
35
+ lock = GOOD.replace('{ registry = "https://pypi.org/simple" }', '{ git = "https://example.com/r" }')
36
+ error = 'uv.lock: ruff: source is not PyPI: source = { git = "https://example.com/r" }'
37
+ assert check_lock.lock_errors(lock) == [error]
38
+
39
+
40
+ def test_a_package_with_no_source_fails() -> None:
41
+ lock = GOOD.replace('source = { editable = "." }\n', "")
42
+ assert check_lock.lock_errors(lock) == ["uv.lock: standards-sync: source is not PyPI: none"]
43
+
44
+
45
+ def test_an_unhashed_artifact_fails() -> None:
46
+ lock = GOOD.replace(f'r.whl", hash = "{HASH}"', 'r.whl"')
47
+ assert check_lock.lock_errors(lock) == ["uv.lock: ruff: no SHA-256 for https://files.pythonhosted.org/r.whl"]
48
+
49
+
50
+ def test_uv_calls_must_use_the_lock() -> None:
51
+ text = "a:\n\tuv run --frozen x\n\tuv sync\n\t$(UV) run y\n\tuv run --locked z\n\tuv build\n"
52
+ assert check_lock.unfrozen_calls(Path("Makefile"), text) == [
53
+ "Makefile:3: uv call without --frozen or --locked: uv sync",
54
+ "Makefile:4: uv call without --frozen or --locked: $(UV) run y",
55
+ ]
56
+
57
+
58
+ def test_main_checks_the_repository(tmp_path: Path, capsys) -> None:
59
+ assert check_lock.main() == 0
60
+ (tmp_path / ".github" / "workflows").mkdir(parents=True)
61
+ (tmp_path / "uv.lock").write_text(GOOD, encoding="utf-8")
62
+ (tmp_path / "Makefile").write_text("x:\n\tuv sync\n", encoding="utf-8")
63
+ (tmp_path / "GNUmakefile").write_text("", encoding="utf-8")
64
+ (tmp_path / ".github" / "workflows" / "ci.yml").write_text("run: uv run --frozen pytest\n", encoding="utf-8")
65
+ assert check_lock.main(tmp_path) == 1
66
+ assert "Makefile:2" in capsys.readouterr().out
@@ -0,0 +1,95 @@
1
+ # SPDX-FileCopyrightText: 2026 Sebastien Rousseau
2
+ # SPDX-License-Identifier: Apache-2.0 OR MIT
3
+ """Tests for scripts/pkg.py: the package tarball and the rendered recipes."""
4
+
5
+ from __future__ import annotations
6
+
7
+ import base64
8
+ import hashlib
9
+ import tarfile
10
+ from pathlib import Path
11
+
12
+ import pytest
13
+
14
+ import pkg
15
+
16
+ VERSION = pkg.project_version(pkg.ROOT / "pyproject.toml")
17
+
18
+
19
+ def stage(tmp_path: Path) -> Path:
20
+ tree = tmp_path / "stage" / f"standards-sync-{VERSION}"
21
+ (tree / "bin").mkdir(parents=True)
22
+ (tree / "bin" / "standards-sync").write_text("#!/usr/bin/env python3\n", encoding="utf-8")
23
+ (tree / "bin" / "standards-sync").chmod(0o700)
24
+ licences = tree / "share" / "licenses" / "standards-sync"
25
+ licences.mkdir(parents=True)
26
+ (licences / "LICENSE-MIT").write_text("MIT\n", encoding="utf-8")
27
+ return tmp_path / "stage"
28
+
29
+
30
+ def test_project_version_reads_pyproject(tmp_path: Path) -> None:
31
+ pyproject = tmp_path / "pyproject.toml"
32
+ pyproject.write_text('[project]\nname = "x"\nversion = "1.2.3"\n', encoding="utf-8")
33
+ assert pkg.project_version(pyproject) == "1.2.3"
34
+ pyproject.write_text("[project]\n", encoding="utf-8")
35
+ with pytest.raises(SystemExit, match="no version"):
36
+ pkg.project_version(pyproject)
37
+
38
+
39
+ def test_tarball_is_reproducible_and_normalised(tmp_path: Path) -> None:
40
+ tree = stage(tmp_path) / f"standards-sync-{VERSION}"
41
+ first, second = tmp_path / "a.tar.gz", tmp_path / "b.tar.gz"
42
+ pkg.write_tarball(tree, first, 86400)
43
+ (tree / "bin" / "standards-sync").touch()
44
+ pkg.write_tarball(tree, second, 86400)
45
+ assert first.read_bytes() == second.read_bytes()
46
+ with tarfile.open(first) as tar:
47
+ members = {m.name: m for m in tar.getmembers()}
48
+ script = members[f"standards-sync-{VERSION}/bin/standards-sync"]
49
+ assert (script.mode, script.uid, script.uname, script.mtime) == (0o755, 0, "", 86400)
50
+ assert members[f"standards-sync-{VERSION}/share/licenses/standards-sync/LICENSE-MIT"].mode == 0o644
51
+ assert list(members) == sorted(members)
52
+
53
+
54
+ def test_render_fills_tokens_and_rejects_unknown_ones() -> None:
55
+ assert pkg.render("v@VERSION@ @SHA256@", {"VERSION": "1", "SHA256": "ab"}) == "v1 ab"
56
+ with pytest.raises(SystemExit, match="@NOPE@"):
57
+ pkg.render("@VERSION@ @NOPE@", {"VERSION": "1"})
58
+
59
+
60
+ def test_main_renders_every_recipe_against_the_tarball(tmp_path: Path, monkeypatch, capsys) -> None:
61
+ monkeypatch.setenv("SOURCE_DATE_EPOCH", "86400")
62
+ out = tmp_path / "out"
63
+ assert pkg.main(["--stage", str(stage(tmp_path)), "--out", str(out), "--url-base", "file:///srv"]) == 0
64
+ tarball = out / f"standards-sync-{VERSION}-unix.tar.gz"
65
+ digest = hashlib.sha256(tarball.read_bytes()).digest()
66
+ brew = (out / "brew" / "standards-sync.rb").read_text(encoding="utf-8")
67
+ assert f'url "file:///srv/{tarball.name}"' in brew
68
+ assert f'sha256 "{digest.hex()}"' in brew
69
+ nix = (out / "nix" / "package.nix").read_text(encoding="utf-8")
70
+ assert f'hash = "sha256-{base64.b64encode(digest).decode()}"' in nix
71
+ assert f'source=("{tarball.name}::file:///srv/{tarball.name}")' in (out / "aur" / "PKGBUILD").read_text()
72
+ assert f"Version: {VERSION}\n" in (out / "rpm" / "standards-sync.spec").read_text()
73
+ assert str(tarball) in capsys.readouterr().out
74
+
75
+
76
+ def test_main_prepares_the_deb_root(tmp_path: Path) -> None:
77
+ out = tmp_path / "out"
78
+ pkg.main(["--stage", str(stage(tmp_path)), "--out", str(out)])
79
+ root = out / "deb" / f"standards-sync_{VERSION}-1_all"
80
+ assert f"Version: {VERSION}-1\n" in (root / "DEBIAN" / "control").read_text()
81
+ assert (root / "usr" / "share" / "doc" / "standards-sync" / "copyright").is_file()
82
+ assert (root / "usr" / "bin" / "standards-sync").is_file()
83
+ assert not (root / "usr" / "share" / "licenses").exists()
84
+
85
+
86
+ def test_main_defaults_to_the_release_url(tmp_path: Path) -> None:
87
+ out = tmp_path / "out"
88
+ pkg.main(["--stage", str(stage(tmp_path)), "--out", str(out)])
89
+ url = f"{pkg.RELEASES}/v{VERSION}/standards-sync-{VERSION}-unix.tar.gz"
90
+ assert f'url "{url}"' in (out / "brew" / "standards-sync.rb").read_text()
91
+
92
+
93
+ def test_main_needs_the_staged_tree(tmp_path: Path) -> None:
94
+ with pytest.raises(SystemExit, match="run make pkg"):
95
+ pkg.main(["--stage", str(tmp_path), "--out", str(tmp_path / "out")])