kiwi-el8/kiwi/bootloader/install/__init__.py
Marcus Schäfer 319e78a707
Fixed selinux labels for boot files
When kiwi calls the bootloader config and installation modules
several files gets created as unlabeled_t because the labeling
happened earlier. This commit ensures that setfiles gets called
after BootLoaderConfig and/or BootLoaderInstall has done its
job. This Fixes #2568
2024-06-17 18:24:44 +02:00

68 lines
2.3 KiB
Python

# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved.
#
# This file is part of kiwi.
#
# kiwi is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# kiwi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with kiwi. If not, see <http://www.gnu.org/licenses/>
#
import importlib
from typing import Dict
from kiwi.xml_state import XMLState
from abc import (
ABCMeta,
abstractmethod
)
from ...exceptions import (
KiwiBootLoaderInstallSetupError
)
class BootLoaderInstall(metaclass=ABCMeta):
"""
**BootLoaderInstall Factory**
:param string name: bootloader name
:param string root_dir: root directory path name
:param object device_provider: instance of :class:`DeviceProvider`
:param dict custom_args: custom arguments dictionary
"""
@abstractmethod
def __init__(self) -> None:
return None # pragma: no cover
@staticmethod
def new(
name: str, xml_state: XMLState, root_dir: str, device_provider: object,
custom_args: Dict = None
):
name_map = {
'grub2': {'grub2': 'BootLoaderInstallGrub2'},
'grub2_s390x_emu': {'grub2': 'BootLoaderInstallGrub2'},
'systemd_boot': {'systemd_boot': 'BootLoaderInstallSystemdBoot'},
'zipl': {'zipl': 'BootLoaderInstallZipl'}
}
try:
(bootloader_namespace, bootloader_name) = \
list(name_map[name].items())[0]
bootloader_install = importlib.import_module(
'kiwi.bootloader.install.{}'.format(bootloader_namespace)
)
return bootloader_install.__dict__[bootloader_name](
xml_state, root_dir, device_provider, custom_args
)
except Exception:
raise KiwiBootLoaderInstallSetupError(
f'Support for {name} bootloader installation not implemented'
)