Ejemplo n.º 1
0
    def delete_packages(self, manager, packages, force=False):
        """
        Delete one or more packages using the package manager inside
        of the new root directory. If the removal is set with `force` flag
        only listed packages are deleted and any dependency break or leftover
        is ignored.

        :param object manager: instance of a :class:`PackageManager` subclass
        :param list packages: package list
        :param bool force: force deletion true|false

        :raises KiwiSystemDeletePackagesFailed: if installation process fails
        """
        all_delete_items = self._setup_requests(manager, packages)
        if all_delete_items:
            log.info('{0} system packages (chroot)'.format(
                'Force deleting' if force else 'Uninstall'))
            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 issue:
                raise KiwiSystemDeletePackagesFailed(
                    self.issue_message.format(
                        headline='Package deletion failed', reason=issue))
Ejemplo n.º 2
0
    def install_packages(self, manager, packages):
        """
        Install one or more packages using the package manager inside
        of the new root directory

        :param object manager: PackageManager
        :param list packages: package list
        """
        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)
                )
Ejemplo n.º 3
0
    def install_packages(self, manager, packages):
        """
        Install one or more packages using the package manager inside
        of the new root directory

        :param object manager: instance of a :class:`PackageManager` subclass
        :param list packages: package list

        :raises KiwiSystemInstallPackagesFailed: if installation process fails
        """
        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 issue:
                raise KiwiSystemInstallPackagesFailed(
                    self.issue_message.format(
                        headline='Package installation failed',
                        reason=issue
                    )
                )
Ejemplo n.º 4
0
    def delete_packages(self, manager, packages, force=False):
        """
        Delete one or more packages using the package manager inside
        of the new root directory

        :param object manager: PackageManager
        :param list packages: package list
        :param bool force: force deletion true|false
        """
        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)
                )
Ejemplo n.º 5
0
    def delete_packages(self, manager, packages, force=False):
        """
        Delete one or more packages using the package manager inside
        of the new root directory. If the removal is set with `force` flag
        only listed packages are deleted and any dependency break or leftover
        is ignored.

        :param object manager: instance of a :class:`PackageManager` subclass
        :param list packages: package list
        :param bool force: force deletion true|false

        :raises KiwiSystemDeletePackagesFailed: if installation process fails
        """
        log.info('{0} system packages (chroot)'.format(
            'Force deleting' if force else 'Uninstall'
        ))
        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)
                )
Ejemplo n.º 6
0
    def install_packages(self, manager, packages):
        """
        Install one or more packages using the package manager inside
        of the new root directory

        :param object manager: instance of a :class:`PackageManager` subclass
        :param list packages: package list

        :raises KiwiSystemInstallPackagesFailed: if installation process fails
        """
        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)
                )
Ejemplo n.º 7
0
Archivo: prepare.py Proyecto: jfkw/kiwi
    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))
Ejemplo n.º 8
0
Archivo: prepare.py Proyecto: D4N/kiwi
    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

        :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_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(
                        'System package installation failed: {0}'.format(issue)
                    )
        # 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)
                )
Ejemplo n.º 9
0
    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

        :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_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 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)
                )
Ejemplo n.º 10
0
    def install_bootstrap(self, manager):
        """
        Install system software using the package manager
        from the host, also known as bootstrapping

        :param object manager: instance of a :class:`PackageManager` subclass

        :raises KiwiBootStrapPhaseFailed: if the bootstrapping process fails
            either installing packages or including bootstrap archives
        """
        if not self.xml_state.get_bootstrap_packages_sections():
            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()
        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(),
            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)
                )
Ejemplo n.º 11
0
 def test_poll_show_progress_raises(self, mock_command):
     match_method = CommandProcess(mock_command).create_match_method(
         self.fake_matcher)
     process = CommandProcess(mock_command)
     process.command.command.process.poll = self.flow
     process.command.command.output_available = self.flow_out_available
     process.command.command.error_available = self.flow_err_available
     process.command.command.output.read = self.flow_out
     process.command.command.error.read = self.flow_err
     process.command.command.process.returncode = 1
     process.poll_show_progress(['a', 'b'], match_method)
Ejemplo n.º 12
0
 def test_poll_show_progress_raises(self, mock_command):
     match_method = CommandProcess(mock_command).create_match_method(
         self.fake_matcher
     )
     process = CommandProcess(mock_command)
     process.command.command.process.poll = self.flow
     process.command.command.output_available = self.flow_out_available
     process.command.command.error_available = self.flow_err_available
     process.command.command.output.read = self.flow_out
     process.command.command.error.read = self.flow_err
     process.command.command.process.returncode = 1
     process.poll_show_progress(['a', 'b'], match_method)
Ejemplo n.º 13
0
    def install_bootstrap(self, manager):
        """
        Install system software using the package manager
        from the host, also known as bootstrapping
        """
        if not self.xml_state.get_bootstrap_packages_sections():
            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()
        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(),
            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)
                )
Ejemplo n.º 14
0
 def test_poll_show_progress(self, mock_command):
     match_method = CommandProcess(mock_command).create_match_method(
         self.fake_matcher)
     process = CommandProcess(mock_command)
     process.command.command.process.poll = self.flow
     process.command.command.output_available = self.flow_out_available
     process.command.command.error_available = self.flow_err_available
     process.command.command.output.read = self.flow_out
     process.command.command.error.read = self.flow_err
     process.command.command.process.returncode = 0
     with self._caplog.at_level(logging.DEBUG):
         process.poll_show_progress(['a', 'b'], match_method)
         assert 'system: data' in self._caplog.text
Ejemplo n.º 15
0
 def test_poll_show_progress(self, mock_log_debug, mock_command):
     match_method = CommandProcess(mock_command).create_match_method(
         self.fake_matcher)
     process = CommandProcess(mock_command)
     process.command.command.process.poll = self.flow
     process.command.command.output_available = self.flow_out_available
     process.command.command.error_available = self.flow_err_available
     process.command.command.output.read = self.flow_out
     process.command.command.error.read = self.flow_err
     process.command.command.process.returncode = 0
     process.poll_show_progress(['a', 'b'], match_method)
     assert mock_log_debug.call_args_list == [
         call('%s: %s', 'system', 'data')
     ]
Ejemplo n.º 16
0
 def test_poll_show_progress(self, mock_log_debug, mock_command):
     match_method = CommandProcess(mock_command).create_match_method(
         self.fake_matcher
     )
     process = CommandProcess(mock_command)
     process.command.command.process.poll = self.flow
     process.command.command.output_available = self.flow_out_available
     process.command.command.error_available = self.flow_err_available
     process.command.command.output.read = self.flow_out
     process.command.command.error.read = self.flow_err
     process.command.command.process.returncode = 0
     process.poll_show_progress(['a', 'b'], match_method)
     assert mock_log_debug.call_args_list == [
         call('%s: %s', 'system', 'data')
     ]