diff options
author | Samuli Piippo <samuli.piippo@qt.io> | 2019-02-04 09:23:12 +0200 |
---|---|---|
committer | Samuli Piippo <samuli.piippo@qt.io> | 2019-02-07 10:00:22 +0000 |
commit | bd688542dacfdac86d18cbaf60249e0a26b1b66e (patch) | |
tree | a3bcd44b937eb7ae3e4fd3be499ec329ec82cbcc /packaging-tools/create_installer.py | |
parent | b8590063510194d2b8a579fd592849f592b1f423 (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>
Diffstat (limited to 'packaging-tools/create_installer.py')
-rw-r--r-- | packaging-tools/create_installer.py | 26 |
1 files changed, 26 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 |