[partition] Put EFI settings in a sub-map

This commit is contained in:
Adriaan de Groot 2023-11-09 23:31:17 +01:00
parent eb08c3facd
commit 85350e63ef
3 changed files with 80 additions and 38 deletions

View File

@ -274,38 +274,66 @@ fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configu
QString firmwareType( PartUtils::isEfiSystem() ? QStringLiteral( "efi" ) : QStringLiteral( "bios" ) ); QString firmwareType( PartUtils::isEfiSystem() ? QStringLiteral( "efi" ) : QStringLiteral( "bios" ) );
gs->insert( "firmwareType", firmwareType ); gs->insert( "firmwareType", firmwareType );
gs->insert( "efiSystemPartition", bool ok = false;
Calamares::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) ) ); auto efiConfiguration = Calamares::getSubMap( configurationMap, "efi", ok );
// Read and parse key efiSystemPartitionSize // Mount Point
if ( configurationMap.contains( "efiSystemPartitionSize" ) )
{ {
const QString sizeString = Calamares::getString( configurationMap, "efiSystemPartitionSize" ); const auto efiSystemPartition = Calamares::getString(
Calamares::Partition::PartitionSize part_size = Calamares::Partition::PartitionSize( sizeString ); efiConfiguration,
"mountPoint",
Calamares::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) ) );
// This specific GS key is also used by bootloader and grubcfg modules,
// as well as partition module internalls.
gs->insert( "efiSystemPartition", efiSystemPartition );
}
// Sizes
{
const auto efiRecommendedSize = Calamares::getString(
efiConfiguration, "recommendedSize", Calamares::getString( configurationMap, "efiSystemPartitionSize" ) );
if ( !efiRecommendedSize.isEmpty() )
{
Calamares::Partition::PartitionSize part_size = Calamares::Partition::PartitionSize( efiRecommendedSize );
if ( part_size.isValid() ) if ( part_size.isValid() )
{ {
// Insert once as string, once as a size-in-bytes;
// changes to these keys should be synchronized with PartUtils.cpp
gs->insert( PartUtils::efiFilesystemRecommendedSizeGSKey(), part_size.toBytes() ); gs->insert( PartUtils::efiFilesystemRecommendedSizeGSKey(), part_size.toBytes() );
// Assign long long int to long unsigned int to prevent compilation warning // Assign long long int to long unsigned int to prevent compilation warning,
// checks for loss-of-precision in the conversion.
auto byte_part_size = part_size.toBytes(); auto byte_part_size = part_size.toBytes();
if ( byte_part_size != PartUtils::efiFilesystemRecommendedSize() ) if ( byte_part_size != PartUtils::efiFilesystemRecommendedSize() )
{ {
cWarning() << "EFI partition size" << sizeString << "has been adjusted to" cWarning() << "EFI partition size" << efiRecommendedSize << "has been adjusted to"
<< PartUtils::efiFilesystemRecommendedSize() << "bytes"; << PartUtils::efiFilesystemRecommendedSize() << "bytes";
} }
} }
else else
{ {
cWarning() << "EFI partition size" << sizeString << "is invalid, ignored"; cWarning() << "EFI partition size" << efiRecommendedSize << "is invalid, ignored";
} }
} }
// Read and parse key efiSystemPartitionName const auto efiMinimumSize = Calamares::getString( efiConfiguration, "minimumSize" );
if ( configurationMap.contains( "efiSystemPartitionName" ) ) if ( !efiMinimumSize.isEmpty() )
{ {
gs->insert( "efiSystemPartitionName", Calamares::getString( configurationMap, "efiSystemPartitionName" ) ); Calamares::Partition::PartitionSize part_size = Calamares::Partition::PartitionSize( efiRecommendedSize );
if ( part_size.isValid() )
{
gs->insert( PartUtils::efiFilesystemMinimumSizeGSKey(), part_size.toBytes() );
}
}
}
// Name (label) of partition
{
const auto efiLabel = Calamares::getString(
efiConfiguration, "label", Calamares::getString( configurationMap, "efiSystemPartitionName" ) );
if ( !efiLabel.isEmpty() )
{
gs->insert( "efiSystemPartitionName", efiLabel );
}
} }
} }

View File

