make gummiboot kernel/distro agnostic
add hibernate option to .conf create a fallback entry in gummiboot menu re-add firmware to globalstorage, simplifies this module, will be needed to add more OS to gummi
This commit is contained in:
parent
54feddb330
commit
53da965bb1
@ -1,7 +1,10 @@
|
|||||||
---
|
---
|
||||||
# Gummiboot configuration files settings, set preffered distribution name and amount of time before
|
# Gummiboot configuration files settings, set preffered distribution name and amount of time before
|
||||||
# default selection boots
|
# default selection boots
|
||||||
distribution: KaOS
|
distribution: KaOS-kf5
|
||||||
|
kernel: /vmlinuz-linux
|
||||||
|
img: /initramfs-linux.img
|
||||||
|
fallback: /initramfs-linux-fallback.img
|
||||||
|
|
||||||
timeout: 10
|
timeout: 10
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@ def detect_firmware_type():
|
|||||||
else:
|
else:
|
||||||
fw_type = 'bios'
|
fw_type = 'bios'
|
||||||
|
|
||||||
|
libcalamares.globalstorage.insert("firmwareType", fw_type)
|
||||||
|
libcalamares.utils.debug("Firmware type: {!s}".format(fw_type))
|
||||||
|
|
||||||
|
|
||||||
def get_uuid():
|
def get_uuid():
|
||||||
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
@ -48,17 +51,24 @@ def get_uuid():
|
|||||||
return partition["uuid"]
|
return partition["uuid"]
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def create_conf(uuid, conf_path):
|
def create_conf(uuid, conf_path):
|
||||||
distribution = libcalamares.job.configuration["distribution"]
|
distribution = libcalamares.job.configuration["distribution"]
|
||||||
|
kernel = libcalamares.job.configuration["kernel"]
|
||||||
|
img = libcalamares.job.configuration["img"]
|
||||||
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
|
for partition in partitions:
|
||||||
|
if partition["fs"] == "linuxswap":
|
||||||
|
swap = partition["uuid"]
|
||||||
|
else:
|
||||||
|
swap = ""
|
||||||
lines = [
|
lines = [
|
||||||
'## This is just an exmaple config file.\n',
|
'## This is just an exmaple config file.\n',
|
||||||
'## Please edit the paths and kernel parameters according to your system.\n',
|
'## Please edit the paths and kernel parameters according to your system.\n',
|
||||||
'\n',
|
'\n',
|
||||||
'title %s GNU/Linux, with Linux core repo kernel\n' % distribution,
|
'title %s GNU/Linux, with Linux core repo kernel\n' % distribution,
|
||||||
'linux /vmlinuz-linux\n',
|
'linux %s\n' % kernel,
|
||||||
'initrd /initramfs-linux.img\n',
|
'initrd %s\n' % img,
|
||||||
'options root=UUID=%s quiet rw\n' % uuid,
|
'options root=UUID=%s quiet resume=%s rw\n' % (uuid, swap),
|
||||||
]
|
]
|
||||||
|
|
||||||
with open(conf_path, 'w') as f:
|
with open(conf_path, 'w') as f:
|
||||||
@ -66,6 +76,31 @@ def create_conf(uuid, conf_path):
|
|||||||
f.write(l)
|
f.write(l)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
def create_fallback(uuid, fallback_path):
|
||||||
|
distribution = libcalamares.job.configuration["distribution"]
|
||||||
|
kernel = libcalamares.job.configuration["kernel"]
|
||||||
|
fb_img = libcalamares.job.configuration["fallback"]
|
||||||
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
|
for partition in partitions:
|
||||||
|
if partition["fs"] == "linuxswap":
|
||||||
|
swap = partition["uuid"]
|
||||||
|
else:
|
||||||
|
swap = ""
|
||||||
|
lines = [
|
||||||
|
'## This is just an exmaple config file.\n',
|
||||||
|
'## Please edit the paths and kernel parameters according to your system.\n',
|
||||||
|
'\n',
|
||||||
|
'title %s GNU/Linux, with Linux fallback kernel\n' % distribution,
|
||||||
|
'linux %s\n' % kernel,
|
||||||
|
'initrd %s\n' % fb_img,
|
||||||
|
'options root=UUID=%s quiet resume=%s rw\n' % (uuid, swap),
|
||||||
|
]
|
||||||
|
|
||||||
|
with open(fallback_path, 'w') as f:
|
||||||
|
for l in lines:
|
||||||
|
f.write(l)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def create_loader(loader_path):
|
def create_loader(loader_path):
|
||||||
distribution = libcalamares.job.configuration["distribution"]
|
distribution = libcalamares.job.configuration["distribution"]
|
||||||
@ -88,11 +123,23 @@ def install_bootloader(boot_loader, fw_type):
|
|||||||
distribution = libcalamares.job.configuration["distribution"]
|
distribution = libcalamares.job.configuration["distribution"]
|
||||||
conf_path = os.path.join(
|
conf_path = os.path.join(
|
||||||
install_path, "boot", "loader", "entries", "%s.conf" % distribution)
|
install_path, "boot", "loader", "entries", "%s.conf" % distribution)
|
||||||
|
fallback_path = os.path.join(
|
||||||
|
install_path, "boot", "loader", "entries", "%s-fallback.conf" % distribution)
|
||||||
loader_path = os.path.join(
|
loader_path = os.path.join(
|
||||||
install_path, "boot", "loader", "loader.conf")
|
install_path, "boot", "loader", "loader.conf")
|
||||||
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
|
for partition in partitions:
|
||||||
|
if partition["mountPoint"] == "/boot":
|
||||||
|
print(partition["device"])
|
||||||
|
boot_device = partition["device"]
|
||||||
|
boot_p = boot_device[-1:]
|
||||||
|
device = boot_device[:-1]
|
||||||
|
print(device)
|
||||||
|
subprocess.call(['sgdisk', '--typecode=%s:EF00 %s' % (boot_p, device)])
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
["gummiboot", "--path=%s/boot" % install_path, "install"])
|
["gummiboot", "--path=%s/boot" % install_path, "install"])
|
||||||
create_conf(uuid, conf_path)
|
create_conf(uuid, conf_path)
|
||||||
|
create_fallback(uuid, fallback_path)
|
||||||
create_loader(loader_path)
|
create_loader(loader_path)
|
||||||
else:
|
else:
|
||||||
install_path = boot_loader["installPath"]
|
install_path = boot_loader["installPath"]
|
||||||
|
Loading…
Reference in New Issue
Block a user