From eed387f7a4e90d7f5574f99ce36587cca3a65588 Mon Sep 17 00:00:00 2001 From: Rohan Garg Date: Tue, 14 Oct 2014 15:09:38 +0200 Subject: [PATCH] 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. --- src/modules/grubcfg/main.py | 7 +++++-- src/modules/unpackfs/main.py | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/grubcfg/main.py b/src/modules/grubcfg/main.py index 734b94b75..70362a916 100644 --- a/src/modules/grubcfg/main.py +++ b/src/modules/grubcfg/main.py @@ -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) diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index 91fcf350e..e54bd4ca6 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -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])