[initcpiocfg] Code-shuffle

- put the system-information and -detection functions at top
  and the "do the actual work" things below
- don't mix the boolean do-we-use-this flags with the
  lists of files and modules which are the important
  parts of modify_mkinitcpio_conf
This commit is contained in:
Adriaan de Groot 2021-09-21 13:03:13 +02:00
parent 7c3c7c4ff7
commit 118e18ac60

View File

@ -28,6 +28,16 @@ def pretty_name():
return _("Configuring mkinitcpio.") return _("Configuring mkinitcpio.")
def detect_plymouth():
"""
Checks existence (runnability) of plymouth in the target system.
@return True if plymouth exists in the target, False otherwise
"""
# Used to only check existence of path /usr/bin/plymouth in target
return target_env_call(["sh", "-c", "which plymouth"]) == 0
class cpuinfo(object): class cpuinfo(object):
""" """
Object describing the current CPU's characteristics. It may be Object describing the current CPU's characteristics. It may be
@ -115,16 +125,6 @@ def write_mkinitcpio_lines(hooks, modules, files, root_mount_point):
mkinitcpio_file.write("\n".join(mklins) + "\n") mkinitcpio_file.write("\n".join(mklins) + "\n")
def detect_plymouth():
"""
Checks existence (runnability) of plymouth in the target system.
@return True if plymouth exists in the target, False otherwise
"""
# Used to only check existence of path /usr/bin/plymouth in target
return target_env_call(["sh", "-c", "which plymouth"]) == 0
def modify_mkinitcpio_conf(partitions, root_mount_point): def modify_mkinitcpio_conf(partitions, root_mount_point):
""" """
Modifies mkinitcpio.conf Modifies mkinitcpio.conf
@ -132,13 +132,13 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
:param partitions: :param partitions:
:param root_mount_point: :param root_mount_point:
""" """
hooks = ["base", "udev", "autodetect", "modconf", "block", "keyboard", "keymap"]
modules = []
files = []
swap_uuid = "" swap_uuid = ""
uses_btrfs = False uses_btrfs = False
uses_lvm2 = False uses_lvm2 = False
hooks = ["base", "udev", "autodetect", "modconf", "block", "keyboard",
"keymap"]
modules = []
files = []
encrypt_hook = False encrypt_hook = False
openswap_hook = False openswap_hook = False
unencrypted_separate_boot = False unencrypted_separate_boot = False