From 6e5944123a88f62c5adda619cf258700146e85d1 Mon Sep 17 00:00:00 2001 From: Ondřej Šmalec Date: Wed, 22 Jan 2020 07:38:29 +0100 Subject: Option for additional metadata in package.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue-ID: OOM-2269 Signed-off-by: Ondřej Šmalec Change-Id: I6b23512746171fdeaac3883fb61695db2c48c3ab --- build/package.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'build/package.py') diff --git a/build/package.py b/build/package.py index 47f78b87..9e9a6606 100755 --- a/build/package.py +++ b/build/package.py @@ -69,12 +69,13 @@ def prepare_application_repository(directory, url, refspec, patch_path): return repository -def create_package_info_file(output_file, repository_list, tag): +def create_package_info_file(output_file, repository_list, tag, metadata): """ Generates text file in json format containing basic information about the build :param output_file: :param repository_list: list of repositories to be included in package info :param tag: build version of packages + :param metadata: additional metadata into package.info :return: """ log.info('Generating package.info file') @@ -88,6 +89,9 @@ def create_package_info_file(output_file, repository_list, tag): build_info['Build_info'][ repository.config_reader().get_value('remote "origin"', 'url')] = repository.head.commit.hexsha + if len(metadata) != 0: + build_info['Build_info'][metadata[0]] = metadata[1] + with open(output_file, 'w') as outfile: json.dump(build_info, outfile, indent=4) @@ -118,7 +122,8 @@ def build_offline_deliverables(build_version, skip_sw, skip_resources, skip_aux, - overwrite): + overwrite, + metadata): """ Prepares offline deliverables :param build_version: Version for packages tagging @@ -135,6 +140,7 @@ def build_offline_deliverables(build_version, :param skip_resources: skip resources package generation :param skip_aux: skip aux package generation :param overwrite: overwrite files in output directory + :param metadata: add metadata info into package.info :return: """ @@ -155,7 +161,7 @@ def build_offline_deliverables(build_version, # Package info info_file = os.path.join(output_dir, 'package.info') - create_package_info_file(info_file, [application_repository, offline_repository], build_version) + create_package_info_file(info_file, [application_repository, offline_repository], build_version, metadata) # packages layout as dictionaries. : sw_content = { @@ -262,6 +268,8 @@ def run_cli(): help='overwrite files in output directory') parser.add_argument('--debug', action='store_true', default=False, help='Turn on debug output') + parser.add_argument('--add-metadata', nargs=2, + help='additional metadata added into package.info, format: key value', default=[]) args = parser.parse_args() if args.debug: @@ -282,7 +290,8 @@ def run_cli(): args.skip_sw, args.skip_resources, args.skip_aux, - args.overwrite) + args.overwrite, + args.add_metadata) if __name__ == '__main__': -- cgit 1.2.3-korg