From 148a29d506739c6038eefc18aa89e79ce4823f17 Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Tue, 19 Aug 2014 19:12:48 +0200 Subject: [PATCH 1/3] unpackfs: code dedup --- src/modules/unpackfs/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index 0124ef4bb..8e5da8c78 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -120,16 +120,17 @@ class UnpackOperation: self.mount_image(entry, imgmountdir) + fslist = "" + if entry.sourcefs == "squashfs": - sqfslist = subprocess.check_output(["unsquashfs", + fslist = subprocess.check_output(["unsquashfs", "-l", entry.source]) - entry.total = len(sqfslist.splitlines()) if entry.sourcefs == "ext4": fslist = subprocess.check_output(["find", imgmountdir, "-type", "f"]) - entry.total = len(fslist.splitlines()) + entry.total = len(fslist.splitlines()) self.report_progress() error_msg = self.unpack_image(entry, imgmountdir) From c97251d741a8d116e153f348d8437afd77098c9e Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Tue, 19 Aug 2014 19:52:26 +0200 Subject: [PATCH 2/3] unpackfs: check for supported filesystems Use /proc/filesystems to check if the system supportes the given source filesystem. --- src/modules/unpackfs/main.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index 8e5da8c78..91fcf350e 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -177,6 +177,8 @@ def run(): # sourcefs: "squashfs" # destination: "" + PATH_PROCFS = '/proc/filesystems' + root_mount_point = globalstorage.value("rootMountPoint") if not root_mount_point: return ("No mount point for root partition in globalstorage", @@ -192,14 +194,31 @@ def run(): source = os.path.abspath(entry["source"]) sourcefs = entry["sourcefs"] - if sourcefs not in ["ext4", "squashfs"]: + + # Get supported filesystems + fs_is_supported = False + + if os.path.isfile(PATH_PROCFS) and os.access(PATH_PROCFS, os.R_OK): + procfile = open(PATH_PROCFS, 'r') + filesystems = procfile.read() + procfile.close + + filesystems = filesystems.replace("nodev", "") + filesystems = filesystems.replace("\t", "") + filesystems = filesystems.splitlines() + + # Check if the source filesystem is supported + for fs in filesystems: + if fs == sourcefs: + fs_is_supported = True + + if fs_is_supported == False: return "Bad filesystem", "sourcefs=\"{}\"".format(sourcefs) destination = os.path.abspath(root_mount_point + entry["destination"]) if not os.path.isfile(source): return ("Bad source", "source=\"{}\"".format(source)) - # Add test for supported filesystems if not os.path.isdir(destination): return ("Bad destination", "destination=\"{}\"".format(destination)) From 38f32bfd568e9abcd2ed148c9544f212aa3f6214 Mon Sep 17 00:00:00 2001 From: Daniel Hillenbrand Date: Tue, 19 Aug 2014 20:39:26 +0200 Subject: [PATCH 3/3] locale: make sure /etc/localtime doesn't exist If /etc/localtime exists in source image, creating a new symlink will fail and prevent the installer from doing it's job. --- src/modules/locale/SetTimezoneJob.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/locale/SetTimezoneJob.cpp b/src/modules/locale/SetTimezoneJob.cpp index 5ae908446..a4529f44d 100644 --- a/src/modules/locale/SetTimezoneJob.cpp +++ b/src/modules/locale/SetTimezoneJob.cpp @@ -45,6 +45,7 @@ SetTimezoneJob::prettyName() const Calamares::JobResult SetTimezoneJob::exec() { + QString localtimeSlink( "/etc/localtime" ); QString zoneinfoPath( "/usr/share/zoneinfo" ); zoneinfoPath.append( QDir::separator() + m_region ); zoneinfoPath.append( QDir::separator() + m_zone ); @@ -55,10 +56,15 @@ SetTimezoneJob::exec() return Calamares::JobResult::error( tr( "Cannot access selected timezone path." ), tr( "Bad path: %1" ).arg( zoneFile.absolutePath() ) ); + // Make sure /etc/localtime doesn't exist, otherwise symlinking will fail + CalamaresUtils::chrootCall( { "rm", + "-f", + localtimeSlink } ); + int ec = CalamaresUtils::chrootCall( { "ln", "-s", zoneinfoPath, - "/etc/localtime" } ); + localtimeSlink } ); if ( ec ) return Calamares::JobResult::error( tr( "Cannot set timezone." ), tr( "Link creation failed, target: %1; link name: %2" )