39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify a detached release-metadata signature with the launcher 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 ReleaseToolError, verify_signature # noqa: E402
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("source", type=Path)
|
|
parser.add_argument("signature", type=Path)
|
|
parser.add_argument(
|
|
"--public-key",
|
|
type=Path,
|
|
default=SOURCE_ROOT / "ptlinux/launcher-update-public.pem",
|
|
)
|
|
arguments = parser.parse_args()
|
|
try:
|
|
verify_signature(arguments.source, arguments.signature, arguments.public_key)
|
|
except (OSError, ReleaseToolError) as exc:
|
|
print(f"Metadata verification failed: {exc}", file=sys.stderr)
|
|
return 1
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|