コード例 #1
0
ファイル: engine.py プロジェクト: scollison/image-bootstrap
    def detect_grub2_install(self):
        if self._command_grub2_install:
            return  # Explicit command given, no detection needed

        if self._config.bootloader_approach not in BOOTLOADER__HOST_GRUB2:
            return  # Host grub2-install not used, no detection needed

        COMMAND_GRUB_INSTALL = 'grub-install'
        COMMAND_GRUB2_INSTALL = 'grub2-install'

        self._command_grub2_install = COMMAND_GRUB2_INSTALL
        try:
            find_command(self._command_grub2_install)
        except OSError as e:
            if e.errno != EXIT_COMMAND_NOT_FOUND:
                raise

            self._command_grub2_install = COMMAND_GRUB_INSTALL
            try:
                find_command(self._command_grub2_install)
            except OSError as e:
                if e.errno != EXIT_COMMAND_NOT_FOUND:
                    raise

                # NOTE: consecutive search for "grub-install" will fail and
                #       be reported, so we don't need to raise here
                return

            self._protect_against_grub_legacy(self._command_grub2_install)
コード例 #2
0
    def detect_grub2_install(self):
        if self._command_grub2_install:
            return  # Explicit command given, no detection needed

        if self._config.bootloader_approach not in BOOTLOADER__HOST_GRUB2:
            return  # Host grub2-install not used, no detection needed

        COMMAND_GRUB_INSTALL = 'grub-install'
        COMMAND_GRUB2_INSTALL = 'grub2-install'

        self._command_grub2_install = COMMAND_GRUB2_INSTALL
        try:
            find_command(self._command_grub2_install)
        except OSError as e:
            if e.errno != EXIT_COMMAND_NOT_FOUND:
                raise

            self._command_grub2_install = COMMAND_GRUB_INSTALL
            try:
                find_command(self._command_grub2_install)
            except OSError as e:
                if e.errno != EXIT_COMMAND_NOT_FOUND:
                    raise

                # NOTE: consecutive search for "grub-install" will fail and
                #       be reported, so we don't need to raise here
                return

            self._protect_against_grub_legacy(self._command_grub2_install)
コード例 #3
0
ファイル: yum_based.py プロジェクト: ym/image-bootstrap
    def _repair_var_lib_rpm(self, rpm_berkeley_db_version):
        self._messenger.info('Repairing RPM package database...')
        for db_dump_command in _get_db_dump_command_names(
                rpm_berkeley_db_version):
            try:
                abs_path_db_dump = find_command(db_dump_command)
                self._messenger.info('Checking for %s... %s' %
                                     (db_dump_command, abs_path_db_dump))
                break
            except OSError:
                self._messenger.info('Checking for %s... not found' %
                                     db_dump_command)
                pass
        else:
            raise OSError(EXIT_COMMAND_NOT_FOUND,
                          'No db*_dump command found in PATH.')

        abs_path_packages = '/var/lib/rpm/Packages'
        abs_full_path_packages = os.path.join(self._abs_target_dir,
                                              abs_path_packages.lstrip('/'))

        fd, abs_full_path_temp = tempfile.mkstemp(
            prefix='Packages-',
            suffix='.dump',
            dir=os.path.dirname(abs_full_path_packages))
        try:
            os.close(fd)

            abs_path_temp = os.path.join(os.path.dirname(abs_path_packages),
                                         os.path.split(abs_full_path_temp)[-1])

            # Export
            self._executor.check_call([
                abs_path_db_dump,
                '-f',
                abs_full_path_temp,
                abs_full_path_packages,
            ])

            os.remove(abs_full_path_packages)

            # Import
            self._executor.check_call([
                COMMAND_CHROOT,
                self._abs_target_dir,
                'db_load',
                '-f',
                abs_path_temp,
                abs_path_packages,
            ])
        finally:
            os.remove(abs_full_path_temp)