2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2020-04-17 00:24:32 +02:00
|
|
|
*
|
2020-07-30 10:26:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2020-04-17 00:24:32 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2020-04-17 00:24:32 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Config.h"
|
2020-05-18 13:07:12 +02:00
|
|
|
|
2021-06-29 11:22:47 +02:00
|
|
|
#include "core/PartUtils.h"
|
2021-06-18 11:51:33 +02:00
|
|
|
|
2020-05-18 13:07:12 +02:00
|
|
|
#include "GlobalStorage.h"
|
|
|
|
#include "JobQueue.h"
|
2021-09-28 18:02:40 +02:00
|
|
|
#include "partition/PartitionSize.h"
|
2020-05-18 14:03:31 +02:00
|
|
|
#include "utils/Logger.h"
|
2020-05-18 13:07:12 +02:00
|
|
|
#include "utils/Variant.h"
|
|
|
|
|
|
|
|
Config::Config( QObject* parent )
|
|
|
|
: QObject( parent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-02 12:08:42 +02:00
|
|
|
const NamedEnumTable< Config::InstallChoice >&
|
|
|
|
Config::installChoiceNames()
|
|
|
|
{
|
2022-10-10 21:09:24 +02:00
|
|
|
// *INDENT-OFF*
|
|
|
|
// clang-format off
|
|
|
|
static const NamedEnumTable< InstallChoice > names {
|
|
|
|
{ QStringLiteral( "none" ), InstallChoice::NoChoice },
|
|
|
|
{ QStringLiteral( "nochoice" ), InstallChoice::NoChoice },
|
|
|
|
{ QStringLiteral( "alongside" ), InstallChoice::Alongside },
|
|
|
|
{ QStringLiteral( "erase" ), InstallChoice::Erase },
|
|
|
|
{ QStringLiteral( "replace" ), InstallChoice::Replace },
|
|
|
|
{ QStringLiteral( "manual" ), InstallChoice::Manual },
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
// *INDENT-ON*
|
|
|
|
|
2020-10-02 12:08:42 +02:00
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
const NamedEnumTable< Config::SwapChoice >&
|
|
|
|
Config::swapChoiceNames()
|
|
|
|
{
|
2022-10-10 21:09:24 +02:00
|
|
|
// *INDENT-OFF*
|
|
|
|
// clang-format off
|
|
|
|
static const NamedEnumTable< SwapChoice > names {
|
|
|
|
{ QStringLiteral( "none" ), SwapChoice::NoSwap },
|
|
|
|
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
|
|
|
|
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
|
|
|
|
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
|
|
|
|
{ QStringLiteral( "file" ), SwapChoice::SwapFile },
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
// *INDENT-ON*
|
2020-10-02 12:22:53 +02:00
|
|
|
|
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
2022-05-25 21:27:07 +02:00
|
|
|
const NamedEnumTable< Config::LuksGeneration >&
|
|
|
|
Config::luksGenerationNames()
|
|
|
|
{
|
2022-10-10 21:09:24 +02:00
|
|
|
// *INDENT-OFF*
|
|
|
|
// clang-format off
|
|
|
|
static const NamedEnumTable< LuksGeneration > names {
|
|
|
|
{ QStringLiteral( "luks1" ), LuksGeneration::Luks1 },
|
2022-10-10 21:12:28 +02:00
|
|
|
{ QStringLiteral( "luks" ), LuksGeneration::Luks1 },
|
2022-10-10 21:09:24 +02:00
|
|
|
{ QStringLiteral( "luks2" ), LuksGeneration::Luks2 },
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
// *INDENT-ON*
|
2022-05-25 21:27:07 +02:00
|
|
|
|
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString
|
|
|
|
Config::luksGenerationToFSName( Config::LuksGeneration luksGeneration )
|
|
|
|
{
|
|
|
|
// Convert luksGenerationChoice from partition.conf into its
|
|
|
|
// corresponding file system type from KPMCore.
|
|
|
|
switch ( luksGeneration )
|
|
|
|
{
|
|
|
|
case Config::LuksGeneration::Luks2:
|
|
|
|
return QStringLiteral( "luks2" );
|
|
|
|
case Config::LuksGeneration::Luks1:
|
|
|
|
return QStringLiteral( "luks" );
|
|
|
|
default:
|
|
|
|
cWarning() << "luksGeneration not supported, defaulting to \"luks\"";
|
|
|
|
return QStringLiteral( "luks" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
Config::SwapChoice
|
|
|
|
pickOne( const Config::SwapChoiceSet& s )
|
|
|
|
{
|
|
|
|
if ( s.count() == 0 )
|
|
|
|
{
|
|
|
|
return Config::SwapChoice::NoSwap;
|
|
|
|
}
|
|
|
|
if ( s.count() == 1 )
|
|
|
|
{
|
|
|
|
return *( s.begin() );
|
|
|
|
}
|
|
|
|
if ( s.contains( Config::SwapChoice::NoSwap ) )
|
|
|
|
{
|
|
|
|
return Config::SwapChoice::NoSwap;
|
|
|
|
}
|
|
|
|
// Here, count > 1 but NoSwap is not a member.
|
|
|
|
return *( s.begin() );
|
|
|
|
}
|
|
|
|
|
2020-10-02 12:08:42 +02:00
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
static Config::SwapChoiceSet
|
2020-05-18 14:03:31 +02:00
|
|
|
getSwapChoices( const QVariantMap& configurationMap )
|
|
|
|
{
|
|
|
|
// SWAP SETTINGS
|
|
|
|
//
|
|
|
|
// This is a bit convoluted because there's legacy settings to handle as well
|
|
|
|
// as the new-style list of choices, with mapping back-and-forth.
|
|
|
|
if ( configurationMap.contains( "userSwapChoices" )
|
|
|
|
&& ( configurationMap.contains( "ensureSuspendToDisk" ) || configurationMap.contains( "neverCreateSwap" ) ) )
|
|
|
|
{
|
|
|
|
cError() << "Partition-module configuration mixes old- and new-style swap settings.";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( configurationMap.contains( "ensureSuspendToDisk" ) )
|
|
|
|
{
|
|
|
|
cWarning() << "Partition-module setting *ensureSuspendToDisk* is deprecated.";
|
|
|
|
}
|
|
|
|
bool ensureSuspendToDisk = CalamaresUtils::getBool( configurationMap, "ensureSuspendToDisk", true );
|
|
|
|
|
|
|
|
if ( configurationMap.contains( "neverCreateSwap" ) )
|
|
|
|
{
|
|
|
|
cWarning() << "Partition-module setting *neverCreateSwap* is deprecated.";
|
|
|
|
}
|
|
|
|
bool neverCreateSwap = CalamaresUtils::getBool( configurationMap, "neverCreateSwap", false );
|
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
Config::SwapChoiceSet choices; // Available swap choices
|
2020-05-18 14:03:31 +02:00
|
|
|
if ( configurationMap.contains( "userSwapChoices" ) )
|
|
|
|
{
|
|
|
|
// We've already warned about overlapping settings with the
|
|
|
|
// legacy *ensureSuspendToDisk* and *neverCreateSwap*.
|
|
|
|
QStringList l = configurationMap[ "userSwapChoices" ].toStringList();
|
|
|
|
|
|
|
|
for ( const auto& item : l )
|
|
|
|
{
|
|
|
|
bool ok = false;
|
2020-10-02 12:22:53 +02:00
|
|
|
auto v = Config::swapChoiceNames().find( item, ok );
|
2020-05-18 14:03:31 +02:00
|
|
|
if ( ok )
|
|
|
|
{
|
|
|
|
choices.insert( v );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( choices.isEmpty() )
|
|
|
|
{
|
|
|
|
cWarning() << "Partition-module configuration for *userSwapChoices* is empty:" << l;
|
2020-10-02 12:22:53 +02:00
|
|
|
choices.insert( Config::SwapChoice::FullSwap );
|
2020-05-18 14:03:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// suspend if it's one of the possible choices; suppress swap only if it's
|
|
|
|
// the **only** choice available.
|
2020-10-02 12:22:53 +02:00
|
|
|
ensureSuspendToDisk = choices.contains( Config::SwapChoice::FullSwap );
|
|
|
|
neverCreateSwap = ( choices.count() == 1 ) && choices.contains( Config::SwapChoice::NoSwap );
|
2020-05-18 14:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Convert the legacy settings into a single setting for now.
|
|
|
|
if ( neverCreateSwap )
|
|
|
|
{
|
2020-10-02 12:22:53 +02:00
|
|
|
choices.insert( Config::SwapChoice::NoSwap );
|
2020-05-18 14:03:31 +02:00
|
|
|
}
|
|
|
|
else if ( ensureSuspendToDisk )
|
|
|
|
{
|
2020-10-02 12:22:53 +02:00
|
|
|
choices.insert( Config::SwapChoice::FullSwap );
|
2020-05-18 14:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-10-02 12:22:53 +02:00
|
|
|
choices.insert( Config::SwapChoice::SmallSwap );
|
2020-05-18 14:03:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not all are supported right now // FIXME
|
|
|
|
static const char unsupportedSetting[] = "Partition-module does not support *userSwapChoices* setting";
|
|
|
|
|
|
|
|
#define COMPLAIN_UNSUPPORTED( x ) \
|
|
|
|
if ( choices.contains( x ) ) \
|
|
|
|
{ \
|
2020-07-30 10:51:48 +02:00
|
|
|
bool bogus = false; \
|
2020-10-02 12:22:53 +02:00
|
|
|
cWarning() << unsupportedSetting << Config::swapChoiceNames().find( x, bogus ); \
|
2020-05-18 14:03:31 +02:00
|
|
|
choices.remove( x ); \
|
|
|
|
}
|
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
COMPLAIN_UNSUPPORTED( Config::SwapChoice::ReuseSwap )
|
2020-05-18 14:03:31 +02:00
|
|
|
#undef COMPLAIN_UNSUPPORTED
|
|
|
|
|
|
|
|
return choices;
|
|
|
|
}
|
|
|
|
|
2020-10-06 15:54:26 +02:00
|
|
|
void
|
|
|
|
updateGlobalStorage( Config::InstallChoice installChoice, Config::SwapChoice swapChoice )
|
|
|
|
{
|
|
|
|
auto* gs = Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
|
|
|
if ( gs )
|
|
|
|
{
|
|
|
|
QVariantMap m;
|
|
|
|
m.insert( "install", Config::installChoiceNames().find( installChoice ) );
|
|
|
|
m.insert( "swap", Config::swapChoiceNames().find( swapChoice ) );
|
|
|
|
gs->insert( "partitionChoices", m );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 14:00:49 +02:00
|
|
|
void
|
|
|
|
Config::setInstallChoice( int c )
|
|
|
|
{
|
2020-10-02 12:08:42 +02:00
|
|
|
if ( ( c < InstallChoice::NoChoice ) || ( c > InstallChoice::Manual ) )
|
2020-09-29 14:00:49 +02:00
|
|
|
{
|
|
|
|
cWarning() << "Invalid install choice (int)" << c;
|
2020-10-02 12:08:42 +02:00
|
|
|
c = InstallChoice::NoChoice;
|
2020-09-29 14:00:49 +02:00
|
|
|
}
|
2020-10-02 12:08:42 +02:00
|
|
|
setInstallChoice( static_cast< InstallChoice >( c ) );
|
2020-09-29 14:00:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2020-10-02 12:08:42 +02:00
|
|
|
Config::setInstallChoice( InstallChoice c )
|
2020-09-29 14:00:49 +02:00
|
|
|
{
|
|
|
|
if ( c != m_installChoice )
|
|
|
|
{
|
|
|
|
m_installChoice = c;
|
2021-06-18 11:31:53 +02:00
|
|
|
Q_EMIT installChoiceChanged( c );
|
2020-10-06 15:54:26 +02:00
|
|
|
::updateGlobalStorage( c, m_swapChoice );
|
2020-09-29 14:00:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 12:40:13 +02:00
|
|
|
void
|
|
|
|
Config::setSwapChoice( int c )
|
|
|
|
{
|
|
|
|
if ( ( c < SwapChoice::NoSwap ) || ( c > SwapChoice::SwapFile ) )
|
|
|
|
{
|
2020-11-11 18:44:41 +01:00
|
|
|
cWarning() << "Invalid swap choice (int)" << c;
|
2020-10-02 12:40:13 +02:00
|
|
|
c = SwapChoice::NoSwap;
|
|
|
|
}
|
|
|
|
setSwapChoice( static_cast< SwapChoice >( c ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Config::setSwapChoice( Config::SwapChoice c )
|
|
|
|
{
|
|
|
|
if ( c != m_swapChoice )
|
|
|
|
{
|
|
|
|
m_swapChoice = c;
|
2021-06-18 11:31:53 +02:00
|
|
|
Q_EMIT swapChoiceChanged( c );
|
2020-10-06 15:54:26 +02:00
|
|
|
::updateGlobalStorage( m_installChoice, c );
|
2020-10-02 12:40:13 +02:00
|
|
|
}
|
|
|
|
}
|
2020-09-29 14:00:49 +02:00
|
|
|
|
2021-03-31 18:15:02 +02:00
|
|
|
void
|
2021-06-18 11:23:27 +02:00
|
|
|
Config::setEraseFsTypeChoice( const QString& choice )
|
2021-03-31 18:15:02 +02:00
|
|
|
{
|
2021-06-18 11:51:33 +02:00
|
|
|
QString canonicalChoice = PartUtils::canonicalFilesystemName( choice, nullptr );
|
|
|
|
if ( canonicalChoice != m_eraseFsTypeChoice )
|
2021-06-18 11:23:27 +02:00
|
|
|
{
|
2021-06-18 11:51:33 +02:00
|
|
|
m_eraseFsTypeChoice = canonicalChoice;
|
|
|
|
Q_EMIT eraseModeFilesystemChanged( canonicalChoice );
|
2021-03-31 18:15:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-09 12:24:51 +01:00
|
|
|
bool
|
|
|
|
Config::acceptPartitionTableType( PartitionTable::TableType tableType ) const
|
|
|
|
{
|
|
|
|
return m_requiredPartitionTableType.empty()
|
|
|
|
|| m_requiredPartitionTableType.contains( PartitionTable::tableTypeToName( tableType ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-29 11:43:20 +02:00
|
|
|
static void
|
|
|
|
fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configurationMap )
|
|
|
|
{
|
|
|
|
// Set up firmwareType global storage entry. This is used, e.g. by the bootloader module.
|
|
|
|
QString firmwareType( PartUtils::isEfiSystem() ? QStringLiteral( "efi" ) : QStringLiteral( "bios" ) );
|
|
|
|
gs->insert( "firmwareType", firmwareType );
|
|
|
|
|
2021-07-12 15:42:54 +02:00
|
|
|
gs->insert( "efiSystemPartition",
|
|
|
|
CalamaresUtils::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) ) );
|
2021-06-29 11:43:20 +02:00
|
|
|
|
|
|
|
// Read and parse key efiSystemPartitionSize
|
|
|
|
if ( configurationMap.contains( "efiSystemPartitionSize" ) )
|
|
|
|
{
|
2021-09-28 18:02:40 +02:00
|
|
|
const QString sizeString = CalamaresUtils::getString( configurationMap, "efiSystemPartitionSize" );
|
2021-11-09 12:24:51 +01:00
|
|
|
CalamaresUtils::Partition::PartitionSize part_size = CalamaresUtils::Partition::PartitionSize( sizeString );
|
|
|
|
if ( part_size.isValid() )
|
2021-09-28 18:02:40 +02:00
|
|
|
{
|
2021-09-28 18:22:56 +02:00
|
|
|
// Insert once as string, once as a size-in-bytes;
|
|
|
|
// changes to these keys should be synchronized with PartUtils.cpp
|
2021-11-09 12:24:51 +01:00
|
|
|
gs->insert( "efiSystemPartitionSize", sizeString );
|
|
|
|
gs->insert( "efiSystemPartitionSize_i", part_size.toBytes() );
|
2021-09-28 18:02:40 +02:00
|
|
|
|
2022-05-16 15:08:11 +02:00
|
|
|
// Assign long long int to long unsigned int to prevent compilation warning
|
|
|
|
size_t unsigned_part_size = part_size.toBytes();
|
|
|
|
if ( unsigned_part_size != PartUtils::efiFilesystemMinimumSize() )
|
2021-09-28 18:02:40 +02:00
|
|
|
{
|
2021-11-09 12:24:51 +01:00
|
|
|
cWarning() << "EFI partition size" << sizeString << "has been adjusted to"
|
|
|
|
<< PartUtils::efiFilesystemMinimumSize() << "bytes";
|
2021-09-28 18:02:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cWarning() << "EFI partition size" << sizeString << "is invalid, ignored";
|
|
|
|
}
|
2021-06-29 11:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Read and parse key efiSystemPartitionName
|
|
|
|
if ( configurationMap.contains( "efiSystemPartitionName" ) )
|
|
|
|
{
|
|
|
|
gs->insert( "efiSystemPartitionName", CalamaresUtils::getString( configurationMap, "efiSystemPartitionName" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-29 14:47:09 +02:00
|
|
|
void
|
2021-07-12 15:42:54 +02:00
|
|
|
Config::fillConfigurationFSTypes( const QVariantMap& configurationMap )
|
2021-06-29 14:47:09 +02:00
|
|
|
{
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
|
|
|
|
|
|
|
|
|
|
|
// The defaultFileSystemType setting needs a bit more processing,
|
|
|
|
// as we want to cover various cases (such as different cases)
|
|
|
|
QString fsName = CalamaresUtils::getString( configurationMap, "defaultFileSystemType" );
|
|
|
|
QString fsRealName;
|
|
|
|
FileSystem::Type fsType = FileSystem::Type::Unknown;
|
|
|
|
if ( fsName.isEmpty() )
|
|
|
|
{
|
|
|
|
cWarning() << "Partition-module setting *defaultFileSystemType* is missing, will use ext4";
|
2021-07-12 15:42:54 +02:00
|
|
|
fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral( "ext4" ), &fsType );
|
2021-06-29 14:47:09 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fsRealName = PartUtils::canonicalFilesystemName( fsName, &fsType );
|
|
|
|
if ( fsType == FileSystem::Type::Unknown )
|
|
|
|
{
|
2021-07-12 15:42:54 +02:00
|
|
|
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsName
|
|
|
|
<< ") using ext4 instead";
|
|
|
|
fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral( "ext4" ), &fsType );
|
2021-06-29 14:47:09 +02:00
|
|
|
}
|
|
|
|
else if ( fsRealName != fsName )
|
|
|
|
{
|
|
|
|
cWarning() << "Partition-module setting *defaultFileSystemType* changed to" << fsRealName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Q_ASSERT( fsType != FileSystem::Type::Unknown );
|
|
|
|
m_defaultFsType = fsType;
|
|
|
|
gs->insert( "defaultFileSystemType", fsRealName );
|
|
|
|
|
|
|
|
// TODO: canonicalize the names? How is translation supposed to work?
|
|
|
|
m_eraseFsTypes = CalamaresUtils::getStringList( configurationMap, "availableFileSystemTypes" );
|
|
|
|
if ( !m_eraseFsTypes.contains( fsRealName ) )
|
|
|
|
{
|
|
|
|
if ( !m_eraseFsTypes.isEmpty() )
|
|
|
|
{
|
|
|
|
// Explicitly set, and doesn't include the default
|
|
|
|
cWarning() << "Partition-module *availableFileSystemTypes* does not contain the default" << fsRealName;
|
|
|
|
m_eraseFsTypes.prepend( fsRealName );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Not explicitly set, so it's empty; don't complain
|
|
|
|
m_eraseFsTypes = QStringList { fsRealName };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-25 21:27:07 +02:00
|
|
|
// Set LUKS file system based on luksGeneration provided, defaults to 'luks'.
|
|
|
|
bool nameFound = false;
|
|
|
|
Config::LuksGeneration luksGeneration
|
|
|
|
= luksGenerationNames().find( CalamaresUtils::getString( configurationMap, "luksGeneration" ), nameFound );
|
|
|
|
if ( !nameFound )
|
|
|
|
{
|
|
|
|
cWarning() << "Partition-module setting *luksGeneration* not found or invalid. Defaulting to luks1.";
|
|
|
|
luksGeneration = Config::LuksGeneration::Luks1;
|
|
|
|
}
|
|
|
|
m_luksFileSystemType = Config::luksGenerationToFSName( luksGeneration );
|
|
|
|
gs->insert( "luksFileSystemType", m_luksFileSystemType );
|
|
|
|
|
2021-06-29 14:47:09 +02:00
|
|
|
Q_ASSERT( !m_eraseFsTypes.isEmpty() );
|
2021-06-29 14:52:16 +02:00
|
|
|
Q_ASSERT( m_eraseFsTypes.contains( fsRealName ) );
|
|
|
|
m_eraseFsTypeChoice = fsRealName;
|
2021-06-29 14:47:09 +02:00
|
|
|
Q_EMIT eraseModeFilesystemChanged( m_eraseFsTypeChoice );
|
|
|
|
}
|
|
|
|
|
2020-05-18 13:07:12 +02:00
|
|
|
void
|
|
|
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
|
|
|
// Settings that overlap with the Welcome module
|
|
|
|
m_requiredStorageGiB = CalamaresUtils::getDouble( configurationMap, "requiredStorage", -1.0 );
|
2020-05-18 14:03:31 +02:00
|
|
|
m_swapChoices = getSwapChoices( configurationMap );
|
2020-07-30 11:36:59 +02:00
|
|
|
|
|
|
|
bool nameFound = false; // In the name table (ignored, falls back to first entry in table)
|
2020-10-02 12:22:53 +02:00
|
|
|
m_initialInstallChoice = installChoiceNames().find(
|
2020-08-22 01:19:58 +02:00
|
|
|
CalamaresUtils::getString( configurationMap, "initialPartitioningChoice" ), nameFound );
|
2020-09-29 14:00:49 +02:00
|
|
|
setInstallChoice( m_initialInstallChoice );
|
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
m_initialSwapChoice
|
|
|
|
= swapChoiceNames().find( CalamaresUtils::getString( configurationMap, "initialSwapChoice" ), nameFound );
|
2020-09-28 15:32:47 +02:00
|
|
|
if ( !m_swapChoices.contains( m_initialSwapChoice ) )
|
|
|
|
{
|
|
|
|
cWarning() << "Configuration for *initialSwapChoice* is not one of the *userSwapChoices*";
|
2022-01-31 23:15:04 +01:00
|
|
|
if ( nameFound )
|
|
|
|
{
|
|
|
|
cWarning() << Logger::SubEntry << "Choice" << swapChoiceNames().find( m_initialSwapChoice ) << "added.";
|
|
|
|
m_swapChoices.insert( m_initialSwapChoice );
|
|
|
|
}
|
2020-10-02 12:22:53 +02:00
|
|
|
m_initialSwapChoice = pickOne( m_swapChoices );
|
2020-09-28 15:32:47 +02:00
|
|
|
}
|
2020-10-02 12:40:13 +02:00
|
|
|
setSwapChoice( m_initialSwapChoice );
|
2020-10-02 13:04:12 +02:00
|
|
|
|
2021-06-29 13:21:46 +02:00
|
|
|
m_allowManualPartitioning = CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true );
|
2021-06-29 12:21:14 +02:00
|
|
|
m_requiredPartitionTableType = CalamaresUtils::getStringList( configurationMap, "requiredPartitionTableType" );
|
2021-06-29 11:43:20 +02:00
|
|
|
|
2021-11-09 12:24:51 +01:00
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
2021-07-12 15:42:54 +02:00
|
|
|
fillGSConfigurationEFI( gs, configurationMap );
|
2021-06-29 14:47:09 +02:00
|
|
|
fillConfigurationFSTypes( configurationMap );
|
2020-05-18 13:07:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2021-06-29 13:01:21 +02:00
|
|
|
Config::fillGSSecondaryConfiguration() const
|
2020-05-18 13:07:12 +02:00
|
|
|
{
|
|
|
|
// If there's no setting (e.g. from the welcome page) for required storage
|
|
|
|
// then use ours, if it was set.
|
|
|
|
auto* gs = Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
|
|
|
if ( m_requiredStorageGiB >= 0.0 && gs && !gs->contains( "requiredStorageGiB" ) )
|
|
|
|
{
|
|
|
|
gs->insert( "requiredStorageGiB", m_requiredStorageGiB );
|
|
|
|
}
|
|
|
|
}
|