Merge branch 'fix-swap-ui' of github.com:calamares/calamares into fix-swap-ui

This commit is contained in:
Adriaan de Groot 2018-10-08 16:49:18 -04:00
commit f7cc571635
2 changed files with 59 additions and 89 deletions

View file

@ -476,86 +476,47 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
// Copy the efiSystemPartition setting to the global storage. It is needed not only in // Copy the efiSystemPartition setting to the global storage. It is needed not only in
// the EraseDiskPage, but also in the bootloader configuration modules (grub, bootloader). // the EraseDiskPage, but also in the bootloader configuration modules (grub, bootloader).
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage(); Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
if ( configurationMap.contains( "efiSystemPartition" ) && QString efiSP = CalamaresUtils::getString( configurationMap, "efiSystemPartition" );
configurationMap.value( "efiSystemPartition" ).type() == QVariant::String && if ( efiSP.isEmpty() )
!configurationMap.value( "efiSystemPartition" ).toString().isEmpty() ) efiSP = QStringLiteral( "/boot/efi" );
{ gs->insert( "efiSystemPartition", efiSP );
gs->insert( "efiSystemPartition", configurationMap.value( "efiSystemPartition" ).toString() );
}
else
{
gs->insert( "efiSystemPartition", QStringLiteral( "/boot/efi" ) );
}
if ( configurationMap.contains( "ensureSuspendToDisk" ) && // SWAP SETTINGS
configurationMap.value( "ensureSuspendToDisk" ).type() == QVariant::Bool ) //
{ // This is a bit convoluted because there's legacy settings to handle as well
gs->insert( "ensureSuspendToDisk", configurationMap.value( "ensureSuspendToDisk" ).toBool() ); // as the new-style list of choices, with mapping back-and-forth.
} if ( configurationMap.contains( "userSwapChoices" ) &&
else ( configurationMap.contains( "ensureSuspendToDisk" ) || configurationMap.contains( "neverCreateSwap" ) ) )
{ cError() << "Partition-module configuration mixes old- and new-style swap settings.";
gs->insert( "ensureSuspendToDisk", true );
}
if ( configurationMap.contains( "neverCreateSwap" ) && if ( configurationMap.contains( "ensureSuspendToDisk" ) )
configurationMap.value( "neverCreateSwap" ).type() == QVariant::Bool ) cWarning() << "Partition-module setting *ensureSuspendToDisk* is deprecated.";
{ bool ensureSuspendToDisk = CalamaresUtils::getBool( configurationMap, "ensureSuspendToDisk", true );
gs->insert( "neverCreateSwap", configurationMap.value( "neverCreateSwap" ).toBool() );
}
else
{
gs->insert( "neverCreateSwap", false );
}
if ( configurationMap.contains( "drawNestedPartitions" ) && if ( configurationMap.contains( "neverCreateSwap" ) )
configurationMap.value( "drawNestedPartitions" ).type() == QVariant::Bool ) cWarning() << "Partition-module setting *neverCreateSwap* is deprecated.";
{ bool neverCreateSwap = CalamaresUtils::getBool( configurationMap, "neverCreateSwap", false );
gs->insert( "drawNestedPartitions",
configurationMap.value( "drawNestedPartitions", false ).toBool() );
}
else
{
gs->insert( "drawNestedPartitions", false );
}
if ( configurationMap.contains( "alwaysShowPartitionLabels" ) && // These gs settings seem to be unused (in upstream Calamares) outside of
configurationMap.value( "alwaysShowPartitionLabels" ).type() == QVariant::Bool ) // the partition module itself.
{ gs->insert( "ensureSuspendToDisk", ensureSuspendToDisk );
gs->insert( "alwaysShowPartitionLabels", gs->insert( "neverCreateSwap", neverCreateSwap );
configurationMap.value( "alwaysShowPartitionLabels", true ).toBool() );
}
else
{
gs->insert( "alwaysShowPartitionLabels", true );
}
if ( configurationMap.contains( "defaultFileSystemType" ) && // OTHER SETTINGS
configurationMap.value( "defaultFileSystemType" ).type() == QVariant::String && //
!configurationMap.value( "defaultFileSystemType" ).toString().isEmpty() ) gs->insert( "drawNestedPartitions", CalamaresUtils::getBool( configurationMap, "drawNestedPartitions", false ) );
{ gs->insert( "alwaysShowPartitionLabels", CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) );
QString typeString = configurationMap.value( "defaultFileSystemType" ).toString(); gs->insert( "enableLuksAutomatedPartitioning", CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) );
gs->insert( "defaultFileSystemType", typeString );
if ( FileSystem::typeForName( typeString ) == FileSystem::Unknown )
{
cWarning() << "bad default filesystem configuration for partition module. Reverting to ext4 as default.";
gs->insert( "defaultFileSystemType", "ext4" );
}
}
else
{
gs->insert( "defaultFileSystemType", QStringLiteral( "ext4" ) );
}
if ( configurationMap.contains( "enableLuksAutomatedPartitioning" ) && QString defaultFS = CalamaresUtils::getString( configurationMap, "defaultFileSystemType" );
configurationMap.value( "enableLuksAutomatedPartitioning" ).type() == QVariant::Bool ) if ( defaultFS.isEmpty() )
defaultFS = QStringLiteral( "ext4" );
if ( FileSystem::typeForName( defaultFS ) == FileSystem::Unknown )
{ {
gs->insert( "enableLuksAutomatedPartitioning", cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << defaultFS << ") using ext4.";
configurationMap.value( "enableLuksAutomatedPartitioning" ).toBool() ); defaultFS = QStringLiteral( "ext4" );
}
else
{
gs->insert( "enableLuksAutomatedPartitioning", true );
} }
gs->insert( "defaultFileSystemType", defaultFS );
// Now that we have the config, we load the PartitionCoreModule in the background // Now that we have the config, we load the PartitionCoreModule in the background

