Files

36 lines
1000 B
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Validate an explicitly selected source-built core ROM bundle.
Use the same bounded directory, manifest and byte checks as source-profile
staging. Validation establishes byte identity, not a redistribution license.
"""
import argparse
from pathlib import Path
import runpy
_STAGE = runpy.run_path(str(Path(__file__).with_name('stage.py')))
def validate_bundle(path):
source = _STAGE['absolute'](path)
_STAGE['directory'](source, 'Source ROM bundle')
return _STAGE['read_bundle'](source)
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('action', choices=['validate'])
parser.add_argument('bundle', type=Path)
args = parser.parse_args()
try:
validate_bundle(args.bundle)
except (OSError, ValueError, UnicodeError) as error:
parser.error(str(error))
print('PASS: source ROM bundle validated')
if __name__ == '__main__':
main()