def delete_packages(self, manager, packages, force=False): """ delete one or more packages using the package manager inside of the new root directory """ log.info('Deleting system packages (chroot)') all_delete_items = self.__setup_requests( manager, packages ) if all_delete_items: process = CommandProcess( command=manager.process_delete_requests(force), log_topic='system' ) try: process.poll_show_progress( items_to_complete=all_delete_items, match_method=process.create_match_method( manager.match_package_deleted ) ) except Exception as e: raise KiwiSystemDeletePackagesFailed( 'Package deletion failed: %s' % format(e) )
def update_system(self, manager): """ install package updates from the used repositories. the process uses the package manager from inside of the new root directory """ log.info('Update system (chroot)') process = CommandProcess(command=manager.update(), log_topic='update') try: process.poll() except Exception as e: raise KiwiSystemUpdateFailed('System update failed: %s' % format(e))
def __call_script(self, name): if os.path.exists(self.root_dir + '/image/' + name): config_script = Command.call( ['chroot', self.root_dir, 'bash', '/image/' + name] ) process = CommandProcess( command=config_script, log_topic='Calling ' + name + ' script' ) result = process.poll_and_watch() if result.returncode != 0: raise KiwiScriptFailed( '%s failed: %s' % (name, format(result.stderr)) )
def install_system(self, manager): """ install system software using the package manager inside of the new root directory. This is done via a chroot operation and requires the desired package manager to became installed via the bootstrap phase """ log.info( 'Installing system (chroot) for build type: %s', self.xml_state.get_build_type_name() ) collection_type = self.xml_state.get_system_collection_type() log.info('--> collection type: %s', collection_type) system_packages = self.xml_state.get_system_packages() system_collections = self.xml_state.get_system_collections() system_products = self.xml_state.get_system_products() system_archives = self.xml_state.get_system_archives() # process package installations if collection_type == 'onlyRequired': manager.process_only_required() all_install_items = self.__setup_requests( manager, system_packages, system_collections, system_products ) if all_install_items: process = CommandProcess( command=manager.process_install_requests(), log_topic='system' ) try: process.poll_show_progress( items_to_complete=all_install_items, match_method=process.create_match_method( manager.match_package_installed ) ) except Exception as e: raise KiwiInstallPhaseFailed( 'System package installation failed: %s' % format(e) ) # process archive installations if system_archives: try: self.__install_archives(system_archives) except Exception as e: raise KiwiInstallPhaseFailed( 'System archive installation failed: %s' % format(e) )
def install_bootstrap(self, manager): """ install system software using the package manager from the host, also known as bootstrapping """ log.info('Installing bootstrap packages') bootstrap_packages = self.xml_state.get_bootstrap_packages() bootstrap_packages.append( self.xml_state.get_package_manager() ) collection_type = self.xml_state.get_bootstrap_collection_type() log.info('--> collection type: %s', collection_type) bootstrap_collections = self.xml_state.get_bootstrap_collections() bootstrap_products = self.xml_state.get_bootstrap_products() bootstrap_archives = self.xml_state.get_bootstrap_archives() # process package installations if collection_type == 'onlyRequired': manager.process_only_required() all_install_items = self.__setup_requests( manager, bootstrap_packages, bootstrap_collections, bootstrap_products ) process = CommandProcess( command=manager.process_install_requests_bootstrap(), log_topic='bootstrap' ) try: process.poll_show_progress( items_to_complete=all_install_items, match_method=process.create_match_method( manager.match_package_installed ) ) except Exception as e: raise KiwiBootStrapPhaseFailed( 'Bootstrap package installation failed: %s' % format(e) ) manager.dump_reload_package_database() # process archive installations if bootstrap_archives: try: self.__install_archives(bootstrap_archives) except Exception as e: raise KiwiBootStrapPhaseFailed( 'Bootstrap archive installation failed: %s' % format(e) )
def update_system(self, manager): """ install package updates from the used repositories. the process uses the package manager from inside of the new root directory """ log.info('Update system (chroot)') process = CommandProcess( command=manager.update(), log_topic='update' ) try: process.poll() except Exception as e: raise KiwiSystemUpdateFailed( 'System update failed: %s' % format(e) )
def __call_script_no_chroot(self, name, option_list): if os.path.exists(self.root_dir + '/image/' + name): bash_command = [ 'cd', self.root_dir, '&&', 'bash', '--norc', 'image/' + name, ' '.join(option_list) ] config_script = Command.call( ['bash', '-c', ' '.join(bash_command)] ) process = CommandProcess( command=config_script, log_topic='Calling ' + name + ' script' ) result = process.poll_and_watch() if result.returncode != 0: raise KiwiScriptFailed( '%s failed: %s' % (name, format(result.stderr)) )
def install_packages(self, manager, packages): """ install one or more packages using the package manager inside of the new root directory """ log.info('Installing system packages (chroot)') all_install_items = self.__setup_requests(manager, packages) if all_install_items: process = CommandProcess( command=manager.process_install_requests(), log_topic='system') try: process.poll_show_progress( items_to_complete=all_install_items, match_method=process.create_match_method( manager.match_package_installed)) except Exception as e: raise KiwiSystemInstallPackagesFailed( 'Package installation failed: %s' % format(e))
def install_system(self, manager): """ install system software using the package manager inside of the new root directory. This is done via a chroot operation and requires the desired package manager to became installed via the bootstrap phase """ log.info('Installing system (chroot) for build type: %s', self.xml_state.get_build_type_name()) collection_type = self.xml_state.get_system_collection_type() log.info('--> collection type: %s', collection_type) system_packages = self.xml_state.get_system_packages() system_collections = self.xml_state.get_system_collections() system_products = self.xml_state.get_system_products() system_archives = self.xml_state.get_system_archives() # process package installations if collection_type == 'onlyRequired': manager.process_only_required() all_install_items = self.__setup_requests(manager, system_packages, system_collections, system_products) if all_install_items: process = CommandProcess( command=manager.process_install_requests(), log_topic='system') try: process.poll_show_progress( items_to_complete=all_install_items, match_method=process.create_match_method( manager.match_package_installed)) except Exception as e: raise KiwiInstallPhaseFailed( 'System package installation failed: %s' % format(e)) # process archive installations if system_archives: try: self.__install_archives(system_archives) except Exception as e: raise KiwiInstallPhaseFailed( 'System archive installation failed: %s' % format(e))
def install_bootstrap(self, manager): """ install system software using the package manager from the host, also known as bootstrapping """ log.info('Installing bootstrap packages') bootstrap_packages = self.xml_state.get_bootstrap_packages() bootstrap_packages.append(self.xml_state.get_package_manager()) collection_type = self.xml_state.get_bootstrap_collection_type() log.info('--> collection type: %s', collection_type) bootstrap_collections = self.xml_state.get_bootstrap_collections() bootstrap_products = self.xml_state.get_bootstrap_products() bootstrap_archives = self.xml_state.get_bootstrap_archives() # process package installations if collection_type == 'onlyRequired': manager.process_only_required() all_install_items = self.__setup_requests(manager, bootstrap_packages, bootstrap_collections, bootstrap_products) process = CommandProcess( command=manager.process_install_requests_bootstrap(), log_topic='bootstrap') try: process.poll_show_progress( items_to_complete=all_install_items, match_method=process.create_match_method( manager.match_package_installed)) except Exception as e: raise KiwiBootStrapPhaseFailed( 'Bootstrap package installation failed: %s' % format(e)) manager.dump_reload_package_database() # process archive installations if bootstrap_archives: try: self.__install_archives(bootstrap_archives) except Exception as e: raise KiwiBootStrapPhaseFailed( 'Bootstrap archive installation failed: %s' % format(e))