当前位置: 首页>>代码示例>>Python>>正文


Python Defaults.get_grub_path方法代码示例

本文整理汇总了Python中kiwi.defaults.Defaults.get_grub_path方法的典型用法代码示例。如果您正苦于以下问题:Python Defaults.get_grub_path方法的具体用法?Python Defaults.get_grub_path怎么用?Python Defaults.get_grub_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kiwi.defaults.Defaults的用法示例。


在下文中一共展示了Defaults.get_grub_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _find_grub_data

# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get_grub_path [as 别名]
    def _find_grub_data(self, lookup_path):
        grub_path = Defaults.get_grub_path(lookup_path)
        if grub_path:
            return grub_path

        raise KiwiBootLoaderGrubDataError(
            'No grub2 installation found in %s' % lookup_path
        )
开发者ID:adrianschroeter,项目名称:kiwi,代码行数:10,代码来源:grub2.py

示例2: install

# 需要导入模块: from kiwi.defaults import Defaults [as 别名]
# 或者: from kiwi.defaults.Defaults import get_grub_path [as 别名]
    def install(self):
        """
        Install bootloader on disk device
        """
        log.info('Installing grub2 on disk %s', self.device)

        if self.target_removable:
            self.install_arguments.append('--removable')

        if self.arch == 'x86_64' or self.arch == 'i686' or self.arch == 'i586':
            self.target = 'i386-pc'
            self.install_device = self.device
            self.modules = ' '.join(
                Defaults.get_grub_bios_modules(multiboot=True)
            )
            self.install_arguments.append('--skip-fs-probe')
        elif self.arch.startswith('ppc64'):
            if not self.custom_args or 'prep_device' not in self.custom_args:
                raise KiwiBootLoaderGrubInstallError(
                    'prep device name required for grub2 installation on ppc'
                )
            self.target = 'powerpc-ieee1275'
            self.install_device = self.custom_args['prep_device']
            self.modules = ' '.join(Defaults.get_grub_ofw_modules())
            self.install_arguments.append('--skip-fs-probe')
            self.install_arguments.append('--no-nvram')
        else:
            raise KiwiBootLoaderGrubPlatformError(
                'host architecture %s not supported for grub2 installation' %
                self.arch
            )

        self.root_mount = MountManager(
            device=self.custom_args['root_device']
        )
        self.boot_mount = MountManager(
            device=self.custom_args['boot_device'],
            mountpoint=self.root_mount.mountpoint + '/boot'
        )

        self.root_mount.mount()

        if not self.root_mount.device == self.boot_mount.device:
            self.boot_mount.mount()

        if self.volumes:
            for volume_path in Path.sort_by_hierarchy(
                sorted(self.volumes.keys())
            ):
                volume_mount = MountManager(
                    device=self.volumes[volume_path]['volume_device'],
                    mountpoint=self.root_mount.mountpoint + '/' + volume_path
                )
                self.volumes_mount.append(volume_mount)
                volume_mount.mount(
                    options=[self.volumes[volume_path]['volume_options']]
                )

        self.device_mount = MountManager(
            device='/dev',
            mountpoint=self.root_mount.mountpoint + '/dev'
        )
        self.proc_mount = MountManager(
            device='/proc',
            mountpoint=self.root_mount.mountpoint + '/proc'
        )
        self.sysfs_mount = MountManager(
            device='/sys',
            mountpoint=self.root_mount.mountpoint + '/sys'
        )
        self.device_mount.bind_mount()
        self.proc_mount.bind_mount()
        self.sysfs_mount.bind_mount()

        # check if a grub installation could be found in the image system
        grub_directory = Defaults.get_grub_path(
            self.root_mount.mountpoint + '/usr/lib'
        )
        if not grub_directory:
            raise KiwiBootLoaderGrubDataError(
                'No grub2 installation found in %s' % self.root_mount.mountpoint
            )
        grub_directory = grub_directory.replace(
            self.root_mount.mountpoint, ''
        )
        module_directory = grub_directory + '/' + self.target
        boot_directory = '/boot'

        # wipe existing grubenv to allow the grub installer to create a new one
        grubenv_glob = os.sep.join(
            [self.root_mount.mountpoint, 'boot', '*', 'grubenv']
        )
        for grubenv in glob.glob(grubenv_glob):
            Path.wipe(grubenv)

        # install grub2 boot code
        Command.run(
            [
                'chroot', self.root_mount.mountpoint,
                self._get_grub2_install_tool_name(self.root_mount.mountpoint)
#.........这里部分代码省略.........
开发者ID:AdamMajer,项目名称:kiwi-ng,代码行数:103,代码来源:grub2.py


注:本文中的kiwi.defaults.Defaults.get_grub_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。