31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
# Docs inputs for the archive page's Cabinet section (tools/fixtures.py; tools/docs_check.py explains the inputs): an
|
|
# MSZIP cabinet of a small tree by gcab.
|
|
# tests/gen/docs_arch_cab.luau { files = { [name] = bytes }, vars = { cabBytes = "setup.cab" } }
|
|
import importlib.util, os, subprocess, tempfile
|
|
|
|
INPUTS = ["tools/docs_check.py"]
|
|
|
|
MTIME = 1767225600 # 2026-01-01T00:00:00Z
|
|
|
|
|
|
def docs_check(ctx):
|
|
spec = importlib.util.spec_from_file_location("docs_check", os.path.join(ctx.root, "tools", "docs_check.py"))
|
|
m = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(m)
|
|
return m
|
|
|
|
|
|
def generate(ctx):
|
|
dc = docs_check(ctx)
|
|
files = {}
|
|
with tempfile.TemporaryDirectory() as d:
|
|
os.makedirs(os.path.join(d, "bin"))
|
|
for n, data in (("readme.txt", b"rosetta cabinet\n" * 20), ("bin/tool.dll", bytes(range(256)) * 64)):
|
|
with open(os.path.join(d, n), "wb") as f:
|
|
f.write(data)
|
|
os.utime(os.path.join(d, n), (MTIME, MTIME))
|
|
subprocess.run(["nix", "shell", "nixpkgs#gcab", "-c", "gcab", "-c", "-z", "setup.cab", "readme.txt", "bin/tool.dll"],
|
|
cwd=d, check=True, capture_output=True, env=dict(os.environ, TZ="UTC"))
|
|
files["setup.cab"] = open(os.path.join(d, "setup.cab"), "rb").read()
|
|
dc.emit_inputs(ctx, files, {"cabBytes": "setup.cab"})
|