Option for additional metadata in package.py

Issue-ID: OOM-2269
Signed-off-by: Ondřej Šmalec <o.smalec@partner.samsung.com>
Change-Id: I6b23512746171fdeaac3883fb61695db2c48c3ab
diff --git a/build/package.py b/build/package.py
index 47f78b8..9e9a660 100755
--- a/build/package.py
+++ b/build/package.py
@@ -69,12 +69,13 @@
     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 @@
         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 @@
                                skip_sw,
                                skip_resources,
                                skip_aux,
-                               overwrite):
+                               overwrite,
+                               metadata):
     """
     Prepares offline deliverables
     :param build_version: Version for packages tagging
@@ -135,6 +140,7 @@
     :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 @@
 
     # 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 @@
                         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 @@
                                args.skip_sw,
                                args.skip_resources,
                                args.skip_aux,
-                               args.overwrite)
+                               args.overwrite,
+                               args.add_metadata)
 
 
 if __name__ == '__main__':