aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Kokko <antti.kokko@qt.io>2019-04-05 08:37:30 +0300
committerAntti Kokko <antti.kokko@qt.io>2019-04-08 10:40:13 +0000
commitff6d9a176c338f487e1361054e0135b055830fbe (patch)
treedb39dd2cf8d43d07901f525e7273621c5178ea36
parent364b1205f3fc4ea72cde345abb11b1805ccbefc7 (diff)
Fix online repository build upload
This fix aims to adapt to "scp: error: unexpected filename ." error seen in online repository builds. This was caused by change in OpenSSH server code due to a security vulnerability CVE-2018-20685. Change-Id: Ie05065d3c24b59ac17cc814d8324e66eef49eb29 Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
-rw-r--r--packaging-tools/batch_process_installer_bld.py16
-rw-r--r--packaging-tools/create_installer.py2
-rw-r--r--packaging-tools/update_repository.py23
3 files changed, 25 insertions, 16 deletions
diff --git a/packaging-tools/batch_process_installer_bld.py b/packaging-tools/batch_process_installer_bld.py
index 6cb9efa6c..0b3203d9e 100644
--- a/packaging-tools/batch_process_installer_bld.py
+++ b/packaging-tools/batch_process_installer_bld.py
@@ -366,7 +366,7 @@ def handle_repo_build(optionDict, branch, arch, update_staging_repo, update_prod
# determine testination path on test server
dest_path_repository, dest_path_pkg = generate_repo_dest_path_pending(optionDict, job)
# copy repo content to test server
- source_path_repository = os.path.join(release_tools_dir, 'repository')
+ source_path_repository = os.path.join(release_tools_dir, 'online_repository')
source_path_pkg = os.path.join(release_tools_dir, 'pkg')
push_online_repository(optionDict, optionDict['PKG_STAGING_SERVER'], optionDict['PKG_STAGING_SERVER_UNAME'], source_path_repository, dest_path_repository)
push_online_repository(optionDict, optionDict['PKG_STAGING_SERVER'], optionDict['PKG_STAGING_SERVER_UNAME'], source_path_pkg, dest_path_pkg)
@@ -415,8 +415,14 @@ def push_online_repository(optionDict, server_addr, username, directory_to_copy,
print('Preparing to copy: {0}'.format(directory_to_copy))
where_to_copy = ensure_unix_paths(where_to_copy)
destination = username + '@' + server_addr + ':' + where_to_copy + '/'
- cmd_args = [optionDict['SCP_COMMAND'], '-r', '.', destination]
- bldinstallercommon.do_execute_sub_process(cmd_args, directory_to_copy)
+
+ parts = directory_to_copy.strip(os.path.sep).split(os.path.sep)
+ parentDir = os.path.sep + os.path.sep.join(parts[:-1])
+ dirToCopy = parts[-1]
+ if bldinstallercommon.is_win_platform():
+ parentDir = os.path.sep.join(parts[:-1])
+ cmd_args = [optionDict['SCP_COMMAND'], '-r', dirToCopy, destination]
+ bldinstallercommon.do_execute_sub_process(cmd_args, parentDir)
# init online repository directory structure at remote server
@@ -462,8 +468,8 @@ def generate_repo_path_for_pending_area(optionDict, build_job):
# generate temporary 'pkg' and 'online_repository' pending area paths for repo update work
def generate_repo_dest_path_pending(optionDict, repo_job):
base_path_pending = generate_repo_path_for_pending_area(optionDict, repo_job)
- dest_path_repository = ensure_unix_paths(os.path.join(base_path_pending, 'online_repository'))
- dest_path_pkg = ensure_unix_paths(os.path.join(base_path_pending, 'pkg'))
+ dest_path_repository = ensure_unix_paths(os.path.join(base_path_pending))
+ dest_path_pkg = ensure_unix_paths(os.path.join(base_path_pending))
return dest_path_repository, dest_path_pkg
diff --git a/packaging-tools/create_installer.py b/packaging-tools/create_installer.py
index bdde4d460..197ad4fe6 100644
--- a/packaging-tools/create_installer.py
+++ b/packaging-tools/create_installer.py
@@ -64,7 +64,7 @@ CONFIGURATIONS_DIR = 'configurations'
CONFIG_DIR_DST = 'config'
COMMON_CONFIG_NAME = 'common'
COMMON_CONFIG_DIR_NAME = 'all-os'
-REPO_OUTPUT_DIR = os.path.normpath(SCRIPT_ROOT_DIR + os.sep + 'repository')
+REPO_OUTPUT_DIR = os.path.normpath(SCRIPT_ROOT_DIR + os.sep + 'online_repository')
PACKAGES_DIR_NAME_LIST = []
PACKAGES_FULL_PATH_DST = 'pkg'
ROOT_COMPONENT_NAME = ''
diff --git a/packaging-tools/update_repository.py b/packaging-tools/update_repository.py
index 6726086d6..ad781431b 100644
--- a/packaging-tools/update_repository.py
+++ b/packaging-tools/update_repository.py
@@ -137,7 +137,7 @@ def update_repository(source_pkg, target_repo, components_to_update):
cmd_args += [target_repo]
else:
cmd_args += ['--include', ','.join(components_to_update), target_repo]
- bldinstallercommon.do_execute_sub_process(cmd_args, source_pkg)
+ bldinstallercommon.do_execute_sub_process(cmd_args, source_pkg, True)
###############################
@@ -156,8 +156,9 @@ def is_number(s):
###############################
def sanity_check(component_list, source_pkg):
source_packages = []
- for name in os.listdir(source_pkg):
- temp = os.path.join(source_pkg, name)
+ source_pkg_path = os.path.join(source_pkg, 'online_repository')
+ for name in os.listdir(source_pkg_path):
+ temp = os.path.join(source_pkg_path, name)
if os.path.isdir(temp):
source_packages.append(name)
for item in component_list:
@@ -169,7 +170,7 @@ def sanity_check(component_list, source_pkg):
item = left.rstrip('.')
if item not in source_packages:
print('*** Sanity check fail!')
- print('*** Can not update component: [{0}] as it does not exist under: {1}'.format(orig_item, source_pkg))
+ print('*** Can not update component: [{0}] as it does not exist under: {1}'.format(orig_item, source_pkg_path))
raise RuntimeError()
@@ -271,8 +272,9 @@ def parse_components_from_argument(caller_arguments):
return_list = []
# parse all possible components in source repo
full_component_listing = []
- for name in os.listdir(caller_arguments.source_pkg):
- temp = os.path.join(caller_arguments.source_pkg, name)
+ source_pkg_path = os.path.join(caller_arguments.source_pkg, 'pkg')
+ for name in os.listdir(source_pkg_path):
+ temp = os.path.join(source_pkg_path, name)
if os.path.isdir(temp):
full_component_listing.append(name)
# figure out all components that should be updated
@@ -299,9 +301,10 @@ if __name__ == "__main__":
# 1) target repository directory must be empty i.e. we initialize things for the first time
# 2) copy the source repository as target repository 1:1 and nothing else
if CALLER_ARGUMENTS.source_repo:
- if not os.path.isdir(CALLER_ARGUMENTS.source_repo) or not os.path.isfile(os.path.join(CALLER_ARGUMENTS.source_repo, 'Updates.xml')):
+ source_repo = os.path.join(CALLER_ARGUMENTS.source_repo, 'online_repository')
+ if not os.path.isdir(source_repo) or not os.path.isfile(os.path.join(source_repo, 'Updates.xml')):
print('*** The given source directory does not seem to be proper repository? Abort!')
- print('Given source repository: {0}'.format(CALLER_ARGUMENTS.source_repo))
+ print('Given source repository: {0}'.format(source_repo))
raise RuntimeError()
if os.path.isfile(os.path.join(CALLER_ARGUMENTS.target_repo, 'Updates.xml')):
print('The given destination directory already contains a repository.')
@@ -312,10 +315,10 @@ if __name__ == "__main__":
# create dirs
bldinstallercommon.create_dirs(CALLER_ARGUMENTS.target_repo)
# copy repository
- bldinstallercommon.copy_tree(CALLER_ARGUMENTS.source_repo, CALLER_ARGUMENTS.target_repo)
+ bldinstallercommon.copy_tree(source_repo, CALLER_ARGUMENTS.target_repo)
# everything done now!
print('Repository initialized:')
- print('Source: {0}'.format(CALLER_ARGUMENTS.source_repo))
+ print('Source: {0}'.format(source_repo))
print('Destination: {0}'.format(CALLER_ARGUMENTS.target_repo))
sys.exit()
# fetch tools