42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
SOURCE_ROOT = Path(__file__).resolve().parents[1]
|
|
if str(SOURCE_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(SOURCE_ROOT))
|
|
|
|
from scripts.fat16_image import Fat16Image
|
|
from scripts.image_config import PRODUCT_ID, read_config_file
|
|
|
|
|
|
def reject_in_place_refresh(image_path: Path) -> None:
|
|
image_path = Path(image_path).resolve()
|
|
with Fat16Image(image_path) as image:
|
|
config, _, _ = read_config_file(image.read_file("MSCCFG.BIN"))
|
|
metadata = json.loads(image.read_file("MSCMETA.JSN").decode("utf-8"))
|
|
if config.get("product") != PRODUCT_ID or metadata.get("product") != PRODUCT_ID:
|
|
raise ValueError("image product does not match this project")
|
|
raise ValueError(
|
|
"in-place image payload refresh is retired; rebuild from the official baseline with "
|
|
"export_release.py image --repair-current"
|
|
)
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(
|
|
description="Reject unsafe in-place image refreshes and direct callers to the transactional exporter"
|
|
)
|
|
parser.add_argument("--image", type=Path, required=True)
|
|
args = parser.parse_args()
|
|
reject_in_place_refresh(args.image)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|