49 lines
1.2 KiB
Python
Executable File
49 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Sign release metadata and verify it against the launcher's public key."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
if __package__:
|
|
from .repository_paths import SOURCE_ROOT, ensure_project_imports
|
|
else:
|
|
from repository_paths import SOURCE_ROOT, ensure_project_imports
|
|
|
|
ensure_project_imports()
|
|
from scripts.release_lib import ( # noqa: E402
|
|
ReleaseToolError,
|
|
sign_file,
|
|
verify_signature,
|
|
)
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("source", type=Path)
|
|
parser.add_argument("signature", type=Path)
|
|
parser.add_argument("private_key", type=Path)
|
|
parser.add_argument(
|
|
"--public-key",
|
|
type=Path,
|
|
default=SOURCE_ROOT / "ptlinux/launcher-update-public.pem",
|
|
)
|
|
arguments = parser.parse_args()
|
|
try:
|
|
sign_file(arguments.source, arguments.signature, arguments.private_key)
|
|
verify_signature(
|
|
arguments.source,
|
|
arguments.signature,
|
|
arguments.public_key,
|
|
)
|
|
except (OSError, ReleaseToolError) as exc:
|
|
print(f"Metadata signing failed: {exc}", file=sys.stderr)
|
|
return 1
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|