diff options
-rw-r--r-- | packaging-tools/archiveresolver.py | 3 | ||||
-rwxr-xr-x | packaging-tools/bld_module.py | 14 | ||||
-rw-r--r-- | packaging-tools/bldinstallercommon.py | 39 | ||||
-rw-r--r-- | packaging-tools/build_doc.py | 6 | ||||
-rw-r--r-- | packaging-tools/build_wrapper.py | 91 | ||||
-rw-r--r-- | packaging-tools/create_installer.py | 47 | ||||
-rw-r--r-- | packaging-tools/patch_qmake_qt_key.py | 4 | ||||
-rw-r--r-- | packaging-tools/release_build_handler.py | 70 | ||||
-rw-r--r-- | packaging-tools/sdkcomponent.py | 4 | ||||
-rw-r--r-- | packaging-tools/swap_repository.py | 6 | ||||
-rw-r--r-- | packaging-tools/update_repository.py | 23 |
11 files changed, 118 insertions, 189 deletions
diff --git a/packaging-tools/archiveresolver.py b/packaging-tools/archiveresolver.py index f70d58825..3c7d61239 100644 --- a/packaging-tools/archiveresolver.py +++ b/packaging-tools/archiveresolver.py @@ -122,8 +122,7 @@ class ArchiveLocationResolver: for server in self.server_list: if server.server_name == server_name: return server.server_url - print '*** Error! Unable to find server by name: ' + server_name - sys.exit(-1) + raise RuntimeError('*** Error! Unable to find server by name: %s' % server_name) ############################### diff --git a/packaging-tools/bld_module.py b/packaging-tools/bld_module.py index 4d18ffa0a..1f38a3467 100755 --- a/packaging-tools/bld_module.py +++ b/packaging-tools/bld_module.py @@ -236,7 +236,7 @@ if not os.path.lexists(callerArguments.qt5path) and not callerArguments.qt5_modu parser.print_help() print(("error: Please add the missing qt5_module_url arguments if the {0} does not exist" + os.linesep + os.linesep).format(callerArguments.qt5path)) - sys.exit(1) + raise RuntimeError() qmakeBinary = os.path.abspath(os.path.join(callerArguments.qt5path, 'bin', 'qmake')) @@ -315,13 +315,13 @@ runCommand(generateCommand, currentWorkingDirectory = qtModuleBuildDirectory, ret = runBuildCommand(currentWorkingDirectory = qtModuleBuildDirectory, callerArguments = callerArguments) if ret: - sys.exit('Failure running the last command: %i' % ret) + raise RuntimeError('Failure running the last command: %i' % ret) ret = runInstallCommand(['install', 'INSTALL_ROOT=' + qtModuleInstallDirectory], currentWorkingDirectory = qtModuleBuildDirectory, callerArguments = callerArguments, init_environment = environment) if ret: - sys.exit('Failure running the last command: %i' % ret) + raise RuntimeError('Failure running the last command: %i' % ret) # patch .so filenames on Windows/Android if bldinstallercommon.is_win_platform() and os.environ.get('DO_PATCH_ANDROID_SONAME_FILES'): @@ -342,13 +342,13 @@ if callerArguments.makeDocs: currentWorkingDirectory = qtModuleBuildDirectory, callerArguments = callerArguments, init_environment = environment) if ret: - sys.exit('Failure running the last command: %i' % ret) + raise RuntimeError('Failure running the last command: %i' % ret) # then make install those ret = runInstallCommand(['install_docs', 'INSTALL_ROOT=' + qtModuleInstallDirectory], currentWorkingDirectory = qtModuleBuildDirectory, callerArguments = callerArguments, init_environment = environment) if ret: - sys.exit('Failure running the last command: %i' % ret) + raise RuntimeError('Failure running the last command: %i' % ret) # make separate "doc.7z" for later use if needed doc_dir = bldinstallercommon.locate_directory(qtModuleInstallDirectory, 'doc') if doc_dir: @@ -356,7 +356,7 @@ if callerArguments.makeDocs: ret = runCommand(['7z', 'a', os.path.join('doc_archives', archive_name), doc_dir], currentWorkingDirectory = os.path.dirname(os.path.realpath(__file__))) if ret: - sys.exit('Failure running the last command: %i' % ret) + raise RuntimeError('Failure running the last command: %i' % ret) # try to figure out where the actual exported content is qt5_install_basename = os.path.basename(callerArguments.qt5path) @@ -381,4 +381,4 @@ else: archive_cmd.append(dir_to_archive) ret = runCommand(archive_cmd, currentWorkingDirectory = os.path.dirname(os.path.realpath(__file__))) if ret: - sys.exit('Failure running the last command: %i' % ret) + raise RuntimeError('Failure running the last command: %i' % ret) diff --git a/packaging-tools/bldinstallercommon.py b/packaging-tools/bldinstallercommon.py index 20a4beb87..8d2173c25 100644 --- a/packaging-tools/bldinstallercommon.py +++ b/packaging-tools/bldinstallercommon.py @@ -169,8 +169,7 @@ def set_platform_specific_data(): IS_UNIX_PLATFORM = True IS_MAC_PLATFORM = True else: - print '*** Unsupported platform, abort!' - sys.exit(-1) + raise EnvironmentError('*** Unsupported platform, abort!') ############################### @@ -244,8 +243,7 @@ def make_files_list(directory, rgxp): """Populate and return 'fileslist[]' with all files inside 'directory' matching 'regx'""" # if 'directory' is not a directory, exit with error if not os.path.isdir(directory): - print '*** Error, Given path is not valid: ' + directory - sys.exit(-1) + raise IOError('*** Error, Given path is not valid: %s' % directory) regex = re.compile(rgxp) filelist = [] for root, dirs, files in os.walk(directory): @@ -292,19 +290,15 @@ def move_tree(srcdir, dstdir, pattern=None): for name in srcnames: srcfname = os.path.join(srcdir, name) if not srcfname: - print '*** Fatal error! Unable to create source file path, too long path name!' - sys.exit(-1) + raise IOError('*** Fatal error! Unable to create source file path, too long path name!') dstfname = os.path.join(dstdir, name) if not dstfname: - print '*** Fatal error! Unable to create destination file path, too long path name!' - sys.exit(-1) + raise IOError('*** Fatal error! Unable to create destination file path, too long path name!') if is_win_platform(): if len(srcfname) > 255: - print 'given srcfname length (' + len(srcfname) + ') too long for Windows: ' + srcfname - sys.exit(-1) + raise IOError('given srcfname length [%s] too long for Windows: %s' % (len(srcfname), srcfname)) if len(dstfname) > 255: - print 'given dstfname length (' + len(dstfname) + ') too long for Windows: ' + dstfname - sys.exit(-1) + raise IOError('given dstfname length [%s] too long for Windows: %s' % (len(dstfname), dstfname)) if os.path.isdir(srcfname) and not os.path.islink(srcfname): os.mkdir(dstfname) move_tree(srcfname, dstfname) @@ -324,12 +318,10 @@ def copy_tree(source_dir, dest_dir): for file_name in src_files: full_file_name = os.path.join(source_dir, file_name) if not full_file_name: - print '*** Fatal error! Unable to create source file path, too long path name!' - sys.exit(-1) + raise IOError('*** Fatal error! Unable to create source file path, too long path name!') if is_win_platform(): if len(full_file_name) > 255: - print 'given full_file_name length (' + len(full_file_name) + ') too long for Windows: ' + full_file_name - sys.exit(-1) + raise IOError('given full_file_name length [%s] too long for Windows: %s' % (len(full_file_name), full_file_name)) if os.path.isdir(full_file_name): create_dirs(dest_dir + os.sep + file_name) copy_tree(full_file_name, dest_dir + os.sep + file_name) @@ -498,8 +490,7 @@ def create_dirs(path_to_be_created): try: os.makedirs(path_to_be_created) except: - print '*** Failed to create dir: ' + path_to_be_created - sys.exit(-1) + raise IOError('*** Failed to create dir: %s' % path_to_be_created) ############################### @@ -564,8 +555,7 @@ def is_executable(path): stdout=subprocess.PIPE).stdout.read()) is not None) else: - print '*** Error, is_executable not implemented yet!' - sys.exit(-1) + raise RuntimeError('*** Error, is_executable not implemented yet!') return False @@ -630,7 +620,7 @@ def sanity_check_rpath_max_length(file_path, new_rpath): print '*** Warning - Not able to process RPath for file: ' + file_path print '*** Required length for new RPath [' + new_rpath + '] is: ' + str(len(new_rpath)) print '*** Space available for new RPath inside the binary is: ' + str(space_for_new_rpath) - sys.exit(-1) + raise IOError() return True @@ -669,8 +659,7 @@ def calculate_relpath(p1, p2): ############################################################## def calculate_rpath(file_full_path, destination_lib_path): if not os.path.isfile(file_full_path): - print '*** Not a valid file: ' + file_full_path - sys.exit(-1) + raise IOError('*** Not a valid file: %s' % file_full_path) bin_path = os.path.dirname(file_full_path) path_to_lib = os.path.abspath(destination_lib_path) @@ -759,7 +748,7 @@ def do_execute_sub_process(args, execution_path, abort_on_fail=True, get_output= sys.stderr.write(' Execution path: [' + execution_path + ']' + os.linesep) traceback.print_exc() if abort_on_fail: - sys.exit(-1) + raise else: pass @@ -809,7 +798,7 @@ def extract_file(path, to_directory='.'): ret = runCommand(cmd_args, currentWorkingDirectory=to_directory, onlyErrorCaseOutput=True) if ret: - sys.exit('Failure running the last command: %i' % ret) + raise RuntimeError('Failure running the last command: %i' % ret) return True diff --git a/packaging-tools/build_doc.py b/packaging-tools/build_doc.py index 4739f9849..d6217c52f 100644 --- a/packaging-tools/build_doc.py +++ b/packaging-tools/build_doc.py @@ -50,8 +50,7 @@ bldinstallercommon.init_common_module(os.path.dirname(os.path.realpath(__file__) def handle_module_doc_build(): if not bldinstallercommon.is_linux_platform(): - print('*** Only Linux platform supported currently to perform doc builds. Aborting') - sys.exit(-1) + raise RuntimeError('*** Only Linux platform supported currently to perform doc builds. Aborting') if not os.environ.get('MODULE_NAME'): print('*** MODULE_NAME environment variable not defined. Unable to generate doc for this package.') return @@ -126,8 +125,7 @@ def handle_module_doc_build(): # patch Qt package qt_bin_directory = bldinstallercommon.locate_directory(qt_package_path, 'bin') if not os.path.exists(qt_bin_directory): - print('*** Unable to locate bin directory from: {0}'.format(qt_bin_directory)) - sys.exit(-1) + raise IOError('*** Unable to locate bin directory from: %s' % qt_bin_directory) qtConfFile = open(os.path.join(qt_bin_directory, 'qt.conf'), "w") qtConfFile.write("[Paths]" + os.linesep) qtConfFile.write("Prefix=.." + os.linesep) diff --git a/packaging-tools/build_wrapper.py b/packaging-tools/build_wrapper.py index f6b0aa106..ea31a627a 100644 --- a/packaging-tools/build_wrapper.py +++ b/packaging-tools/build_wrapper.py @@ -150,8 +150,7 @@ class BldCommand: if not self.license: self.license = os.environ.get('LICENSE') if not any(self.license in s for s in ['opensource', 'enterprise']): - print('*** License unknown: {0}'.format(self.license)) - sys.exit(-1) + raise RuntimeError('*** License unknown: %s' % self.license) # cfg self.target_env = options.target_env if not self.target_env: @@ -324,7 +323,7 @@ class BldCommand: print('Validating build args for Qt5 Extra Module src init') print(self.options) if not os.environ.get('LICENSE'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('LICENSE')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: LICENSE') return True ####################################################### @@ -334,7 +333,7 @@ class BldCommand: print('Validating build args for Qt5 Extra Module binary init') print(self.options) if not os.environ.get('LICENSE'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('LICENSE')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: LICENSE') return True ####################################################### @@ -344,23 +343,23 @@ class BldCommand: print('Validating build args for Qt5 Extra Module Src build') print(self.options) if not os.environ.get('LICENSE'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('LICENSE')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: LICENSE') if not os.environ.get('MODULE_NAME'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('MODULE_NAME')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: MODULE_NAME') if not os.environ.get('MODULE_VERSION'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('MODULE_VERSION')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: MODULE_VERSION') if not os.environ.get('GIT_MODULE_REPO'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('GIT_MODULE_REPO')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: GIT_MODULE_REPO') if not os.environ.get('GIT_MODULE_REPO_BRANCH'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('GIT_MODULE_REPO_BRANCH')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: GIT_MODULE_REPO_BRANCH') if not os.environ.get('BUILD_NUMBER'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('BUILD_NUMBER')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: BUILD_NUMBER') if not os.environ.get('PACKAGE_STORAGE_SERVER'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('PACKAGE_STORAGE_SERVER')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: PACKAGE_STORAGE_SERVER') if not os.environ.get('PACKAGE_STORAGE_SERVER_USER'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('PACKAGE_STORAGE_SERVER_USER')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: PACKAGE_STORAGE_SERVER_USER') if not os.environ.get('PACKAGE_STORAGE_SERVER_BASE_DIR'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('PACKAGE_STORAGE_SERVER_BASE_DIR')) + raise EnvironmentError('*** Error - Qt5 Extra Module build missing environment variable: PACKAGE_STORAGE_SERVER_BASE_DIR') return True ####################################################### @@ -371,22 +370,22 @@ class BldCommand: print(self.options) # check env variables if not os.environ.get('LICENSE'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('LICENSE')) + raise RuntimeError('*** Error - Qt5 Extra Module build missing environment variable: LICENSE') if not os.environ.get('PACKAGE_STORAGE_SERVER_PATH_HTTP'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('PACKAGE_STORAGE_SERVER_PATH_HTTP')) + raise RuntimeError('*** Error - Qt5 Extra Module build missing environment variable: PACKAGE_STORAGE_SERVER_PATH_HTTP') if not os.environ.get('QT_VERSION_MINOR'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('QT_VERSION_MINOR')) + raise RuntimeError('*** Error - Qt5 Extra Module build missing environment variable: QT_VERSION_MINOR') if not os.environ.get('MODULE_NAME'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('MODULE_NAME')) + raise RuntimeError('*** Error - Qt5 Extra Module build missing environment variable: MODULE_NAME') if not os.environ.get('MODULE_VERSION'): - sys.exit('*** Error - Qt5 Extra Module build missing environment variable: {0}'.format('MODULE_VERSION')) + raise RuntimeError('*** Error - Qt5 Extra Module build missing environment variable: MODULE_VERSION') # check command line arguments if not self.options.server: - sys.exit('*** Qt5 Extra Module build missing command line argument: --server') + raise RuntimeError('*** Qt5 Extra Module build missing command line argument: --server') if not self.options.target_env: - sys.exit('*** Qt5 Extra Module build missing command line argument: --target_env') + raise RuntimeError('*** Qt5 Extra Module build missing command line argument: --target_env') if not self.options.path: - sys.exit('*** Qt5 Extra Module build missing command line argument: --path') + raise RuntimeError('*** Qt5 Extra Module build missing command line argument: --path') return True ########################################### @@ -455,8 +454,7 @@ class MultipleOption(Option): ############################### def sanity_check_packaging_server(bld_command): if not bld_command.pkg_server_addr: - print('*** Error - Packaging server address not defined?') - sys.exit(-1) + raise RuntimeError('*** Error - Packaging server address not defined?') ############################### # sign windows executable @@ -817,8 +815,7 @@ def handle_qt_src_package_build(bld_command): print('Running {0} custom commands'.format(bld_command.custom_build)) module.handle_custom_commands(bld_command.custom_build, WORK_DIR) else: - print('*** No custom functions found') - sys.exit(-1) + raise RuntimeError('*** No custom functions found') if bld_command.license == 'enterprise': cmd_args = ['../patches/apply.sh'] bldinstallercommon.do_execute_sub_process(cmd_args, exec_path) @@ -933,8 +930,7 @@ def get_qt_configuration_options(bld_command): qt_configure_options_file = os.environ['RELEASE_BUILD_QT_CONFIGURE_OPTIONS_FILE'] # parse qt configuration arguments from release description file if not os.path.isfile(qt_configure_options_file): - print('*** Not a valid release description file: {0}'.format(qt_configure_options_file)) - sys.exit(-1) + raise IOError('*** Not a valid release description file: %s' % qt_configure_options_file) tmp_conf = os.path.dirname(qt_configure_options_file) parser = ConfigParser.ConfigParser() parser.readfp(open(qt_configure_options_file)) @@ -1073,8 +1069,7 @@ def generate_bin_target_dictionary(): # parse module exclude list from release description file conf_file_base_path = os.path.join(SCRIPT_ROOT_DIR, BUILD_META_INFO_FILE) if not os.path.isfile(conf_file_base_path): - print('*** Not a valid release description file: {0}'.format(conf_file_base_path)) - sys.exit(-1) + raise IOError('*** Not a valid release description file: %s' % conf_file_base_path) parser = ConfigParser.ConfigParser() parser.readfp(open(conf_file_base_path)) # parse @@ -1087,11 +1082,9 @@ def generate_bin_target_dictionary(): build_node_labels = bldinstallercommon.safe_config_key_fetch(parser, s, 'build_node_labels').replace(' ', '') label_list = build_node_labels.split(',') if not build_target_dir: - print('*** No build target directory defined for: {0}'.format(s)) - sys.exit(-1) + raise RuntimeError('*** No build target directory defined for: %s' % s) if not label_list: - print('*** No build slave label defined for: {0}'.format(s)) - sys.exit(-1) + raise RuntimeError('*** No build slave label defined for: %s' % s) for label in label_list: BIN_TARGET_DIRS[label] = build_target_dir if ci_target_postfix: @@ -1106,8 +1099,7 @@ def handle_qt_release_build(bld_command): # Qt configure options qt_configure_options_file = get_qt_configuration_options(bld_command) if not os.path.isfile(qt_configure_options_file): - print('*** No valid Qt configuration file found: {0}'.format(qt_configure_options_file)) - sys.exit(-1) + raise IOError('*** No valid Qt configuration file found: %s' % qt_configure_options_file) # additional Qt configure options qt_configure_extra_options = os.getenv('EXTRA_QT_CONFIGURE_OPTIONS', '') if bld_command.license.lower() == 'enterprise': @@ -1436,7 +1428,7 @@ def handle_qt_creator_build(bld_command): for dependency_name in plugin.dependencies: matches = [dep for dep in additional_plugins if dep.name == dependency_name] if not matches: - raise LookupError('did not find dependency "{0}" for plugin "{1}"'.format(dependency_name, plugin.name)) + raise RuntimeError('did not find dependency "{0}" for plugin "{1}"'.format(dependency_name, plugin.name)) dependency = matches[0] cmd_arguments.extend(['--plugin-search-path', os.path.join(WORK_DIR, dependency.path, 'plugins')]) libs_base = os.path.join(WORK_DIR, dependency.name + '-target') @@ -1755,8 +1747,7 @@ def delete_remote_directory_tree(bld_command, remote_dir): def trigger_rta(rta_description_files_dir): # check if rta cases define for this build job if not os.path.isdir(rta_description_files_dir): - print('*** Error - Given rta_description_files_dir does not exist: {0}'.format(rta_description_files_dir)) - sys.exit(-1) + raise IOError('*** Error - Given rta_description_files_dir does not exist: %s' % rta_description_files_dir) dir_list = os.listdir(rta_description_files_dir) matching = [s for s in dir_list if pkg_constants.RTA_DESCRIPTION_FILE_NAME_BASE in s] if not matching: @@ -1777,8 +1768,7 @@ def trigger_rta(rta_description_files_dir): for line in iter(f): line_split = line.split(' ') if len(line_split) != 2: - print('*** Error - Invalid format in rta description file {0}, line: {1}'.format(rta_file, line)) - sys.exit(-1) + raise RuntimeError('*** Error - Invalid format in rta description file %s, line: %s' % (rta_file, line)) rta_keys = line_split[1].split(',') for item in rta_keys: item = item.rstrip().replace(' ', '') @@ -1795,8 +1785,7 @@ def trigger_rta(rta_description_files_dir): def handle_online_repository_build(bld_command): conf_file = bld_command.release_description_file if not os.path.exists(conf_file): - print('*** The given file does not exist: {0}'.format(conf_file)) - sys.exit(-1) + raise IOError('*** The given file does not exist: %s' % conf_file) if bld_command.target_env.find('64') != -1: arch = 'x64' else: @@ -1895,11 +1884,11 @@ def initialize_icu_build(bld_command): # sanity check icu args in bld_command sanity_check_packaging_server(bld_command) if not bld_command.icu_version: - sys.exit('*** ICU build is missing: icu_version') + raise RuntimeError('*** ICU build is missing: icu_version') if not bld_command.path: - sys.exit('*** ICU build is missing: path') + raise RuntimeError('*** ICU build is missing: path') if not bld_command.build_number: - sys.exit('*** ICU build is missing: build_number') + raise RuntimeError('*** ICU build is missing: build_number') remote_snaphot_dir_base = bld_command.path + '/' + 'icu' + '/' + bld_command.icu_version remote_snaphot_dir = remote_snaphot_dir_base + '/' + bld_command.build_number remote_latest_dir = remote_snaphot_dir_base + '/' + 'latest' @@ -1916,11 +1905,11 @@ def handle_icu_build(bld_command): # sanity check icu args in bld_command sanity_check_packaging_server(bld_command) if not bld_command.icu_version: - sys.exit('*** ICU build is missing: icu_version') + raise RuntimeError('*** ICU build is missing: icu_version') if not bld_command.path: - sys.exit('*** ICU build is missing: path') + raise RuntimeError('*** ICU build is missing: path') if not bld_command.icu_src_pkg_url: - sys.exit('*** ICU build is missing: icu_src_pkg_url') + raise RuntimeError('*** ICU build is missing: icu_src_pkg_url') bld_icu_tools.init_build_icu(bld_command.icu_src_pkg_url, bld_command.icu_version, True) # define remote dir where to upload remote_snaphot_dir = bld_command.path + '/' + 'icu' + '/' + bld_command.icu_version + '/' + 'latest' @@ -1941,7 +1930,7 @@ def publish_icu_packages(bld_command): # sanity check icu args in bld_command sanity_check_packaging_server(bld_command) if not bld_command.icu_version: - sys.exit('*** ICU build is missing: icu_version') + raise RuntimeError('*** ICU build is missing: icu_version') # Opensource server address and path ext_server_base_url = os.environ['EXT_SERVER_BASE_URL'] ext_server_base_path = os.environ['EXT_SERVER_BASE_PATH'] @@ -1972,14 +1961,14 @@ def parse_cmd_line(): arg_count = len(sys.argv) if arg_count < 2: OPTION_PARSER.print_help() - sys.exit(-1) + raise RuntimeError() (options, dummy) = OPTION_PARSER.parse_args() bld_cmd_validator = BldCommand(options) if not bld_cmd_validator.validate_bld_args(): OPTION_PARSER.print_help() - sys.exit(-1) + raise RuntimeError() if bldinstallercommon.is_linux_platform(): PLATFORM = 'linux' diff --git a/packaging-tools/create_installer.py b/packaging-tools/create_installer.py index 7acf4a35a..e272f5af0 100644 --- a/packaging-tools/create_installer.py +++ b/packaging-tools/create_installer.py @@ -157,9 +157,8 @@ def main(): """ Start """ if parse_cmd_line(): create_installer() - sys.exit(0) else: - sys.exit(-1) + raise ValueError("Insufficient command line arguments given") ############################################################## @@ -177,9 +176,7 @@ def check_required_tools(): break if not found: - sys.stderr.write('*** Error! Required tools are not present in the system (7z)') - sys.stderr.write('*** Abort!') - sys.exit(-1) + raise EnvironmentError("7z tool not found in the PATH") ############################################################## @@ -192,7 +189,7 @@ def check_platform_identifier(platform_identifier): return sys.stderr.write('*** Unsupported platform identifier given: ' + platform_identifier) sys.stderr.write('*** Following directory can not be found: ' + path_to_be_checked) - sys.exit(-1) + raise ValueError() ############################################################## @@ -427,11 +424,11 @@ def parse_cmd_line(): if CREATE_ONLINE_INSTALLER and CREATE_OFFLINE_INSTALLER: sys.stderr.write('*** Error! This script does not support (yet) creating offline and online installers at the same time!') sys.stderr.write('*** Choose either offline or online!') - sys.exit(-1) + raise ValueError() if CREATE_ONLINE_INSTALLER and CREATE_REPOSITORY: sys.stderr.write('*** Error! This script does not support (yet) creating online installer and repository at the same time!') sys.stderr.write('*** Choose either online installer or repository creation!') - sys.exit(-1) + raise ValueError() # check that given main configuration root dir exists if not os.path.isdir(CONFIGURATIONS_DIR): @@ -582,7 +579,7 @@ def set_config_xml(): sys.stderr.write('*** Error!') sys.stderr.write('*** Given config.xml template does not exist: ' + config_template_source) sys.stderr.write('*** Abort!') - sys.exit(-1) + raise ValueError() # name has to be config.xml for installer-framework config_template_dest_dir = CONFIG_DIR_DST @@ -696,8 +693,7 @@ def parse_component_data(configuration_file, configurations_base_path): allos_conf_file_dir = os.path.normpath(CONFIGURATIONS_DIR + os.sep + COMMON_CONFIG_DIR_NAME) file_full_path = bldinstallercommon.locate_file(allos_conf_file_dir, configuration_file) if not file_full_path: - print '*** Aborting, unable to locate the specified file. Check the configuration files for possible error(s).' - sys.exit(-1) + raise ValueError('*** Aborting, unable to locate the specified file. Check the configuration files for possible error(s).') print ' -> Reading target configuration file: ' + file_full_path configuration = ConfigParser.ConfigParser() configuration.readfp(open(file_full_path)) @@ -725,7 +721,7 @@ def parse_component_data(configuration_file, configurations_base_path): else: if STRICT_MODE: print sdk_component.error_msg() - sys.exit(-1) + raise ValueError() else: print '!!! Ignored component in non-strict mode (missing archive data or metadata?): ' + section SDK_COMPONENT_LIST_SKIPPED.append(sdk_component) @@ -789,11 +785,11 @@ def move_directory_one_layer_up(directory): new_location = os.path.abspath(os.path.join(temp_path_name, '..')) bldinstallercommon.move_tree(temp_path_name, new_location) if not bldinstallercommon.remove_tree(temp_path_name): - sys.exit('Unable to remove directory: %s' % temp_path_name) + raise IOError('Unable to remove directory: ' + temp_path_name) else: sys.stderr.write('*** Error: unsupported folder structure encountered, abort!') sys.stderr.write('*** Found items: ' + str(items) + ' in directory: ' + directory) - sys.exit(-1) + raise IOError() @@ -948,7 +944,7 @@ def create_target_components(target_config): if hasattr(sdk_component, 'temp_data_dir') and os.path.exists(sdk_component.temp_data_dir): # lastly remove temp dir after all data is prepared if not bldinstallercommon.remove_tree(sdk_component.temp_data_dir): - sys.exit('Unable to remove directory: %s' % sdk_component.temp_data_dir) + raise IOError('Unable to remove directory: %s' % sdk_component.temp_data_dir) # substitute downloadable archive names in installscript.qs substitute_component_tags(sdk_component.generate_downloadable_archive_list(), sdk_component.meta_dir_dest) @@ -1070,11 +1066,11 @@ def install_ifw_tools(): if not(res): sys.stderr.write('*** Package URL is invalid: [' + package_url + ']') sys.stderr.write('*** Abort!') - sys.exit(-1) + raise ValueError() bldinstallercommon.retrieve_url(package_url, package_save_as_temp) if not (os.path.isfile(package_save_as_temp)): sys.stderr.write('*** Downloading failed! Aborting!') - sys.exit(-1) + raise RuntimeError() # extract IFW archive bldinstallercommon.extract_file(package_save_as_temp, IFW_TOOLS_DIR) os.remove(package_save_as_temp) @@ -1089,7 +1085,7 @@ def install_ifw_tools(): else: sys.stderr.write('*** Unsupported dir structure for installer-framework-tools package?!') sys.stderr.write('*** Abort!') - sys.exit(-1) + raise RuntimeError() executable_suffix = bldinstallercommon.get_executable_suffix() ARCHIVEGEN_TOOL = bldinstallercommon.locate_executable(tools_bin_path, 'archivegen' + executable_suffix) @@ -1098,17 +1094,13 @@ def install_ifw_tools(): REPOGEN_TOOL = bldinstallercommon.locate_executable(tools_bin_path, 'repogen' + executable_suffix) # check if not (os.path.isfile(ARCHIVEGEN_TOOL)): - sys.stderr.write('*** Archivegen tool not found: ' + ARCHIVEGEN_TOOL) - sys.exit(-1) + raise IOError('*** Archivegen tool not found: ' + ARCHIVEGEN_TOOL) if not (os.path.isfile(BINARYCREATOR_TOOL)): - sys.stderr.write('*** Binarycreator tool not found: ' + BINARYCREATOR_TOOL) - sys.exit(-1) + raise IOError('*** Binarycreator tool not found: ' + BINARYCREATOR_TOOL) if not (os.path.isfile(INSTALLERBASE_TOOL)): - sys.stderr.write('*** Installerbase tool not found: ' + INSTALLERBASE_TOOL) - sys.exit(-1) + raise IOError('*** Installerbase tool not found: ' + INSTALLERBASE_TOOL) if not (os.path.isfile(REPOGEN_TOOL)): - sys.stderr.write('*** Repogen tool not found: ' + REPOGEN_TOOL) - sys.exit(-1) + raise IOError('*** Repogen tool not found: ' + REPOGEN_TOOL) print ' ARCHIVEGEN_TOOL: ' + ARCHIVEGEN_TOOL print ' BINARYCREATOR_TOOL: ' + BINARYCREATOR_TOOL @@ -1234,8 +1226,7 @@ def create_offline_repository(): # create repository bldinstallercommon.do_execute_sub_process(repogen_args, SCRIPT_ROOT_DIR) if not os.path.exists(REPO_OUTPUT_DIR): - sys.stderr.write('*** Fatal error! Unable to create repository directory: ' + REPO_OUTPUT_DIR) - sys.exit(-1) + raise IOError('*** Fatal error! Unable to create repository directory: ' + REPO_OUTPUT_DIR) ############################################################## diff --git a/packaging-tools/patch_qmake_qt_key.py b/packaging-tools/patch_qmake_qt_key.py index 21d2f16f9..c87bae289 100644 --- a/packaging-tools/patch_qmake_qt_key.py +++ b/packaging-tools/patch_qmake_qt_key.py @@ -128,9 +128,7 @@ def fetch_key(qmake_file_name, key): ############################################################## if __name__ == "__main__": if len(sys.argv) != 4: - print '*** Three parameters needed!' - print '*** Abort!' - sys.exit(-1) + raise RuntimeError('*** Three parameters needed!') print fetch_key(sys.argv[1], sys.argv[2]) replace_key(sys.argv[1], sys.argv[2], sys.argv[3]) sys.exit(0) diff --git a/packaging-tools/release_build_handler.py b/packaging-tools/release_build_handler.py index 150946822..72dd02fd4 100644 --- a/packaging-tools/release_build_handler.py +++ b/packaging-tools/release_build_handler.py @@ -147,33 +147,24 @@ class BuildJob: # validate content def validate(self): if not self.node_name: - print('*** Fatal error! <node_name> not defined for build job?') - sys.exit(-1) + raise RuntimeError('*** Fatal error! <node_name> not defined for build job?') if not self.license: - print('*** Fatal error! <license> not defined for {0}'.format(self.node_name)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <license> not defined for: %s' % self.node_name) if not self.configurations_dir: - print('*** Fatal error! <configurations_dir> not defined for {0}'.format(self.node_name)) - sys.exit(-1) + raise IOError('*** Fatal error! <configurations_dir> not defined for: %s' % self.node_name) if not self.configurations_file: - print('*** Fatal error! <configurations_file> not defined for {0}'.format(self.node_name)) - sys.exit(-1) + raise IOError('*** Fatal error! <configurations_file> not defined for: %s' % self.node_name) if not self.ifw_tools: - print('*** Fatal error! <ifw_tools> not defined for {0}'.format(self.node_name)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <ifw_tools> not defined for: %s' % self.node_name) if self.is_repo_job: if not self.repo_content_type: - print('*** Fatal error! <repo_content_type> not defined for {0}'.format(self.node_name)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <repo_content_type> not defined for: %s' % self.node_name) if not self.repo_content_type: - print('*** Fatal error! <repo_content_type> not defined for {0}'.format(self.node_name)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <repo_content_type> not defined for: %s' % self.node_name) if not self.repo_components_to_update: - print('*** Fatal error! <repo_components_to_update> not defined for {0}'.format(self.node_name)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <repo_components_to_update> not defined for: %s' % self.node_name) if not self.repo_url_specifier: - print('*** Fatal error! <repo_url_specifier> not defined for {0}'.format(self.node_name)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <repo_url_specifier> not defined for: %s' % self.node_name) # all ok return True @@ -206,8 +197,7 @@ def is_valid_job_type(job_type_specifier): def get_job_list(conf_file, job_type_specifier, license_type, branch, platform, arch, conf_file_base_dir, ifw_base_url, global_version, global_version_tag): print('Get [{0}] build job list for: {1}'.format(job_type_specifier, platform + '-' + arch)) if not os.path.isfile(conf_file): - print('*** Fatal error! Given file does not exist: {0}'.format(conf_file)) - sys.exit(-1) + raise IOError('*** Fatal error! Given file does not exist: %s' % conf_file) # ensure the string ends with '/' if not ifw_base_url.endswith('/'): ifw_base_url += '/' @@ -215,13 +205,11 @@ def get_job_list(conf_file, job_type_specifier, license_type, branch, platform, parser.readfp(open(conf_file)) # validate job type if not is_valid_job_type(job_type_specifier): - print('*** Fatal error! Unsupported job type specifier given {0}'.format(job_type_specifier)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! Unsupported job type specifier given: %s' % job_type_specifier) # determine which ifw tools to use (which platform) ifw_tools = bldinstallercommon.safe_config_key_fetch(parser, 'ifwtools', platform + '-' + arch) if not ifw_tools: - print('*** Fatal error! Unable to find ifw tools for {0}'.format(platform + '-' + arch)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! Unable to find ifw tools for_ %s' % (platform + '-' + arch)) ifw_tools_url = urlparse.urljoin(ifw_base_url, ifw_tools) # check if repository build job is_repo_job = False @@ -254,8 +242,7 @@ def get_job_list(conf_file, job_type_specifier, license_type, branch, platform, version_number_tag = global_version_tag arg_configurations_file = bldinstallercommon.safe_config_key_fetch(parser, s, 'arg_configurations_file') if not arg_configurations_file: - print('*** Fatal error! Configuration file not defined for {0}'.format(s)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! Configuration file not defined for: %s' % s) # for triggering rta later on if specified rta_key_list = bldinstallercommon.safe_config_key_fetch(parser, s, 'rta_key_list') # preferred installer name @@ -271,16 +258,13 @@ def get_job_list(conf_file, job_type_specifier, license_type, branch, platform, if job_type_specifier == 'repository': repo_content_type = bldinstallercommon.safe_config_key_fetch(parser, s, 'repo_content_type') if not repo_content_type: - print('*** Fatal error! <repo_content_type> not defined for {0}'.format(s)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <repo_content_type> not defined for: %s' % s) repo_components_to_update = bldinstallercommon.safe_config_key_fetch(parser, s, 'repo_components_to_update') if not repo_components_to_update: - print('*** Fatal error! <repo_components_to_update> not defined for {0}'.format(s)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <repo_components_to_update> not defined for: %s' % s) repo_url_specifier = bldinstallercommon.safe_config_key_fetch(parser, s, 'repo_url_specifier') if not repo_url_specifier: - print('*** Fatal error! <repo_url_specifier> not defined for {0}'.format(s)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! <repo_url_specifier> not defined for: %s' % s) # determine full path for the conf file full_conf_file_path = os.path.join(conf_file_base_dir, arg_configurations_file) # create build job @@ -300,8 +284,7 @@ def get_repo_job_list(conf_file, license_type, branch, platform, arch, conf_file # - online installer build(s) def handle_installer_build(conf_file, installer_type, license_type, branch, platform, arch, packages_base_url): if not os.path.isfile(conf_file): - print('*** Fatal error! Given file does not exist: {0}'.format(conf_file)) - sys.exit(-1) + raise IOError('*** Fatal error! Given file does not exist: %s' % conf_file) init_env() conf_file_base_dir = CONFIGURATIONS_FILE_BASE_DIR ifw_base_url = IFW_TOOLS_BASE_URL @@ -312,13 +295,11 @@ def handle_installer_build(conf_file, installer_type, license_type, branch, plat global_version = bldinstallercommon.safe_config_key_fetch(parser, section_name, 'version') global_version_tag = bldinstallercommon.safe_config_key_fetch(parser, section_name, 'version_tag') if not global_version: - print('*** Fatal error! Invalid values in {0} -> {1}'.format(conf_file, section_name)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! Invalid values in %s -> %s' % (conf_file, section_name)) # parse build jobs job_list = get_job_list(conf_file, installer_type, license_type, branch, platform, arch, conf_file_base_dir, ifw_base_url, global_version, global_version_tag) if (len(job_list) == 0): - print('*** Fatal error! No [{0}] installer build jobs found from: {1}. Probably an error?'.format(installer_type, conf_file)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! No [%s] installer build jobs found from: %s. Probably an error?' % (installer_type, conf_file)) installer_output_dir = os.path.join(SCRIPT_ROOT_DIR, pkg_constants.INSTALLER_OUTPUT_DIR_NAME) rta_descr_output_dir = os.path.join(SCRIPT_ROOT_DIR, pkg_constants.RTA_DESCRIPTION_FILE_DIR_NAME) bldinstallercommon.create_dirs(rta_descr_output_dir) @@ -338,8 +319,7 @@ def handle_installer_build(conf_file, installer_type, license_type, branch, plat rta_description_file.close() # if "/installer_output" directory is empty -> error if not os.listdir(installer_output_dir): - print('*** Fatal error! No installers generated into: {0}'.format(installer_output_dir)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! No installers generated into: %s' % installer_output_dir) # helper function/wrapper to create online installer @@ -382,8 +362,7 @@ def create_installer(job, packages_base_url, installer_type): # - update existing repository at test server with new content def handle_repo_build(conf_file, license_type, branch, platform, arch, packages_base_url, update_staging_repo, update_production_repo): if not os.path.isfile(conf_file): - print('*** Fatal error! Given file does not exist: {0}'.format(conf_file)) - sys.exit(-1) + raise IOError('*** Fatal error! Given file does not exist: %s' % conf_file) init_env() release_tools_dir = SCRIPT_ROOT_DIR conf_file_base_dir = CONFIGURATIONS_FILE_BASE_DIR @@ -397,8 +376,7 @@ def handle_repo_build(conf_file, license_type, branch, platform, arch, packages_ # parse build jobs repo_job_list = get_repo_job_list(conf_file, license_type, branch, platform, arch, conf_file_base_dir, ifw_base_url, global_version, global_version_tag) if (len(repo_job_list) == 0): - print('*** Fatal error! No repository build jobs found. Probably an error?'.format(conf_file, section_name)) - sys.exit(-1) + raise RuntimeError('*** Fatal error! No repository build jobs found. Probably an error? %s' % conf_file) # init repo dirs init_repositories(repo_job_list) # is this snapshot build? Then enable component version number forced update @@ -609,9 +587,7 @@ def update_online_repo(job, update_staging_repo, update_production_repo): cmd_args_log_to_prod = cmd_args_log_to_staging + ['ssh', '-t', '-t', PROD_USER + '@' + PROD_ADDR ] # delete old stuff from pending area, but do sanity check first! if (os.path.normpath(PROD_SRV_REPO_PENDING_AREA_DIR) in (os.path.normpath(PROD_SRV_REPO_BASE_PATH + '/' + REPOSITORY_BASE_NAME))): - print('*** Fatal error!!! You are trying to delete production repository: '.format(prod_server_pending_area_dir)) - print('*** Aborting ...') - sys.exit(-1) + raise RuntimeError('*** Fatal error!!! You are trying to delete production repository: %s' % prod_server_pending_area_dir) cmd_args_rm_old = cmd_args_log_to_prod + ['rm', '-rf', prod_server_pending_area_dir] bldinstallercommon.do_execute_sub_process(cmd_args_rm_old, SCRIPT_ROOT_DIR) # create pending dirs into production server diff --git a/packaging-tools/sdkcomponent.py b/packaging-tools/sdkcomponent.py index 4664142b1..cda608ef3 100644 --- a/packaging-tools/sdkcomponent.py +++ b/packaging-tools/sdkcomponent.py @@ -213,9 +213,7 @@ class SdkComponent: for archive in archives_list: # check that archive template exists if not target_config.has_section(archive): - print '*** Error! Given archive section does not exist in configuration file: ' + archive - print '*** Abort!' - sys.exit(-1) + raise RuntimeError('*** Error! Given archive section does not exist in configuration file: %s' % archive) archive_obj = SdkComponent.DownloadableArchive(archive, self.package_name, self.archive_server_name, target_config, archive_location_resolver, self.key_value_substitution_list) diff --git a/packaging-tools/swap_repository.py b/packaging-tools/swap_repository.py index 1289afb6d..e190d2302 100644 --- a/packaging-tools/swap_repository.py +++ b/packaging-tools/swap_repository.py @@ -148,13 +148,11 @@ def generate_match_list(source_match_list, dest_match_list, component_name, dest ############################### def swap_repository(parser_args): if not parser_args: - print('*** No options available to swap online reposities') - sys.exit(1) + raise RuntimeError('*** No options available to swap online reposities') source_match_list = get_directory_list(parser_args.source, parser_args.component) if not source_match_list: - print('*** Nothing to update? Did not find any component named: {0}'.format(parser_args.component)) - sys.exit(1) + raise RuntimeError('*** Nothing to update? Did not find any component named: %s' % parser_args.component) dest_match_list = get_directory_list(parser_args.destination, parser_args.component) match_list = generate_match_list(source_match_list, dest_match_list, parser_args.component, parser_args.destination) diff --git a/packaging-tools/update_repository.py b/packaging-tools/update_repository.py index 071559d01..6726086d6 100644 --- a/packaging-tools/update_repository.py +++ b/packaging-tools/update_repository.py @@ -102,15 +102,11 @@ def fetch_repogen_tools(tools_uri): print('Trying to locate repogen tool: {0}'.format(REPOGEN_TOOL + executable_suffix)) tool = bldinstallercommon.locate_executable(REPOGEN_TOOLS_DIR, REPOGEN_TOOL + executable_suffix) if not os.path.isfile(tool): - print('Unable to locate repogen tool [{0}] under directory: {1}'.format(REPOGEN_TOOL + executable_suffix, REPOGEN_TOOLS_DIR)) - print('*** Abort!') - sys.exit(-1) + raise IOError('Unable to locate repogen tool [%s] under directory: %s' % (REPOGEN_TOOL + executable_suffix, REPOGEN_TOOLS_DIR)) else: REPOGEN_TOOL = tool else: - print('Invalid url: {0}'.format(tools_uri)) - print('*** Abort!') - sys.exit(-1) + raise IOError('Invalid url: %s' % tools_uri) # found the tool print('Using repogen tool: {0}'.format(REPOGEN_TOOL)) @@ -126,14 +122,11 @@ def update_repository(source_pkg, target_repo, components_to_update): print(' Components: {0}'.format(components_to_update)) print() if not len(components_to_update): - print('*** You asked me to update nothing?') - sys.exit(-1) + raise RuntimeError('*** You asked me to update nothing?') if not os.path.exists(source_pkg): - print('*** Source pkg does not exist: {0}'.format(source_pkg)) - sys.exit(-1) + raise IOError('*** Source pkg does not exist: %s' % source_pkg) if not os.path.exists(target_repo): - print('*** Target repository does not exist: {0}'.format(target_repo)) - sys.exit(-1) + raise IOError('*** Target repository does not exist: %s' % target_repo) # do we update new components only or all given components no matter # what the version numbers are repogen_update_cmd = '--update' @@ -177,7 +170,7 @@ def sanity_check(component_list, source_pkg): 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)) - sys.exit(-1) + raise RuntimeError() ############################### @@ -244,7 +237,7 @@ def ask_for_components(source_pkg): var = raw_input("Is the above selection correct? y/n ") if var not in ['y', 'Y']: print('*** Aborting...') - sys.exit(-1) + raise RuntimeError() # return the components to be updated return component_list @@ -309,7 +302,7 @@ if __name__ == "__main__": if not os.path.isdir(CALLER_ARGUMENTS.source_repo) or not os.path.isfile(os.path.join(CALLER_ARGUMENTS.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)) - sys.exit(-1) + raise RuntimeError() if os.path.isfile(os.path.join(CALLER_ARGUMENTS.target_repo, 'Updates.xml')): print('The given destination directory already contains a repository.') print('We just update the existing repository:') |