aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuli Piippo <samuli.piippo@qt.io>2019-02-04 09:23:12 +0200
committerSamuli Piippo <samuli.piippo@qt.io>2019-02-07 10:00:22 +0000
commitbd688542dacfdac86d18cbaf60249e0a26b1b66e (patch)
treea3bcd44b937eb7ae3e4fd3be499ec329ec82cbcc
parentb8590063510194d2b8a579fd592849f592b1f423 (diff)
Add support for component sha1 substitution
New component configs 'component_sha1_uri' and 'component_sha1_file' can define a URI to a downloadable file and file path inside a downloadable archive, respectively. The file is used to read a sha1 for the component, which can then be used with substitution '%COMPONENT_SHA1%'. Task-number: AUTOSUITE-760 Change-Id: If0d2a30c6e07f61df89609194ce96077e81fa9a8 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
-rw-r--r--packaging-tools/create_installer.py26
-rw-r--r--packaging-tools/sdkcomponent.py5
2 files changed, 31 insertions, 0 deletions
diff --git a/packaging-tools/create_installer.py b/packaging-tools/create_installer.py
index 778ce8efc..4ebde9210 100644
--- a/packaging-tools/create_installer.py
+++ b/packaging-tools/create_installer.py
@@ -103,6 +103,7 @@ PACKAGE_CREATION_DATE_TAG = '%PACKAGE_CREATION_DATE%'
INSTALL_PRIORITY_TAG = '%INSTALL_PRIORITY%'
SORTING_PRIORITY_TAG = '%SORTING_PRIORITY%'
VERSION_NUMBER_AUTO_INCREASE_TAG = '%VERSION_NUMBER_AUTO_INCREASE%'
+COMPONENT_SHA1_TAG = '%COMPONENT_SHA1%'
VERSION_NUMBER_AUTO_INCREASE_VALUE = ''
REMOVE_PDB_FILES = 'False'
REMOVE_WINDOWS_DEBUG_LIBRARIES = 'False'
@@ -706,9 +707,20 @@ def create_metadata_map(sdk_component):
# target install dir substitution
if sdk_component.target_install_base:
component_metadata_tag_pair_list.append([TARGET_INSTALL_DIR_NAME_TAG, sdk_component.target_install_base])
+ # component sha1 substitution
+ if sdk_component.component_sha1:
+ component_metadata_tag_pair_list.append([COMPONENT_SHA1_TAG, sdk_component.component_sha1])
return component_metadata_tag_pair_list
+def get_component_sha1_file(sdk_component, sha1_file_dest):
+ """download component sha1 file"""
+ bld_utils.download(sdk_component.component_sha1_uri, sha1_file_dest)
+
+ # read sha1 from the file
+ with open(sha1_file_dest, "r") as sha1_file:
+ sdk_component.component_sha1 = sha1_file.read().strip()
+
def get_component_data(sdk_component, archive, install_dir, data_dir_dest, compress_content_dir):
"""download and create data for a component"""
package_raw_name = os.path.basename(archive.archive_uri)
@@ -793,6 +805,15 @@ def get_component_data(sdk_component, archive, install_dir, data_dir_dest, compr
if bldinstallercommon.is_linux_platform() or bldinstallercommon.is_solaris_platform():
bldinstallercommon.handle_component_rpath(install_dir, archive.rpath_target)
+ if archive.component_sha1_file:
+ # read sha1 from the file
+ sha1_file_path = install_dir + os.sep + archive.component_sha1_file
+ if os.path.exists(sha1_file_path):
+ with open(sha1_file_path, "r") as sha1_file:
+ sdk_component.component_sha1 = sha1_file.read().strip()
+ else:
+ raise ValueError('Component SHA1 file "{0}" not found'.format(archive.component_sha1_file))
+
# lastly compress the component back to .7z archive
content_list = os.listdir(compress_content_dir)
#adding compress_content_dir in front of every item
@@ -969,6 +990,11 @@ def create_target_components(target_config):
data_dir_dest = win32api.GetShortPathName(data_dir_dest)
getComponentDataWork.addTask("adding {0} to {1}".format(archive.archive_name, sdk_component.package_name),
get_component_data, sdk_component, archive, install_dir, data_dir_dest, compress_content_dir)
+ # handle component sha1 uri
+ if sdk_component.component_sha1_uri:
+ sha1_file_dest = os.path.normpath(dest_base + 'SHA1')
+ getComponentDataWork.addTask("getting component sha1 file for {0}".format(sdk_component.package_name),
+ get_component_sha1_file, sdk_component, sha1_file_dest)
if not ARCHIVE_DOWNLOAD_SKIP:
# start the work threaded, more than 8 parallel downloads are not so useful
diff --git a/packaging-tools/sdkcomponent.py b/packaging-tools/sdkcomponent.py
index 2d1fb61d9..9e6ca61e7 100644
--- a/packaging-tools/sdkcomponent.py
+++ b/packaging-tools/sdkcomponent.py
@@ -46,6 +46,7 @@ class SdkComponent:
self.package_finalize_items = bldinstallercommon.safe_config_key_fetch(target_config, archive, 'package_finalize_items')
self.target_install_dir = bldinstallercommon.safe_config_key_fetch(target_config, archive, 'target_install_dir') # todo, is needed?
self.rpath_target = bldinstallercommon.safe_config_key_fetch(target_config, archive, 'rpath_target')
+ self.component_sha1_file = bldinstallercommon.safe_config_key_fetch(target_config, archive, 'component_sha1_file')
self.nomalize_archive_uri(package_name, archive_server_name, archive_location_resolver)
self.archive_name = bldinstallercommon.safe_config_key_fetch(target_config, archive, 'archive_name')
if not self.archive_name:
@@ -94,6 +95,10 @@ class SdkComponent:
self.package_default = bldinstallercommon.safe_config_key_fetch(target_config, section_name, 'package_default')
self.install_priority = bldinstallercommon.safe_config_key_fetch(target_config, section_name, 'install_priority')
self.sorting_priority = bldinstallercommon.safe_config_key_fetch(target_config, section_name, 'sorting_priority')
+ self.component_sha1 = ""
+ self.component_sha1_uri = bldinstallercommon.safe_config_key_fetch(target_config, section_name, 'component_sha1_uri')
+ if (self.component_sha1_uri):
+ self.component_sha1_uri = archive_location_resolver.resolve_full_uri(self.package_name, self.archive_server_name, self.component_sha1_uri)
self.optional_for_offline = False
self.key_value_substitution_list = key_value_substitution_list
self.archive_skip = False