[partition] Move fs-type handling into Config
- the defaultFileSystemType interacts with availableFileSystemTypes so set them together.
This commit is contained in:
parent
f494440895
commit
67fafa04ac
@ -242,6 +242,61 @@ fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configu
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Config::fillConfigurationFSTypes(const QVariantMap& configurationMap)
|
||||
{
|
||||
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";
|
||||
fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral("ext4"), &fsType );
|
||||
}
|
||||
else
|
||||
{
|
||||
fsRealName = PartUtils::canonicalFilesystemName( fsName, &fsType );
|
||||
if ( fsType == FileSystem::Type::Unknown )
|
||||
{
|
||||
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsName << ") using ext4 instead";
|
||||
fsRealName = PartUtils::canonicalFilesystemName( QStringLiteral("ext4"), &fsType );
|
||||
}
|
||||
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 };
|
||||
}
|
||||
}
|
||||
|
||||
Q_ASSERT( !m_eraseFsTypes.isEmpty() );
|
||||
m_eraseFsTypeChoice = m_eraseFsTypes.first();
|
||||
Q_EMIT eraseModeFilesystemChanged( m_eraseFsTypeChoice );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
@ -266,23 +321,12 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
|
||||
m_allowManualPartitioning = CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true );
|
||||
|
||||
if ( configurationMap.contains( "availableFileSystemTypes" ) )
|
||||
{
|
||||
QStringList fsTypes = CalamaresUtils::getStringList( configurationMap, "availableFileSystemTypes" );
|
||||
|
||||
m_eraseFsTypes = fsTypes;
|
||||
if ( !fsTypes.empty() )
|
||||
{
|
||||
m_eraseFsTypeChoice = m_eraseFsTypes.first();
|
||||
Q_EMIT eraseModeFilesystemChanged( m_eraseFsTypeChoice );
|
||||
}
|
||||
}
|
||||
|
||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
m_requiredPartitionTableType = CalamaresUtils::getStringList( configurationMap, "requiredPartitionTableType" );
|
||||
gs->insert( "requiredPartitionTableType", m_requiredPartitionTableType );
|
||||
|
||||
fillGSConfigurationEFI(gs, configurationMap);
|
||||
fillConfigurationFSTypes( configurationMap );
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include "utils/NamedEnum.h"
|
||||
|
||||
#include <kpmcore/fs/filesystem.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
|
||||
@ -108,10 +110,22 @@ public:
|
||||
*/
|
||||
SwapChoice swapChoice() const { return m_swapChoice; }
|
||||
|
||||
/** @brief Get the list of configured FS types to use with *erase* mode
|
||||
*
|
||||
* This list is not empty.
|
||||
*/
|
||||
EraseFsTypesSet eraseFsTypes() const { return m_eraseFsTypes; }
|
||||
|
||||
/** @brief Currently-selected FS type for *erase* mode
|
||||
*/
|
||||
QString eraseFsType() const { return m_eraseFsTypeChoice; }
|
||||
|
||||
/** @brief Configured default FS type (for other modes than erase)
|
||||
*
|
||||
* This is not "Unknown" or "Unformatted"
|
||||
*/
|
||||
FileSystem::Type defaultFsType() const { return m_defaultFsType; }
|
||||
|
||||
///@brief Is manual partitioning allowed (not explicitly disabled in the config file)?
|
||||
bool allowManualPartitioning() const { return m_allowManualPartitioning; }
|
||||
|
||||
@ -128,9 +142,13 @@ Q_SIGNALS:
|
||||
void eraseModeFilesystemChanged( const QString& );
|
||||
|
||||
private:
|
||||
SwapChoiceSet m_swapChoices;
|
||||
/** @brief Handle FS-type configuration, for erase and default */
|
||||
void fillConfigurationFSTypes( const QVariantMap& configurationMap );
|
||||
EraseFsTypesSet m_eraseFsTypes;
|
||||
QString m_eraseFsTypeChoice;
|
||||
FileSystem::Type m_defaultFsType;
|
||||
|
||||
SwapChoiceSet m_swapChoices;
|
||||
SwapChoice m_initialSwapChoice = NoSwap;
|
||||
SwapChoice m_swapChoice = NoSwap;
|
||||
InstallChoice m_initialInstallChoice = NoChoice;
|
||||
|
@ -541,8 +541,6 @@ PartitionViewStep::onLeave()
|
||||
void
|
||||
PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
Logger::Once o;
|
||||
|
||||
m_config->setConfigurationMap( configurationMap );
|
||||
|
||||
// Copy the efiSystemPartition setting to the global storage. It is needed not only in
|
||||
@ -563,30 +561,6 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
gs->insert( "enableLuksAutomatedPartitioning",
|
||||
CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) );
|
||||
|
||||
// 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" );
|
||||
FileSystem::Type fsType;
|
||||
if ( fsName.isEmpty() )
|
||||
{
|
||||
cWarning() << "Partition-module setting *defaultFileSystemType* is missing, will use ext4";
|
||||
}
|
||||
QString fsRealName = PartUtils::canonicalFilesystemName( fsName, &fsType );
|
||||
if ( fsRealName == fsName )
|
||||
{
|
||||
cDebug() << o << "Partition-module setting *defaultFileSystemType*" << fsRealName;
|
||||
}
|
||||
else if ( fsType != FileSystem::Unknown )
|
||||
{
|
||||
cWarning() << "Partition-module setting *defaultFileSystemType* changed" << fsRealName;
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsName << ") using" << fsRealName
|
||||
<< "instead.";
|
||||
}
|
||||
gs->insert( "defaultFileSystemType", fsRealName );
|
||||
|
||||
QString partitionTableName = CalamaresUtils::getString( configurationMap, "defaultPartitionTableType" );
|
||||
if ( partitionTableName.isEmpty() )
|
||||
{
|
||||
@ -608,7 +582,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
||||
m_future->setFuture( future );
|
||||
|
||||
m_core->initLayout( fsType == FileSystem::Unknown ? FileSystem::Ext4 : fsType,
|
||||
m_core->initLayout( m_config->defaultFsType(),
|
||||
configurationMap.value( "partitionLayout" ).toList() );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user