@ -1,18 +1,28 @@
# SPDX-FileCopyrightText: no # SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0 # SPDX-License-Identifier: CC0-1.0
# #
# Options for EFI system partition.
#
# - *mountPoint*
# This setting specifies the mount point of the EFI system partition. Some # This setting specifies the mount point of the EFI system partition. Some
# distributions (Fedora, Debian, Manjaro, etc.) use /boot/efi, others (KaOS, # distributions (Fedora, Debian, Manjaro, etc.) use /boot/efi, others (KaOS,
# etc.) use just /boot. # etc.) use just /boot.
# #
# Defaults to "/boot/efi", may be empty (but weird effects ensue) # Defaults to "/boot/efi", may be empty (but weird effects ensue)
efiSystemPartition: "/boot/efi" # - *recommendedSize*
# This optional setting specifies the size of the EFI system partition. # This optional setting specifies the size of the EFI system partition.
# If nothing is specified, the default size of 300MiB will be used. # If nothing is specified, the default size of 300MiB will be used.
# # When writing quantities here, M is treated as MiB, and if you really
# 300MiB is the default, and when writing quantities here, M is treated # want one-million (10^6) bytes, use MB.
# as MiB, and if you really want one-million (10^6) bytes, use MB. # - *minimumSize*
# This optional setting specifies the absolute minimum size of the EFI
# system partition. If nothing is specified, the *recommendedSize*
# is used instead.
# - *label*
# This optional setting specifies the name of the EFI system partition (see
# PARTLABEL; gpt only; requires KPMCore >= 4.2.0).
# If nothing is specified, the partition name is left unset.
# #
# Going below the *recommended* size is allowed, but the user will # Going below the *recommended* size is allowed, but the user will
# get a warning that it might not work. Going below the *minimum* # get a warning that it might not work. Going below the *minimum*
@ -22,15 +32,18 @@ efiSystemPartition: "/boot/efi"
# spec. If minimum is not specified, it defaults to the recommended # spec. If minimum is not specified, it defaults to the recommended
# size. Distro's that allow more user latitude can set the minimum lower. # size. Distro's that allow more user latitude can set the minimum lower.
efi: efi:
mountPoint: "/boot/efi"
recommendedSize: 300MiB recommendedSize: 300MiB
minimumSize: 32MiB minimumSize: 32MiB
label: "EFI"
# This is a deprecated alias of efi.recommendedSize # Deprecated alias of efi.mountPoint
# efiSystemPartition: "/boot/efi"
# Deprecated alias of efi.recommendedSize
# efiSystemPartitionSize: 300MiB # efiSystemPartitionSize: 300MiB
# This optional setting specifies the name of the EFI system partition (see # Deprecated alias of efi.label
# PARTLABEL; gpt only; requires KPMCore >= 4.2.0).
# If nothing is specified, the partition name is left unset.
# efiSystemPartitionName: EFI # efiSystemPartitionName: EFI
# In autogenerated partitioning, allow the user to select a swap size? # In autogenerated partitioning, allow the user to select a swap size?

View File

@ -7,15 +7,17 @@ $id: https://calamares.io/schemas/partition
additionalProperties: false additionalProperties: false
type: object type: object
properties: properties:
efiSystemPartition: { type: string } # Mount point efiSystemPartition: { type: string } # Deprecated alias of efi.mountPoint
efiSystemPartitionSize: { type: string } # Deprecated alias of efi.recommendedSize efiSystemPartitionSize: { type: string } # Deprecated alias of efi.recommendedSize
efiSystemPartitionName: { type: string } efiSystemPartitionName: { type: string } # Deprecated alias of efi.label
efi: efi:
type: object type: object
properties: properties:
recommendedSize: { type: string } recommendedSize: { type: string }
minimumSize: { type: string } minimumSize: { type: string }
label: { type: string }
mountPoint: { type: string }
additionalProperties: false additionalProperties: false
userSwapChoices: { type: array, items: { type: string, enum: [ none, reuse, small, suspend, file ] } } userSwapChoices: { type: array, items: { type: string, enum: [ none, reuse, small, suspend, file ] } }
@ -41,5 +43,4 @@ properties:
requiredStorage: { type: number } requiredStorage: { type: number }
required: required:
- efiSystemPartition
- userSwapChoices - userSwapChoices