From 60f5b443b931655e5d3138ab1a0b2d13fcec497c Mon Sep 17 00:00:00 2001 From: Andrew Gunnerson Date: Mon, 22 May 2023 22:46:52 -0400 Subject: [PATCH] modules/build.py: Allow building individual modules Signed-off-by: Andrew Gunnerson --- modules/build.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/modules/build.py b/modules/build.py index 036f1ea..c9a591a 100755 --- a/modules/build.py +++ b/modules/build.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import argparse import io import os import re @@ -117,13 +118,24 @@ def build_module(dist_dir, common_dir, module_dir, extra_files): return zip_path +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('module', nargs='*', + default=('clearotacerts', 'oemunlockonboot'), + help='Module to build') + + return parser.parse_args() + + def main(): + args = parse_args() + dist_dir = os.path.join(sys.path[0], 'dist') os.makedirs(dist_dir, exist_ok=True) common_dir = os.path.join(sys.path[0], 'common') - for module in ('clearotacerts', 'oemunlockonboot'): + for module in args.module: module_dir = os.path.join(sys.path[0], module) if module == 'clearotacerts': @@ -141,6 +153,8 @@ def main(): 'file': os.path.join(module_dir, 'service.sh'), }, } + else: + raise ValueError(f'Invalid module: {module}') module_zip = build_module(dist_dir, common_dir, module_dir, extra_files) print('Built module', module_zip)