Make sure to check things exist before actually modifying them
This fixes crashes when a system does not have squashfs-tools or a grub dir does not exist.
This commit is contained in:
parent
9c10b49802
commit
eed387f7a4
@ -29,6 +29,9 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
||||
use_splash = ""
|
||||
swap_uuid = ""
|
||||
|
||||
if not os.path.exists(default_dir):
|
||||
return ("Directory does not exist", "The directory {} does not exist on
|
||||
the target".format(default_dir))
|
||||
if os.path.exists(plymouth_bin):
|
||||
use_splash = "splash"
|
||||
|
||||
@ -58,10 +61,10 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
||||
with open(default_grub, 'w') as grub_file:
|
||||
grub_file.write("\n".join(lines) + "\n")
|
||||
|
||||
return None
|
||||
|
||||
def run():
|
||||
partitions = libcalamares.globalstorage.value("partitions")
|
||||
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||
distributor = libcalamares.job.configuration["distributor"]
|
||||
modify_grub_default(partitions, root_mount_point, distributor)
|
||||
return None
|
||||
return modify_grub_default(partitions, root_mount_point, distributor)
|
||||
|
@ -123,6 +123,10 @@ class UnpackOperation:
|
||||
fslist = ""
|
||||
|
||||
if entry.sourcefs == "squashfs":
|
||||
if shutil.which("unsquashfs") == None:
|
||||
return ("Failed to unpack image", "Failed to find unsquashfs, make sure you have
|
||||
the squashfs-tools package installed")
|
||||
|
||||
fslist = subprocess.check_output(["unsquashfs",
|
||||
"-l",
|
||||
entry.source])
|
||||
|
Loading…
Reference in New Issue
Block a user