31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""Deterministic, dependency-free package for the owned Mac NetBird policy."""
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def build(target):
|
|
files = {
|
|
"profile_policy.py": (ROOT / "src/k1link/fleet/netbird/profile_policy.py").read_bytes(),
|
|
"__main__.py": b"from profile_policy import main\nmain()\n",
|
|
}
|
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
with zipfile.ZipFile(target, "w") as archive:
|
|
for name, data in sorted(files.items()):
|
|
info = zipfile.ZipInfo(name, (2026, 1, 1, 0, 0, 0))
|
|
info.external_attr = 0o644 << 16
|
|
info.compress_type = zipfile.ZIP_DEFLATED
|
|
archive.writestr(info, data)
|
|
return dict(path=str(target), sha256=hashlib.sha256(target.read_bytes()).hexdigest())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
p = argparse.ArgumentParser()
|
|
p.add_argument("--output", type=Path, required=True)
|
|
print(json.dumps(build(p.parse_args().output)))
|