Пример #1
0
    def _copy_theme_data_to_boot_directory(self, lookup_path, target):
        if not lookup_path:
            lookup_path = self.boot_dir
        font_name = 'unicode.pf2'
        efi_font_dir = Defaults.get_grub_efi_font_directory(lookup_path)
        boot_fonts_dir = os.path.normpath(
            os.sep.join([
                self.boot_dir,
                self.get_boot_path(target), self.boot_directory_name, 'fonts'
            ]))
        try:
            unicode_font = Defaults.get_grub_path(lookup_path, font_name)
            if not os.path.exists(os.sep.join([boot_fonts_dir, font_name])):
                Path.create(boot_fonts_dir)
                Command.run(['cp', unicode_font, boot_fonts_dir])
            if efi_font_dir:
                Command.run(['cp', unicode_font, efi_font_dir])
        except Exception as issue:
            raise KiwiBootLoaderGrubFontError(
                'Setting up unicode font failed with {0}'.format(issue))

        boot_theme_dir = os.sep.join(
            [self.boot_dir, 'boot', self.boot_directory_name, 'themes'])
        Path.create(boot_theme_dir)

        if self.theme:
            theme_dir = Defaults.get_grub_path(lookup_path,
                                               'themes/' + self.theme,
                                               raise_on_error=False)
            boot_theme_background_file = self._find_theme_background_file(
                lookup_path)
            if theme_dir and os.path.exists(theme_dir):
                if boot_theme_background_file:
                    # A background file was found. Preserve a copy of the
                    # file which was created at install time of the theme
                    # package by the activate-theme script
                    boot_theme_background_backup_file = os.sep.join(
                        [self.boot_dir, 'background.png'])
                    Command.run([
                        'cp', boot_theme_background_file,
                        boot_theme_background_backup_file
                    ])
                # sync theme data from install path to boot path
                data = DataSync(theme_dir, boot_theme_dir)
                data.sync_data(options=['-a'])
                if boot_theme_background_file:
                    # Install preserved background file to the theme
                    Command.run([
                        'mv', boot_theme_background_backup_file,
                        os.sep.join([boot_theme_dir, self.theme])
                    ])
            elif boot_theme_background_file:
                # assume all theme data is in the directory of the
                # background file and just sync that directory to the
                # boot path
                data = DataSync(os.path.dirname(boot_theme_background_file),
                                boot_theme_dir)
                data.sync_data(options=['-a'])

        self._check_boot_theme_exists()
Пример #2
0
    def _copy_theme_data_to_boot_directory(self, lookup_path):
        if not lookup_path:
            lookup_path = self.root_dir
        boot_unicode_font = self.root_dir + '/boot/unicode.pf2'
        if not os.path.exists(boot_unicode_font):
            unicode_font = self._find_grub_data(lookup_path + '/usr/share') + \
                '/unicode.pf2'
            try:
                Command.run(['cp', unicode_font, boot_unicode_font])
            except Exception:
                raise KiwiBootLoaderGrubFontError('Unicode font %s not found' %
                                                  unicode_font)

        boot_theme_dir = os.sep.join(
            [self.root_dir, 'boot', self.boot_directory_name, 'themes'])
        Path.create(boot_theme_dir)

        if self.theme:
            theme_dir = self._find_grub_data(lookup_path + '/usr/share') + \
                '/themes/' + self.theme
            boot_theme_background_file = self._find_theme_background_file(
                lookup_path)
            if os.path.exists(theme_dir):
                if boot_theme_background_file:
                    # A background file was found. Preserve a copy of the
                    # file which was created at install time of the theme
                    # package by the activate-theme script
                    boot_theme_background_backup_file = os.sep.join(
                        [self.root_dir, 'background.png'])
                    Command.run([
                        'cp', boot_theme_background_file,
                        boot_theme_background_backup_file
                    ])
                # sync theme data from install path to boot path
                data = DataSync(theme_dir, boot_theme_dir)
                data.sync_data(options=['-z', '-a'])
                if boot_theme_background_file:
                    # Install preserved background file to the theme
                    Command.run([
                        'mv', boot_theme_background_backup_file,
                        os.sep.join([boot_theme_dir, self.theme])
                    ])
            elif boot_theme_background_file:
                # assume all theme data is in the directory of the
                # background file and just sync that directory to the
                # boot path
                data = DataSync(os.path.dirname(boot_theme_background_file),
                                boot_theme_dir)
                data.sync_data(options=['-z', '-a'])

        self._check_boot_theme_exists()
Пример #3
0
    def _copy_theme_data_to_boot_directory(self, lookup_path):
        if not lookup_path:
            lookup_path = self.root_dir
        boot_unicode_font = self.root_dir + '/boot/unicode.pf2'
        if not os.path.exists(boot_unicode_font):
            unicode_font = self._find_grub_data(lookup_path + '/usr/share') + \
                '/unicode.pf2'
            try:
                Command.run(['cp', unicode_font, boot_unicode_font])
            except Exception:
                raise KiwiBootLoaderGrubFontError('Unicode font %s not found' %
                                                  unicode_font)

        boot_theme_dir = os.sep.join(
            [self.root_dir, 'boot', self.boot_directory_name, 'themes'])
        Path.create(boot_theme_dir)

        if self.theme:
            theme_dir = self._find_grub_data(lookup_path + '/usr/share') + \
                '/themes/' + self.theme
            # lookup theme background, it is expected that the
            # installation of the theme package provided an appropriate
            # background file
            boot_theme_background_file = self._find_theme_background_file(
                lookup_path)
            if os.path.exists(theme_dir) and boot_theme_background_file:
                # store a backup of the background file
                boot_theme_background_backup_file = os.sep.join(
                    [self.root_dir, 'background.png'])
                Command.run([
                    'cp', boot_theme_background_file,
                    boot_theme_background_backup_file
                ])
                # sync theme data from install path to boot path
                data = DataSync(theme_dir, boot_theme_dir)
                data.sync_data(options=['-z', '-a'])
                # restore background file
                Command.run([
                    'mv', boot_theme_background_backup_file,
                    os.sep.join([boot_theme_dir, self.theme])
                ])
            elif boot_theme_background_file:
                # assume all theme data is in the directory of the
                # background file and just sync that directory to the
                # boot path
                data = DataSync(os.path.dirname(boot_theme_background_file),
                                boot_theme_dir)
                data.sync_data(options=['-z', '-a'])

        self._check_boot_theme_exists()
Пример #4
0
    def _copy_theme_data_to_boot_directory(self, lookup_path):
        if not lookup_path:
            lookup_path = self.root_dir
        boot_unicode_font = self.root_dir + '/boot/unicode.pf2'
        if not os.path.exists(boot_unicode_font):
            unicode_font = self._find_grub_data(lookup_path + '/usr/share') + \
                '/unicode.pf2'
            try:
                Command.run(['cp', unicode_font, boot_unicode_font])
            except Exception:
                raise KiwiBootLoaderGrubFontError('Unicode font %s not found' %
                                                  unicode_font)

        boot_theme_dir = os.sep.join(
            [self.root_dir, 'boot', self.boot_directory_name, 'themes'])
        Path.create(boot_theme_dir)
        if self.theme and not os.listdir(boot_theme_dir):
            theme_dir = self._find_grub_data(lookup_path + '/usr/share') + \
                '/themes/' + self.theme
            if os.path.exists(theme_dir):
                data = DataSync(theme_dir, boot_theme_dir)
                data.sync_data(options=['-z', '-a'])

        self._check_boot_theme_exists()