|
|
|
@ -30,6 +30,15 @@ import tempfile
|
|
|
|
|
|
|
|
|
|
from libcalamares import *
|
|
|
|
|
|
|
|
|
|
import gettext
|
|
|
|
|
_ = gettext.translation("calamares-python",
|
|
|
|
|
localedir=utils.gettext_path(),
|
|
|
|
|
languages=utils.gettext_languages(),
|
|
|
|
|
fallback=True).gettext
|
|
|
|
|
|
|
|
|
|
def pretty_name():
|
|
|
|
|
return _("Installing filesystems.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnpackEntry:
|
|
|
|
|
"""
|
|
|
|
@ -61,6 +70,8 @@ def list_excludes(destination):
|
|
|
|
|
"""
|
|
|
|
|
lst = []
|
|
|
|
|
extra_mounts = globalstorage.value("extraMounts")
|
|
|
|
|
if extra_mounts is None:
|
|
|
|
|
extra_mounts = []
|
|
|
|
|
|
|
|
|
|
for extra_mount in extra_mounts:
|
|
|
|
|
mount_point = extra_mount["mountPoint"]
|
|
|
|
@ -138,7 +149,8 @@ def file_copy(source, dest, progress_cb):
|
|
|
|
|
# https://bugzilla.redhat.com/show_bug.cgi?id=868755#c50
|
|
|
|
|
# for the same issue in Anaconda, which uses a similar workaround.
|
|
|
|
|
if process.returncode != 0 and process.returncode != 23:
|
|
|
|
|
return "rsync failed with error code {}.".format(process.returncode)
|
|
|
|
|
utils.warn("rsync failed with error code {}.".format(process.returncode))
|
|
|
|
|
return _("rsync failed with error code {}.").format(process.returncode)
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
@ -192,11 +204,10 @@ class UnpackOperation:
|
|
|
|
|
|
|
|
|
|
if entry.sourcefs == "squashfs":
|
|
|
|
|
if shutil.which("unsquashfs") is None:
|
|
|
|
|
msg = ("Failed to find unsquashfs, make sure you have "
|
|
|
|
|
"the squashfs-tools package installed")
|
|
|
|
|
print(msg)
|
|
|
|
|
return ("Failed to unpack image",
|
|
|
|
|
msg)
|
|
|
|
|
utils.warning("Failed to find unsquashfs")
|
|
|
|
|
|
|
|
|
|
return (_("Failed to unpack image \"{}\"").format(entry.source),
|
|
|
|
|
_("Failed to find unsquashfs, make sure you have the squashfs-tools package installed"))
|
|
|
|
|
|
|
|
|
|
fslist = subprocess.check_output(
|
|
|
|
|
["unsquashfs", "-l", entry.source]
|
|
|
|
@ -213,7 +224,7 @@ class UnpackOperation:
|
|
|
|
|
error_msg = self.unpack_image(entry, imgmountdir)
|
|
|
|
|
|
|
|
|
|
if error_msg:
|
|
|
|
|
return ("Failed to unpack image {}".format(entry.source),
|
|
|
|
|
return (_("Failed to unpack image \"{}\"").format(entry.source),
|
|
|
|
|
error_msg)
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
@ -261,55 +272,66 @@ class UnpackOperation:
|
|
|
|
|
subprocess.check_call(["umount", "-l", imgmountdir])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run():
|
|
|
|
|
def get_supported_filesystems():
|
|
|
|
|
"""
|
|
|
|
|
Unsquash filesystem.
|
|
|
|
|
Reads /proc/filesystems (the list of supported filesystems
|
|
|
|
|
for the current kernel) and returns a list of (names of)
|
|
|
|
|
those filesystems.
|
|
|
|
|
"""
|
|
|
|
|
PATH_PROCFS = '/proc/filesystems'
|
|
|
|
|
|
|
|
|
|
if os.path.isfile(PATH_PROCFS) and os.access(PATH_PROCFS, os.R_OK):
|
|
|
|
|
with open(PATH_PROCFS, 'r') as procfile:
|
|
|
|
|
filesystems = procfile.read()
|
|
|
|
|
filesystems = filesystems.replace(
|
|
|
|
|
"nodev", "").replace("\t", "").splitlines()
|
|
|
|
|
return filesystems
|
|
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run():
|
|
|
|
|
"""
|
|
|
|
|
Unsquash filesystem.
|
|
|
|
|
"""
|
|
|
|
|
root_mount_point = globalstorage.value("rootMountPoint")
|
|
|
|
|
|
|
|
|
|
if not root_mount_point:
|
|
|
|
|
return ("No mount point for root partition in globalstorage",
|
|
|
|
|
"globalstorage does not contain a \"rootMountPoint\" key, "
|
|
|
|
|
"doing nothing")
|
|
|
|
|
utils.warning("No mount point for root partition")
|
|
|
|
|
return (_("No mount point for root partition"),
|
|
|
|
|
_("globalstorage does not contain a \"rootMountPoint\" key, "
|
|
|
|
|
"doing nothing"))
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(root_mount_point):
|
|
|
|
|
return ("Bad mount point for root partition in globalstorage",
|
|
|
|
|
"globalstorage[\"rootMountPoint\"] is \"{}\", which does not "
|
|
|
|
|
"exist, doing nothing".format(root_mount_point))
|
|
|
|
|
utils.warning("Bad root mount point \"{}\"".format(root_mount_point))
|
|
|
|
|
return (_("Bad mount point for root partition"),
|
|
|
|
|
_("rootMountPoint is \"{}\", which does not "
|
|
|
|
|
"exist, doing nothing").format(root_mount_point))
|
|
|
|
|
|
|
|
|
|
supported_filesystems = get_supported_filesystems()
|
|
|
|
|
|
|
|
|
|
unpack = list()
|
|
|
|
|
|
|
|
|
|
for entry in job.configuration["unpack"]:
|
|
|
|
|
source = os.path.abspath(entry["source"])
|
|
|
|
|
|
|
|
|
|
sourcefs = entry["sourcefs"]
|
|
|
|
|
|
|
|
|
|
# Get supported filesystems
|
|
|
|
|
fs_is_supported = False
|
|
|
|
|
|
|
|
|
|
if os.path.isfile(PATH_PROCFS) and os.access(PATH_PROCFS, os.R_OK):
|
|
|
|
|
with open(PATH_PROCFS, 'r') as procfile:
|
|
|
|
|
filesystems = procfile.read()
|
|
|
|
|
filesystems = filesystems.replace(
|
|
|
|
|
"nodev", "").replace("\t", "").splitlines()
|
|
|
|
|
|
|
|
|
|
# Check if the source filesystem is supported
|
|
|
|
|
for fs in filesystems:
|
|
|
|
|
if fs == sourcefs:
|
|
|
|
|
fs_is_supported = True
|
|
|
|
|
|
|
|
|
|
if not fs_is_supported:
|
|
|
|
|
return "Bad filesystem", "sourcefs=\"{}\"".format(sourcefs)
|
|
|
|
|
if sourcefs not in supported_filesystems:
|
|
|
|
|
utils.warning("The filesystem for \"{}\" ({}) is not supported".format(source, sourcefs))
|
|
|
|
|
return (_("Bad unsquash configuration"),
|
|
|
|
|
_("The filesystem for \"{}\" ({}) is not supported").format(source, sourcefs))
|
|
|
|
|
|
|
|
|
|
destination = os.path.abspath(root_mount_point + entry["destination"])
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(source):
|
|
|
|
|
return "Bad source", "source=\"{}\"".format(source)
|
|
|
|
|
utils.warning("The source filesystem \"{}\" does not exist".format(source))
|
|
|
|
|
return (_("Bad unsquash configuration"),
|
|
|
|
|
_("The source filesystem \"{}\" does not exist").format(source))
|
|
|
|
|
|
|
|
|
|
if not os.path.isdir(destination):
|
|
|
|
|
return "Bad destination", "destination=\"{}\"".format(destination)
|
|
|
|
|
utils.warning(("The destination \"{}\" in the target system is not a directory").format(destination))
|
|
|
|
|
return (_("Bad unsquash configuration"),
|
|
|
|
|
_("The destination \"{}\" in the target system is not a directory").format(destination))
|
|
|
|
|
|
|
|
|
|
unpack.append(UnpackEntry(source, sourcefs, destination))
|
|
|
|
|
|
|
|
|
|