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.
main
Rohan Garg 10 years ago
parent 9c10b49802
commit eed387f7a4

@ -29,6 +29,9 @@ def modify_grub_default(partitions, root_mount_point, distributor):
use_splash = "" use_splash = ""
swap_uuid = "" 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): if os.path.exists(plymouth_bin):
use_splash = "splash" use_splash = "splash"
@ -58,10 +61,10 @@ def modify_grub_default(partitions, root_mount_point, distributor):
with open(default_grub, 'w') as grub_file: with open(default_grub, 'w') as grub_file:
grub_file.write("\n".join(lines) + "\n") grub_file.write("\n".join(lines) + "\n")
return None
def run(): def run():
partitions = libcalamares.globalstorage.value("partitions") partitions = libcalamares.globalstorage.value("partitions")
root_mount_point = libcalamares.globalstorage.value("rootMountPoint") root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
distributor = libcalamares.job.configuration["distributor"] distributor = libcalamares.job.configuration["distributor"]
modify_grub_default(partitions, root_mount_point, distributor) return modify_grub_default(partitions, root_mount_point, distributor)
return None

@ -123,6 +123,10 @@ class UnpackOperation:
fslist = "" fslist = ""
if entry.sourcefs == "squashfs": 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", fslist = subprocess.check_output(["unsquashfs",
"-l", "-l",
entry.source]) entry.source])

Loading…
Cancel
Save