From e4c2fdefbbf7df88d678dfa11e5034d3d5993d9e Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Mon, 13 May 2019 12:58:08 +0300 Subject: Create IFW build from tagged version Change-Id: I2a23deaf12367e83e28eafad218cf6b96b9c4254 Reviewed-by: Iikka Eklund --- packaging-tools/bld_ifw_tools.py | 22 ++++++++++++++++------ packaging-tools/bldinstallercommon.py | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/packaging-tools/bld_ifw_tools.py b/packaging-tools/bld_ifw_tools.py index 47de3cb93..81d9d62c7 100644 --- a/packaging-tools/bld_ifw_tools.py +++ b/packaging-tools/bld_ifw_tools.py @@ -338,9 +338,9 @@ def build_ifw(options, create_installer=False, build_ifw_examples=False): create_installer_package(options) #archive archive_installerbase(options) - archive_installer_framework(options.installer_framework_build_dir, options.installer_framework_archive_name, options.build_artifacts_dir) + archive_installer_framework(options.installer_framework_build_dir, options.installer_framework_archive_name, options, True) if (options.squish_dir): - archive_installer_framework(options.installer_framework_build_dir_squish, options.installer_framework_with_squish_archive_name, options.build_artifacts_dir) + archive_installer_framework(options.installer_framework_build_dir_squish, options.installer_framework_with_squish_archive_name, options, False) return os.path.basename(options.installer_framework_build_dir) @@ -463,7 +463,8 @@ def prepare_installer_framework(options): bldinstallercommon.create_dirs(options.installer_framework_build_dir_squish) if options.qt_installer_framework_uri.endswith('.git'): # clone repos - bldinstallercommon.clone_repository(options.qt_installer_framework_uri, options.qt_installer_framework_branch, options.installer_framework_source_dir) + bldinstallercommon.clone_repository(options.qt_installer_framework_uri, options.qt_installer_framework_branch, options.installer_framework_source_dir, True) + else: # fetch src package prepare_compressed_package(options.qt_installer_framework_uri, options.qt_installer_framework_uri_saveas, options.installer_framework_source_dir) @@ -673,7 +674,7 @@ def clean_build_environment(options): ############################### # function ############################### -def archive_installer_framework(installer_framework_build_dir, installer_framework_archive_name, build_artifacts_dir): +def archive_installer_framework(installer_framework_build_dir, installer_framework_archive_name, options, create_tagged_package): print('--------------------------------------------------------------------') print('Archive Installer Framework') # first strip out all unnecessary files @@ -683,8 +684,17 @@ def archive_installer_framework(installer_framework_build_dir, installer_framewo os.remove(os.path.join(root, filename)) cmd_args = [ARCHIVE_PROGRAM, 'a', installer_framework_archive_name, os.path.basename(installer_framework_build_dir)] bldinstallercommon.do_execute_sub_process(cmd_args, ROOT_DIR) - shutil.move(installer_framework_archive_name, build_artifacts_dir) - + shutil.move(installer_framework_archive_name, options.build_artifacts_dir) + # Check if installer framework is created from branch. If so, check if the branch is tagged and + # create a package with a tagged name. + # Package with the tagged name is needed for creating e.g. offline installers from stable builds + if options.qt_installer_framework_uri.endswith('.git') and create_tagged_package: + tag = bldinstallercommon.get_tag_from_branch(options.installer_framework_source_dir, options.qt_installer_framework_branch) + if tag: + print('Create archive from tag {0}'.format(tag)) + installer_framework_tagged_archive = 'installer-framework-build-' + tag + "-" + options.plat_suffix + '-' + options.architecture + '.7z' + print('Create archive {0}'.format(installer_framework_tagged_archive)) + shutil.copy(os.path.join(options.build_artifacts_dir, installer_framework_archive_name), os.path.join(options.build_artifacts_dir, installer_framework_tagged_archive)) ############################### # function diff --git a/packaging-tools/bldinstallercommon.py b/packaging-tools/bldinstallercommon.py index ddad07a89..1342bfdea 100644 --- a/packaging-tools/bldinstallercommon.py +++ b/packaging-tools/bldinstallercommon.py @@ -815,6 +815,33 @@ def clone_repository(repo_url, repo_branch_or_tag, destination_folder, full_clon cmd_args = ['git', 'submodule', 'update', '--init'] do_execute_sub_process(cmd_args, destination_folder) +##################################################################### +# This function returns a tag if the given branch is tagged. Branch +# parameter can be also a tag, in that case we return empty string. +##################################################################### +def get_tag_from_branch(directory, branch): + tag = "" + # Check if we already have checked out a tag + cmd_args = ['git', 'symbolic-ref', 'HEAD'] + return_code, tag = do_execute_sub_process(cmd_args, directory, False, True) + if return_code != -1: + print("Already checked out a tag. THIS IS TOTALLY OK, PLEASE IGNORE THE ABOVE ERROR.") + tag = "" + else: + # Check what sha1 we have checked out + cmd_args = ['git', 'rev-parse', '--short', 'HEAD'] + return_code, sha1 = do_execute_sub_process(cmd_args, directory, False, True) + if return_code == -1: + # Check if the sha1 matches to any tag + sha1 = sha1.strip('\n') + cmd_args = ['git', 'describe', '--exact-match', sha1] + return_code, tag = do_execute_sub_process(cmd_args, directory, False, True) + tag = tag.strip('\n') + if return_code != -1: + print('No tag found for branch. THIS IS TOTALLY OK, PLEASE IGNORE THE ABOVE ERROR.') + tag = "" + return tag + ############################### # git archive given repository -- cgit v1.2.3