Write crypto_keyfile into mkinicpio configuration.
This commit is contained in:
parent
017aa1ec86
commit
108b83cfd7
@ -22,7 +22,6 @@
|
|||||||
import libcalamares
|
import libcalamares
|
||||||
import os
|
import os
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from libcalamares.utils import check_target_env_call
|
|
||||||
|
|
||||||
|
|
||||||
def cpuinfo():
|
def cpuinfo():
|
||||||
@ -36,8 +35,8 @@ def cpuinfo():
|
|||||||
|
|
||||||
nprocs = 0
|
nprocs = 0
|
||||||
|
|
||||||
with open('/proc/cpuinfo') as f:
|
with open('/proc/cpuinfo') as cpuinfo_file:
|
||||||
for line in f:
|
for line in cpuinfo_file:
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
# end of one processor
|
# end of one processor
|
||||||
cpu_info["proc{!s}".format(nprocs)] = procinfo
|
cpu_info["proc{!s}".format(nprocs)] = procinfo
|
||||||
@ -53,11 +52,12 @@ def cpuinfo():
|
|||||||
return cpu_info
|
return cpu_info
|
||||||
|
|
||||||
|
|
||||||
def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
def write_mkinitcpio_lines(hooks, modules, files, root_mount_point):
|
||||||
""" Set up mkinitcpio.conf.
|
""" Set up mkinitcpio.conf.
|
||||||
|
|
||||||
:param hooks:
|
:param hooks:
|
||||||
:param modules:
|
:param modules:
|
||||||
|
:param files:
|
||||||
:param root_mount_point:
|
:param root_mount_point:
|
||||||
"""
|
"""
|
||||||
with open("/etc/mkinitcpio.conf", "r") as mkinitcpio_file:
|
with open("/etc/mkinitcpio.conf", "r") as mkinitcpio_file:
|
||||||
@ -70,6 +70,9 @@ def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
|||||||
elif mklins[i].startswith("MODULES"):
|
elif mklins[i].startswith("MODULES"):
|
||||||
joined_modules = ' '.join(modules)
|
joined_modules = ' '.join(modules)
|
||||||
mklins[i] = "MODULES=\"{!s}\"".format(joined_modules)
|
mklins[i] = "MODULES=\"{!s}\"".format(joined_modules)
|
||||||
|
elif mklins[i].startswith("FILES"):
|
||||||
|
joined_files = ' '.join(files)
|
||||||
|
mklins[i] = "FILES=\"{!s}\"".format(joined_files)
|
||||||
|
|
||||||
path = os.path.join(root_mount_point, "etc/mkinitcpio.conf")
|
path = os.path.join(root_mount_point, "etc/mkinitcpio.conf")
|
||||||
|
|
||||||
@ -88,6 +91,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||||||
btrfs = ""
|
btrfs = ""
|
||||||
hooks = ["base", "udev", "autodetect", "modconf", "block", "keyboard", "keymap"]
|
hooks = ["base", "udev", "autodetect", "modconf", "block", "keyboard", "keymap"]
|
||||||
modules = []
|
modules = []
|
||||||
|
files = []
|
||||||
encrypt_hook = False
|
encrypt_hook = False
|
||||||
|
|
||||||
# It is important that the plymouth hook comes before any encrypt hook
|
# It is important that the plymouth hook comes before any encrypt hook
|
||||||
@ -107,6 +111,8 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||||||
|
|
||||||
if encrypt_hook:
|
if encrypt_hook:
|
||||||
hooks.append("encrypt")
|
hooks.append("encrypt")
|
||||||
|
if os.path.isfile(os.path.join(root_mount_point, "crypto_keyfile.bin")):
|
||||||
|
files.append("/crypto_keyfile.bin")
|
||||||
|
|
||||||
if swap_uuid is not "":
|
if swap_uuid is not "":
|
||||||
hooks.extend(["resume", "filesystems"])
|
hooks.extend(["resume", "filesystems"])
|
||||||
@ -120,7 +126,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||||||
else:
|
else:
|
||||||
hooks.append("fsck")
|
hooks.append("fsck")
|
||||||
|
|
||||||
set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point)
|
write_mkinitcpio_lines(hooks, modules, files, root_mount_point)
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
Loading…
Reference in New Issue
Block a user