def install_bootstrap(self, manager: PackageManagerBase, plus_packages: List = None) -> None: """ Install system software using the package manager from the host, also known as bootstrapping :param object manager: instance of a :class:`PackageManager` subclass :param list plus_packages: list of additional packages :raises KiwiBootStrapPhaseFailed: if the bootstrapping process fails either installing packages or including bootstrap archives """ if not self.xml_state.get_bootstrap_packages_sections() \ and not plus_packages: log.warning('No <packages> sections marked as "bootstrap" found') log.info('Processing of bootstrap stage skipped') return log.info('Installing bootstrap packages') bootstrap_packages = self.xml_state.get_bootstrap_packages( plus_packages) 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() else: manager.process_plus_recommended() all_install_items = self._setup_requests(manager, bootstrap_packages, bootstrap_collections, bootstrap_products) process = CommandProcess( command=manager.process_install_requests_bootstrap(self.root_bind), 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 issue: if manager.has_failed(process.returncode()): raise KiwiBootStrapPhaseFailed( self.issue_message.format( headline='Bootstrap package installation failed', reason=issue)) manager.post_process_install_requests_bootstrap(self.root_bind) # process archive installations if bootstrap_archives: try: self._install_archives(bootstrap_archives) except Exception as issue: raise KiwiBootStrapPhaseFailed( self.issue_message.format( headline='Bootstrap archive installation failed', reason=issue))
class TestPackageManagerBase(object): def setup(self): repository = mock.Mock() repository.root_dir = 'root-dir' self.manager = PackageManagerBase(repository) @raises(NotImplementedError) def test_request_package(self): self.manager.request_package('name') @raises(NotImplementedError) def test_request_collection(self): self.manager.request_collection('name') @raises(NotImplementedError) def test_request_product(self): self.manager.request_product('name') @raises(NotImplementedError) def test_process_install_requests_bootstrap(self): self.manager.process_install_requests_bootstrap() @raises(NotImplementedError) def test_process_install_requests(self): self.manager.process_install_requests() @raises(NotImplementedError) def test_process_delete_requests(self): self.manager.process_delete_requests() @raises(NotImplementedError) def test_update(self): self.manager.update() @raises(NotImplementedError) def test_process_only_required(self): self.manager.process_only_required() @raises(NotImplementedError) def test_match_package_installed(self): self.manager.match_package_installed('package_name', 'log') @raises(NotImplementedError) def test_match_package_deleted(self): self.manager.match_package_deleted('package_name', 'log') @raises(NotImplementedError) def test_database_consistent(self): self.manager.database_consistent() @raises(NotImplementedError) def test_dump_reload_package_database(self): self.manager.dump_reload_package_database() def test_cleanup_requests(self): self.manager.cleanup_requests() assert self.manager.package_requests == [] assert self.manager.product_requests == [] assert self.manager.collection_requests == []
def install_system(self, manager: PackageManagerBase) -> None: """ 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 :param object manager: instance of a :class:`PackageManager` subclass :raises KiwiInstallPhaseFailed: if the install process fails either installing packages or including any archive """ 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() system_archives_target_dirs = self.xml_state.get_system_archives_target_dirs( ) system_packages_ignored = self.xml_state.get_system_ignore_packages() # process package installations if collection_type == 'onlyRequired': manager.process_only_required() else: manager.process_plus_recommended() all_install_items = self._setup_requests(manager, system_packages, system_collections, system_products, system_packages_ignored) 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 issue: if manager.has_failed(process.returncode()): raise KiwiInstallPhaseFailed( self.issue_message.format( headline='System package installation failed', reason=issue)) # process archive installations if system_archives: try: self._install_archives(system_archives, system_archives_target_dirs) except Exception as issue: raise KiwiInstallPhaseFailed( self.issue_message.format( headline='System archive installation failed', reason=issue))
class TestPackageManagerBase(object): def setup(self): repository = mock.Mock() repository.root_dir = 'root-dir' self.manager = PackageManagerBase(repository) @raises(NotImplementedError) def test_request_package(self): self.manager.request_package('name') @raises(NotImplementedError) def test_request_collection(self): self.manager.request_collection('name') @raises(NotImplementedError) def test_request_product(self): self.manager.request_product('name') @patch.object(PackageManagerBase, 'request_package_exclusion') def test_request_package_lock(self, mock_exclude): self.manager.request_package_lock('name') mock_exclude.assert_called_once_with('name') @raises(NotImplementedError) def test_request_package_exclusion(self): self.manager.request_package_exclusion('name') @raises(NotImplementedError) def test_process_install_requests_bootstrap(self): self.manager.process_install_requests_bootstrap() def test_post_process_install_requests_bootstrap(self): self.manager.post_process_install_requests_bootstrap() @raises(NotImplementedError) def test_process_install_requests(self): self.manager.process_install_requests() @raises(NotImplementedError) def test_process_delete_requests(self): self.manager.process_delete_requests() @raises(NotImplementedError) def test_update(self): self.manager.update() @raises(NotImplementedError) def test_process_only_required(self): self.manager.process_only_required() @raises(NotImplementedError) def test_process_plus_recommended(self): self.manager.process_plus_recommended() @raises(NotImplementedError) def test_match_package_installed(self): self.manager.match_package_installed('package_name', 'log') @raises(NotImplementedError) def test_match_package_deleted(self): self.manager.match_package_deleted('package_name', 'log') def test_database_consistent(self): self.manager.database_consistent() def test_dump_reload_package_database(self): self.manager.dump_reload_package_database() def test_has_failed(self): assert self.manager.has_failed(0) is False assert self.manager.has_failed(1) is True def test_cleanup_requests(self): self.manager.cleanup_requests() assert self.manager.package_requests == [] assert self.manager.product_requests == [] assert self.manager.collection_requests == [] assert self.manager.exclude_requests == []
class TestPackageManagerBase: def setup(self): repository = mock.Mock() repository.root_dir = 'root-dir' self.manager = PackageManagerBase(repository) def setup_method(self, cls): self.setup() def test_request_package(self): with raises(NotImplementedError): self.manager.request_package('name') def test_request_collection(self): with raises(NotImplementedError): self.manager.request_collection('name') def test_request_product(self): with raises(NotImplementedError): self.manager.request_product('name') def test_request_package_lock(self): with raises(DeprecationWarning): self.manager.request_package_lock('name') def test_request_package_exclusion(self): with raises(NotImplementedError): self.manager.request_package_exclusion('name') def test_setup_repository_modules(self): with raises(NotImplementedError): self.manager.setup_repository_modules({}) def test_process_install_requests_bootstrap(self): with raises(NotImplementedError): self.manager.process_install_requests_bootstrap() def test_post_process_install_requests_bootstrap(self): self.manager.post_process_install_requests_bootstrap() def test_post_process_delete_requests(self): self.manager.post_process_delete_requests() def test_process_install_requests(self): with raises(NotImplementedError): self.manager.process_install_requests() def test_process_delete_requests(self): with raises(NotImplementedError): self.manager.process_delete_requests() def test_update(self): with raises(NotImplementedError): self.manager.update() def test_process_only_required(self): with raises(NotImplementedError): self.manager.process_only_required() def test_process_plus_recommended(self): with raises(NotImplementedError): self.manager.process_plus_recommended() def test_match_package_installed(self): with raises(NotImplementedError): self.manager.match_package_installed('package_name', 'log') def test_match_package_deleted(self): with raises(NotImplementedError): self.manager.match_package_deleted('package_name', 'log') def test_database_consistent(self): with raises(DeprecationWarning): self.manager.database_consistent() def test_dump_reload_package_database(self): with raises(DeprecationWarning): self.manager.dump_reload_package_database() def test_has_failed(self): assert self.manager.has_failed(0) is False assert self.manager.has_failed(1) is True def test_cleanup_requests(self): self.manager.cleanup_requests() assert self.manager.package_requests == [] assert self.manager.product_requests == [] assert self.manager.collection_requests == [] assert self.manager.exclude_requests == [] def test_get_error_details(self): assert self.manager.get_error_details() == '' def test_clean_leftovers(self): self.manager.clean_leftovers()