Merge pull request #1560 from gportay/partition-mount-make-mountPoint-and-filesystem-optionals

[partition,mount] Make mountPoint and filesystem optionals
This commit is contained in:
Adriaan de Groot 2020-11-02 23:25:53 +01:00 committed by GitHub
commit 2516f18d1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 51 deletions

View File

@ -7,6 +7,7 @@
# SPDX-FileCopyrightText: 2017 Alf Gaida <agaida@siduction.org>
# SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
# SPDX-FileCopyrightText: 2019 Kevin Kofler <kevin.kofler@chello.at>
# SPDX-FileCopyrightText: 2019-2020 Collabora Ltd
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Calamares is Free Software: see the License-Identifier above.
@ -38,6 +39,9 @@ def mount_partition(root_mount_point, partition, partitions):
# Create mount point with `+` rather than `os.path.join()` because
# `partition["mountPoint"]` starts with a '/'.
raw_mount_point = partition["mountPoint"]
if not raw_mount_point:
return
mount_point = root_mount_point + raw_mount_point
# Ensure that the created directory has the correct SELinux context on
@ -52,26 +56,22 @@ def mount_partition(root_mount_point, partition, partitions):
raise
fstype = partition.get("fs", "").lower()
if not fstype or fstype == "unformatted":
return
if fstype == "fat16" or fstype == "fat32":
fstype = "vfat"
if "luksMapperName" in partition:
libcalamares.utils.debug(
"about to mount {!s}".format(partition["luksMapperName"]))
libcalamares.utils.mount(
"/dev/mapper/{!s}".format(partition["luksMapperName"]),
mount_point,
fstype,
partition.get("options", ""),
)
device = partition["device"]
else:
libcalamares.utils.mount(partition["device"],
mount_point,
fstype,
partition.get("options", ""),
)
if "luksMapperName" in partition:
device = os.path.join("/dev/mapper", partition["luksMapperName"])
if libcalamares.utils.mount(device,
mount_point,
fstype,
partition.get("options", "")) != 0:
libcalamares.utils.warning("Cannot mount {}".format(device))
# If the root partition is btrfs, we create a subvolume "@"
# for the root mount point.
@ -96,37 +96,23 @@ def mount_partition(root_mount_point, partition, partitions):
subprocess.check_call(["umount", "-v", root_mount_point])
device = partition["device"]
if "luksMapperName" in partition:
libcalamares.utils.mount(
"/dev/mapper/{!s}".format(partition["luksMapperName"]),
mount_point,
fstype,
",".join(
["subvol=@", partition.get("options", "")]),
)
if not has_home_mount_point:
libcalamares.utils.mount(
"/dev/mapper/{!s}".format(partition["luksMapperName"]),
root_mount_point + "/home",
fstype,
",".join(
["subvol=@home", partition.get("options", "")]),
)
else:
libcalamares.utils.mount(
partition["device"],
mount_point,
fstype,
",".join(["subvol=@", partition.get("options", "")]),
)
if not has_home_mount_point:
libcalamares.utils.mount(
partition["device"],
root_mount_point + "/home",
fstype,
",".join(
["subvol=@home", partition.get("options", "")]),
)
device = os.path.join("/dev/mapper", partition["luksMapperName"])
if libcalamares.utils.mount(device,
mount_point,
fstype,
",".join(["subvol=@", partition.get("options", "")])) != 0:
libcalamares.utils.warning("Cannot mount {}".format(device))
if not has_home_mount_point:
if libcalamares.utils.mount(device,
root_mount_point + "/home",
fstype,
",".join(["subvol=@home", partition.get("options", "")])) != 0:
libcalamares.utils.warning("Cannot mount {}".format(device))
def run():

View File

@ -103,8 +103,7 @@ PartitionLayout::init( FileSystem::Type defaultFsType, const QVariantList& confi
{
QVariantMap pentry = r.toMap();
if ( !pentry.contains( "name" ) || !pentry.contains( "mountPoint" ) || !pentry.contains( "filesystem" )
|| !pentry.contains( "size" ) )
if ( !pentry.contains( "name" ) || !pentry.contains( "size" ) )
{
cError() << "Partition layout entry #" << config.indexOf( r )
<< "lacks mandatory attributes, switching to default layout.";
@ -117,7 +116,7 @@ PartitionLayout::init( FileSystem::Type defaultFsType, const QVariantList& confi
CalamaresUtils::getString( pentry, "type" ),
CalamaresUtils::getUnsignedInteger( pentry, "attributes", 0 ),
CalamaresUtils::getString( pentry, "mountPoint" ),
CalamaresUtils::getString( pentry, "filesystem" ),
CalamaresUtils::getString( pentry, "filesystem", "unformatted" ),
CalamaresUtils::getSubMap( pentry, "features", ok ),
CalamaresUtils::getString( pentry, "size", QStringLiteral( "0" ) ),
CalamaresUtils::getString( pentry, "minSize", QStringLiteral( "0" ) ),

View File

@ -153,7 +153,7 @@ FillGlobalStorageJob::prettyDescription() const
QString path = partitionMap.value( "device" ).toString();
QString mountPoint = partitionMap.value( "mountPoint" ).toString();
QString fsType = partitionMap.value( "fs" ).toString();
if ( mountPoint.isEmpty() || fsType.isEmpty() )
if ( mountPoint.isEmpty() || fsType.isEmpty() || fsType == QString( "unformatted" ) )
{
continue;
}

View File

@ -207,8 +207,8 @@ defaultFileSystemType: "ext4"
# - uuid: partition uuid (optional parameter; gpt only; requires KPMCore >= 4.2.0)
# - type: partition type (optional parameter; gpt only; requires KPMCore >= 4.2.0)
# - attributes: partition attributes (optional parameter; gpt only; requires KPMCore >= 4.2.0)
# - filesystem: filesystem type
# - mountPoint: partition mount point
# - filesystem: filesystem type (optional parameter; fs not created if "unformatted" or unset)
# - mountPoint: partition mount point (optional parameter; not mounted if unset)
# - size: partition size in bytes (append 'K', 'M' or 'G' for KiB, MiB or GiB)
# or
# % of the available drive space if a '%' is appended to the value