View file

@ -3,28 +3,37 @@
# etc.) use just /boot. # etc.) use just /boot.
efiSystemPartition: "/boot/efi" efiSystemPartition: "/boot/efi"
# Make sure an autogenerated swap partition is big enough for hibernation in # In autogenerated partitioning, allow the user to select a swap size?
# automated partitioning modes. Swap can be disabled through *neverCreateSwap*. # If there is exactly one choice, no UI is presented, and the user
# cannot make a choice -- this setting is used. If there is more than
# one choice, a UI is presented.
# #
# - *neverCreateSwap* is true: no swap is created # Legacy settings *neverCreateSwap* and *ensureSuspendToDisk* correspond
# - *neverCreateSwap* is false (the default): swap is created, as follows: # to values of *userSwapChoices* as follows:
# - *ensureSuspendToDisk* is true (default): Swap is always at least total # - *neverCreateSwap* is true, means [none]
# memory size, and up to 4GiB RAM follows the rule-of-thumb 2 * memory; # - *neverCreateSwap* is false, *ensureSuspendToDisk* is false, [small]
# - *neverCreateSwap* is false, *ensureSuspendToDisk* is true, [suspend]
#
# Autogenerated swap sizes are as follows:
# - *suspend*: Swap is always at least total memory size,
# and up to 4GiB RAM follows the rule-of-thumb 2 * memory;
# from 4GiB to 8 GiB it stays steady at 8GiB, and over 8 GiB memory # from 4GiB to 8 GiB it stays steady at 8GiB, and over 8 GiB memory
# swap is the size of main memory. # swap is the size of main memory.
# - *ensureSuspendToDisk* is false: Follows the rules above, but Swap is at # - *small*: Follows the rules above, but Swap is at
# most 8GiB, and no more than 10% of available disk. # most 8GiB, and no more than 10% of available disk.
# In both cases, a fudge factor (usually 10% extra) is applied so that there # In both cases, a fudge factor (usually 10% extra) is applied so that there
# is some space for administrative overhead (e.g. 8 GiB swap will allocate # is some space for administrative overhead (e.g. 8 GiB swap will allocate
# 8.8GiB on disk in the end). # 8.8GiB on disk in the end).
# userSwapChoices:
# Default is true. - none # Create no swap, use no swap
ensureSuspendToDisk: true # - reuse # Re-use existing swap, but don't create any
- small # Up to 4GB
- suspend # At least main memory size
# - file # To swap file instead of partition (unsupported right now)
# Never create swap partitions in automated partitioning modes. # LEGACY SETTINGS (these will generate a warning)
# If this is true, ensureSuspendToDisk is ignored. # ensureSuspendToDisk: true
# Default is false. # neverCreateSwap: false
neverCreateSwap: false
# Correctly draw nested (e.g. logical) partitions as such. # Correctly draw nested (e.g. logical) partitions as such.
drawNestedPartitions: false drawNestedPartitions: false