diff options
author | Tomáš Levora <t.levora@partner.samsung.com> | 2020-01-23 07:57:48 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-01-23 07:57:48 +0000 |
commit | d1d632f7a2beed8cefcd65f9e85670caca09ebf1 (patch) | |
tree | 305bc15e13092d57b8758c3132402d9f260964c7 | |
parent | 59ee11be51545ac5902c8c6789c1a3a44425ef73 (diff) | |
parent | 6e5944123a88f62c5adda619cf258700146e85d1 (diff) |
Merge "Option for additional metadata in package.py"
-rwxr-xr-x | build/package.py | 17 |
1 files changed, 13 insertions, 4 deletions
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. <file> : <file location under tar archive> 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__': |