def fetch_repogen_tools(tools_uri): global REPOGEN_TOOL executable_suffix = bldinstallercommon.get_executable_suffix() # first check if we have existing copy of the tool if os.path.exists(REPOGEN_TOOLS_DIR): tool = bldinstallercommon.locate_executable(REPOGEN_TOOLS_DIR, REPOGEN_TOOL + executable_suffix) if os.path.isfile(tool): REPOGEN_TOOL = tool print('Found existing repogen tool: {0}'.format(REPOGEN_TOOL)) return else: # remove the bogus directory bldinstallercommon.remove_tree(REPOGEN_TOOLS_DIR) # create dirs bldinstallercommon.create_dirs(REPOGEN_TOOLS_DIR) # fetch print('Fetch repogen tools') if bldinstallercommon.is_content_url_valid(tools_uri): package_save_as_temp = os.path.normpath(os.path.join(ROOT_DIR, os.path.basename(tools_uri))) bldinstallercommon.retrieve_url(tools_uri, package_save_as_temp) bldinstallercommon.extract_file(package_save_as_temp, REPOGEN_TOOLS_DIR) 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): raise IOError('Unable to locate repogen tool [%s] under directory: %s' % (REPOGEN_TOOL + executable_suffix, REPOGEN_TOOLS_DIR)) else: REPOGEN_TOOL = tool else: raise IOError('Invalid url: %s' % tools_uri) # found the tool print('Using repogen tool: {0}'.format(REPOGEN_TOOL))
def archive_installerbase(options): print( '--------------------------------------------------------------------') print('Archive Installerbase') cmd_args_archive = [] cmd_args_clean = [] bin_temp = '' if bldinstallercommon.is_linux_platform( ) or bldinstallercommon.is_mac_platform(): bin_path = bldinstallercommon.locate_executable( options.installer_framework_build_dir, 'installerbase') bin_temp = ROOT_DIR + os.sep + '.tempSDKMaintenanceTool' shutil.copy(bin_path, bin_temp) cmd_args_archive = [ '7z', 'a', options.installer_base_archive_name, bin_temp ] cmd_args_clean = ['rm', bin_temp] if bldinstallercommon.is_win_platform(): bin_path = bldinstallercommon.locate_executable( options.installer_framework_build_dir, 'installerbase.exe') bin_temp = ROOT_DIR + os.sep + 'tempSDKMaintenanceToolBase.exe' shutil.copy(bin_path, bin_temp) cmd_args_archive = [ '7z', 'a', options.installer_base_archive_name, bin_temp ] cmd_args_clean = ['del', bin_temp] bldinstallercommon.do_execute_sub_process(cmd_args_archive, ROOT_DIR) bldinstallercommon.do_execute_sub_process(cmd_args_clean, ROOT_DIR) if not os.path.isfile(options.installer_base_archive_name): print('*** Failed to generate archive: {0}'.format( options.installer_base_archive_name)) sys.exit(-1) shutil.move(options.installer_base_archive_name, options.build_artifacts_dir)
def archive_installerbase(options): print('--------------------------------------------------------------------') print('Archive Installerbase') cmd_args_archive = [] cmd_args_clean = [] bin_temp = '' if bldinstallercommon.is_linux_platform() or bldinstallercommon.is_mac_platform(): bin_path = bldinstallercommon.locate_executable(options.installer_framework_build_dir, 'installerbase') bin_temp = ROOT_DIR + os.sep + '.tempSDKMaintenanceTool' shutil.copy(bin_path, bin_temp) cmd_args_archive = ['7z', 'a', options.installer_base_archive_name, bin_temp] cmd_args_clean = ['rm', bin_temp] if bldinstallercommon.is_win_platform(): bin_path = bldinstallercommon.locate_executable(options.installer_framework_build_dir, 'installerbase.exe') bin_temp = ROOT_DIR + os.sep + 'tempSDKMaintenanceToolBase.exe' shutil.copy(bin_path, bin_temp) if options.signserver and options.signpwd: sign_windows_installerbase('tempSDKMaintenanceToolBase.exe', ROOT_DIR + os.sep, True, options) cmd_args_archive = ['7z', 'a', options.installer_base_archive_name, bin_temp] cmd_args_clean = ['del', bin_temp] bldinstallercommon.do_execute_sub_process(cmd_args_archive, ROOT_DIR) bldinstallercommon.do_execute_sub_process(cmd_args_clean, ROOT_DIR) if not os.path.isfile(options.installer_base_archive_name): print('*** Failed to generate archive: {0}'.format(options.installer_base_archive_name)) sys.exit(-1) shutil.move(options.installer_base_archive_name, options.build_artifacts_dir)
def fetch_repogen_tools(tools_uri): global REPOGEN_TOOL executable_suffix = bldinstallercommon.get_executable_suffix() # first check if we have existing copy of the tool if os.path.exists(REPOGEN_TOOLS_DIR): tool = bldinstallercommon.locate_executable( REPOGEN_TOOLS_DIR, REPOGEN_TOOL + executable_suffix) if os.path.isfile(tool): REPOGEN_TOOL = tool print('Found existing repogen tool: {0}'.format(REPOGEN_TOOL)) return else: # remove the bogus directory bldinstallercommon.remove_tree(REPOGEN_TOOLS_DIR) # create dirs bldinstallercommon.create_dirs(REPOGEN_TOOLS_DIR) # fetch print('Fetch repogen tools') if bldinstallercommon.is_content_url_valid(tools_uri): package_save_as_temp = os.path.normpath( os.path.join(ROOT_DIR, os.path.basename(tools_uri))) bldinstallercommon.retrieve_url(tools_uri, package_save_as_temp) bldinstallercommon.extract_file(package_save_as_temp, REPOGEN_TOOLS_DIR) 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): raise IOError( 'Unable to locate repogen tool [%s] under directory: %s' % (REPOGEN_TOOL + executable_suffix, REPOGEN_TOOLS_DIR)) else: REPOGEN_TOOL = tool else: raise IOError('Invalid url: %s' % tools_uri) # found the tool print('Using repogen tool: {0}'.format(REPOGEN_TOOL))
def save_original_qt_prfxpath(): print_wrap('---------------- Saving original qt_prfxpath -----------------------') global ORIGINAL_QMAKE_QT_PRFXPATH qmake_executable_path = bldinstallercommon.locate_executable(QT_SOURCE_DIR, 'qmake' + bldinstallercommon.get_executable_suffix()) if not qmake_executable_path: print_wrap('*** Error! qmake executable not found? Looks like the build has failed in previous step? Aborting..') sys.exit(-1) ORIGINAL_QMAKE_QT_PRFXPATH = patch_qmake_qt_key.fetch_key(os.path.normpath(qmake_executable_path), 'qt_prfxpath') print_wrap(' ===> Original qt_prfxpath: ' + ORIGINAL_QMAKE_QT_PRFXPATH) if not ORIGINAL_QMAKE_QT_PRFXPATH: print_wrap('*** Could not find original qt_prfxpath from qmake executable?!') print_wrap('*** Abort!') sys.exit(-1) print_wrap('--------------------------------------------------------------------')
def save_install_prefix(): print_wrap('---------------- Saving install prefix -----------------------------') global INSTALL_PREFIX qmake_executable_path = bldinstallercommon.locate_executable(QT_SOURCE_DIR, 'qmake' + bldinstallercommon.get_executable_suffix()) if not qmake_executable_path: print_wrap('*** Error! qmake executable not found? Looks like the build has failed in previous step?') exit_script() query_args = qmake_executable_path + ' -query' dummy, output = bldinstallercommon.do_execute_sub_process(query_args.split(' '), '.', get_output=True) data = output.split('\n') for line in data: if 'QT_INSTALL_PREFIX' in line: splitted = line.split(':') #windows has different syntax in qmake -query if bldinstallercommon.is_win_platform(): INSTALL_PREFIX = splitted[2] else: INSTALL_PREFIX = splitted[1] INSTALL_PREFIX = INSTALL_PREFIX.strip() print_wrap('INSTALL_PREFIX = ' + INSTALL_PREFIX) break print_wrap('--------------------------------------------------------------------')
def handle_module_doc_build(optionDict): if not bldinstallercommon.is_linux_platform(): raise RuntimeError('*** Only Linux platform supported currently to perform doc builds. Aborting') if not 'MODULE_NAME' in optionDict: print('*** MODULE_NAME environment variable not defined. Unable to generate doc for this package.') return if not 'MODULE_SRC_PACKAGE_URI' in optionDict: print('*** MODULE_SRC_PACKAGE_URI environment variable not defined. Unable to generate doc for this package.') return if not 'MODULE_DOC_BUILD_QT_PACKAGE_URI' in optionDict: print('*** MODULE_DOC_BUILD_QT_PACKAGE_URI environment variable not defined. Unable to generate doc for this package.') return module_src_package_uri = optionDict['MODULE_SRC_PACKAGE_URI'] module_doc_build_qt_package_uri = optionDict['MODULE_DOC_BUILD_QT_PACKAGE_URI'] module_doc_build_qt_dependency_package_uri = optionDict.get('MODULE_DOC_BUILD_QT_DEPENDENCY_PACKAGE_URI', '') module_doc_build_qt_icu_package_uri = optionDict.get('MODULE_DOC_BUILD_QT_ICU_PACKAGE_URI', '') # define some paths current_path = os.path.dirname(os.path.realpath(__file__)) qt_package_path = os.path.join(current_path, 'doc_build_qt_package') qt_icu_path = os.path.join(current_path, 'doc_build_qt_icu_package') module_src_path = os.path.join(current_path, 'module_src_package') shutil.rmtree(qt_package_path, ignore_errors=True) shutil.rmtree(qt_icu_path, ignore_errors=True) shutil.rmtree(module_src_path, ignore_errors=True) bldinstallercommon.create_dirs(qt_package_path) bldinstallercommon.create_dirs(module_src_path) bldinstallercommon.create_dirs(qt_icu_path) # fetch module src package raw_name_module_src_package = module_src_package_uri.rsplit('/', 1)[-1] # get last item from array downloaded_module_archive = os.path.join(current_path, raw_name_module_src_package) os.remove(downloaded_module_archive) if os.path.isfile(downloaded_module_archive) else None print('Starting to download: {0}'.format(module_src_package_uri)) bldinstallercommon.retrieve_url(module_src_package_uri, downloaded_module_archive) bldinstallercommon.extract_file(downloaded_module_archive, module_src_path) # fetch qt binary package raw_name_qt_bin_package = module_doc_build_qt_package_uri.rsplit('/', 1)[-1] # get last item from array downloaded_qt_bin_archive = os.path.join(current_path, raw_name_qt_bin_package) os.remove(downloaded_qt_bin_archive) if os.path.isfile(downloaded_qt_bin_archive) else None print('Starting to download: {0}'.format(module_doc_build_qt_package_uri)) bldinstallercommon.retrieve_url(module_doc_build_qt_package_uri, downloaded_qt_bin_archive) bldinstallercommon.extract_file(downloaded_qt_bin_archive, qt_package_path) # fetch qt dependency package (optional) if bldinstallercommon.is_content_url_valid(module_doc_build_qt_dependency_package_uri): raw_name_qt_bin_dependency_package = module_doc_build_qt_dependency_package_uri.rsplit('/', 1)[-1] # get last item from array downloaded_qt_dependency_bin_archive = os.path.join(current_path, raw_name_qt_bin_dependency_package) if os.path.lexists(downloaded_qt_dependency_bin_archive): print('*** Deleted existing qt binary dependency package: [{0}] before fetching the new one.'.format(downloaded_qt_dependency_bin_archive)) os.remove(downloaded_qt_dependency_bin_archive) print('Starting to download: {0}'.format(module_doc_build_qt_dependency_package_uri)) bldinstallercommon.retrieve_url(module_doc_build_qt_dependency_package_uri, downloaded_qt_dependency_bin_archive) bldinstallercommon.extract_file(downloaded_qt_dependency_bin_archive, qt_package_path) # fetch qt icu binary package if given if module_doc_build_qt_icu_package_uri: raw_name_qt_icu_package = module_doc_build_qt_icu_package_uri.rsplit('/', 1)[-1] # get last item from array downloaded_qt_icu_archive = os.path.join(current_path, raw_name_qt_icu_package) if os.path.lexists(downloaded_qt_icu_archive): print('*** Deleted existing qt icu package: [{0}] before fetching the new one.'.format(downloaded_qt_icu_archive)) os.remove(downloaded_qt_icu_archive) print('Starting to download: {0} -> into {1}'.format(module_doc_build_qt_icu_package_uri, downloaded_qt_icu_archive)) bldinstallercommon.retrieve_url(module_doc_build_qt_icu_package_uri, downloaded_qt_icu_archive) qt_lib_directory = bldinstallercommon.locate_directory(qt_package_path, 'lib') print('Extracting icu libs into: {0}'.format(qt_lib_directory)) bldinstallercommon.extract_file(downloaded_qt_icu_archive, qt_lib_directory) # patch Qt package qt_bin_directory = bldinstallercommon.locate_directory(qt_package_path, 'bin') if not os.path.exists(qt_bin_directory): 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) qtConfFile.close() qt_directory = os.path.dirname(qt_bin_directory) #bldinstallercommon.handle_component_rpath(qt_directory, 'lib') # locate tools qmake_binary = bldinstallercommon.locate_executable(qt_directory, 'qmake') print('Using qmake from: {0}'.format(qmake_binary)) # locate module .pro file module_pro_file = bldinstallercommon.locate_file(module_src_path, '*.pro') # build module module_build_environment = dict(os.environ) module_build_environment["LD_LIBRARY_PATH"] = os.pathsep.join([os.path.join(qt_package_path, 'lib')] + optionDict.get("LD_LIBRARY_PATH", "").split(os.pathsep)) module_build_environment["QMAKESPEC"] = "linux-g++" cpu_count = ["-j" + str(multiprocessing.cpu_count() + 1)] print('Using .pro file from: {0}'.format(module_pro_file)) bld_args = [qmake_binary, module_pro_file] bldinstallercommon.do_execute_sub_process(args=bld_args, execution_path=os.path.dirname(module_pro_file), abort_on_fail=False, extra_env=module_build_environment) bld_args = ['make'] + cpu_count bldinstallercommon.do_execute_sub_process(args=bld_args, execution_path=os.path.dirname(module_pro_file), abort_on_fail=False, extra_env=module_build_environment) # make docs bld_args = ['make', '-j1', 'docs'] bldinstallercommon.do_execute_sub_process(args=bld_args, execution_path=os.path.dirname(module_pro_file), abort_on_fail=False, extra_env=module_build_environment) # make install docs module_doc_install_dir = module_src_path = os.path.join(current_path, 'module_doc_install_dir') bld_args = ['make', '-j1', 'install_docs', 'INSTALL_ROOT=' + module_doc_install_dir] bldinstallercommon.do_execute_sub_process(args=bld_args, execution_path=os.path.dirname(module_pro_file), abort_on_fail=False, extra_env=module_build_environment) # create archive doc_dir = bldinstallercommon.locate_directory(module_doc_install_dir, 'doc') if not os.path.exists(doc_dir): print('Warning! Doc archive not generated!') return archive_name = optionDict['MODULE_NAME'] + '-' + optionDict['LICENSE'] + '-doc-' + optionDict['MODULE_VERSION'] + '.7z' archive_path = os.path.join(current_path, 'doc_archives', archive_name) bld_args = ['7z', 'a', archive_path, 'doc'] bldinstallercommon.do_execute_sub_process(args=bld_args, execution_path=os.path.dirname(doc_dir), abort_on_fail=False) if os.path.exists(archive_path): print('Doc archive generated successfully: {0}'.format(archive_path))
def handle_module_doc_build(optionDict): if not bldinstallercommon.is_linux_platform(): raise RuntimeError( '*** Only Linux platform supported currently to perform doc builds. Aborting' ) if not 'MODULE_NAME' in optionDict: print( '*** MODULE_NAME environment variable not defined. Unable to generate doc for this package.' ) return if not 'MODULE_SRC_PACKAGE_URI' in optionDict: print( '*** MODULE_SRC_PACKAGE_URI environment variable not defined. Unable to generate doc for this package.' ) return if not 'MODULE_DOC_BUILD_QT_PACKAGE_URI' in optionDict: print( '*** MODULE_DOC_BUILD_QT_PACKAGE_URI environment variable not defined. Unable to generate doc for this package.' ) return module_src_package_uri = optionDict['MODULE_SRC_PACKAGE_URI'] module_doc_build_qt_package_uri = optionDict[ 'MODULE_DOC_BUILD_QT_PACKAGE_URI'] module_doc_build_qt_dependency_package_uri = optionDict.get( 'MODULE_DOC_BUILD_QT_DEPENDENCY_PACKAGE_URI', '') module_doc_build_qt_icu_package_uri = optionDict.get( 'MODULE_DOC_BUILD_QT_ICU_PACKAGE_URI', '') # define some paths current_path = os.path.dirname(os.path.realpath(__file__)) qt_package_path = os.path.join(current_path, 'doc_build_qt_package') qt_icu_path = os.path.join(current_path, 'doc_build_qt_icu_package') module_src_path = os.path.join(current_path, 'module_src_package') shutil.rmtree(qt_package_path, ignore_errors=True) shutil.rmtree(qt_icu_path, ignore_errors=True) shutil.rmtree(module_src_path, ignore_errors=True) bldinstallercommon.create_dirs(qt_package_path) bldinstallercommon.create_dirs(module_src_path) bldinstallercommon.create_dirs(qt_icu_path) # fetch module src package raw_name_module_src_package = module_src_package_uri.rsplit( '/', 1)[-1] # get last item from array downloaded_module_archive = os.path.join(current_path, raw_name_module_src_package) os.remove(downloaded_module_archive) if os.path.isfile( downloaded_module_archive) else None print('Starting to download: {0}'.format(module_src_package_uri)) bldinstallercommon.retrieve_url(module_src_package_uri, downloaded_module_archive) bldinstallercommon.extract_file(downloaded_module_archive, module_src_path) # fetch qt binary package raw_name_qt_bin_package = module_doc_build_qt_package_uri.rsplit( '/', 1)[-1] # get last item from array downloaded_qt_bin_archive = os.path.join(current_path, raw_name_qt_bin_package) os.remove(downloaded_qt_bin_archive) if os.path.isfile( downloaded_qt_bin_archive) else None print('Starting to download: {0}'.format(module_doc_build_qt_package_uri)) bldinstallercommon.retrieve_url(module_doc_build_qt_package_uri, downloaded_qt_bin_archive) bldinstallercommon.extract_file(downloaded_qt_bin_archive, qt_package_path) # fetch qt dependency package (optional) if bldinstallercommon.is_content_url_valid( module_doc_build_qt_dependency_package_uri): raw_name_qt_bin_dependency_package = module_doc_build_qt_dependency_package_uri.rsplit( '/', 1)[-1] # get last item from array downloaded_qt_dependency_bin_archive = os.path.join( current_path, raw_name_qt_bin_dependency_package) if os.path.lexists(downloaded_qt_dependency_bin_archive): print( '*** Deleted existing qt binary dependency package: [{0}] before fetching the new one.' .format(downloaded_qt_dependency_bin_archive)) os.remove(downloaded_qt_dependency_bin_archive) print('Starting to download: {0}'.format( module_doc_build_qt_dependency_package_uri)) bldinstallercommon.retrieve_url( module_doc_build_qt_dependency_package_uri, downloaded_qt_dependency_bin_archive) bldinstallercommon.extract_file(downloaded_qt_dependency_bin_archive, qt_package_path) # fetch qt icu binary package if given if module_doc_build_qt_icu_package_uri: raw_name_qt_icu_package = module_doc_build_qt_icu_package_uri.rsplit( '/', 1)[-1] # get last item from array downloaded_qt_icu_archive = os.path.join(current_path, raw_name_qt_icu_package) if os.path.lexists(downloaded_qt_icu_archive): print( '*** Deleted existing qt icu package: [{0}] before fetching the new one.' .format(downloaded_qt_icu_archive)) os.remove(downloaded_qt_icu_archive) print('Starting to download: {0} -> into {1}'.format( module_doc_build_qt_icu_package_uri, downloaded_qt_icu_archive)) bldinstallercommon.retrieve_url(module_doc_build_qt_icu_package_uri, downloaded_qt_icu_archive) qt_lib_directory = bldinstallercommon.locate_directory( qt_package_path, 'lib') print('Extracting icu libs into: {0}'.format(qt_lib_directory)) bldinstallercommon.extract_file(downloaded_qt_icu_archive, qt_lib_directory) # patch Qt package qt_bin_directory = bldinstallercommon.locate_directory( qt_package_path, 'bin') if not os.path.exists(qt_bin_directory): 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) qtConfFile.close() qt_directory = os.path.dirname(qt_bin_directory) #bldinstallercommon.handle_component_rpath(qt_directory, 'lib') # locate tools qmake_binary = bldinstallercommon.locate_executable(qt_directory, 'qmake') print('Using qmake from: {0}'.format(qmake_binary)) # locate module .pro file module_pro_file = bldinstallercommon.locate_file(module_src_path, '*.pro') # build module module_build_environment = dict(os.environ) module_build_environment["LD_LIBRARY_PATH"] = os.pathsep.join( [os.path.join(qt_package_path, 'lib')] + optionDict.get("LD_LIBRARY_PATH", "").split(os.pathsep)) module_build_environment["QMAKESPEC"] = "linux-g++" cpu_count = ["-j" + str(multiprocessing.cpu_count() + 1)] print('Using .pro file from: {0}'.format(module_pro_file)) bld_args = [qmake_binary, module_pro_file] bldinstallercommon.do_execute_sub_process( args=bld_args, execution_path=os.path.dirname(module_pro_file), abort_on_fail=False, extra_env=module_build_environment) bld_args = ['make'] + cpu_count bldinstallercommon.do_execute_sub_process( args=bld_args, execution_path=os.path.dirname(module_pro_file), abort_on_fail=False, extra_env=module_build_environment) # make docs bld_args = ['make', '-j1', 'docs'] bldinstallercommon.do_execute_sub_process( args=bld_args, execution_path=os.path.dirname(module_pro_file), abort_on_fail=False, extra_env=module_build_environment) # make install docs module_doc_install_dir = module_src_path = os.path.join( current_path, 'module_doc_install_dir') bld_args = [ 'make', '-j1', 'install_docs', 'INSTALL_ROOT=' + module_doc_install_dir ] bldinstallercommon.do_execute_sub_process( args=bld_args, execution_path=os.path.dirname(module_pro_file), abort_on_fail=False, extra_env=module_build_environment) # create archive doc_dir = bldinstallercommon.locate_directory(module_doc_install_dir, 'doc') if not os.path.exists(doc_dir): print('Warning! Doc archive not generated!') return archive_name = optionDict['MODULE_NAME'] + '-' + optionDict[ 'LICENSE'] + '-doc-' + optionDict['MODULE_VERSION'] + '.7z' archive_path = os.path.join(current_path, 'doc_archives', archive_name) bld_args = ['7z', 'a', archive_path, 'doc'] bldinstallercommon.do_execute_sub_process( args=bld_args, execution_path=os.path.dirname(doc_dir), abort_on_fail=False) if os.path.exists(archive_path): print('Doc archive generated successfully: {0}'.format(archive_path))