Merge pull request #1094 from a-wai/fix-default-fs
[partition] Fix default fs FIXES: #1093
This commit is contained in:
commit
be5abf08dc
@ -408,6 +408,56 @@ isEfiBootable( const Partition* candidate )
|
|||||||
flags.testFlag( PartitionTable::FlagBoot );
|
flags.testFlag( PartitionTable::FlagBoot );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
findFS( QString fsName, FileSystem::Type* fsType )
|
||||||
|
{
|
||||||
|
QStringList fsLanguage { QLatin1Literal( "C" ) }; // Required language list to turn off localization
|
||||||
|
if ( fsName.isEmpty() )
|
||||||
|
fsName = QStringLiteral( "ext4" );
|
||||||
|
|
||||||
|
FileSystem::Type tmpType = FileSystem::typeForName( fsName, fsLanguage );
|
||||||
|
if ( tmpType != FileSystem::Unknown )
|
||||||
|
{
|
||||||
|
cDebug() << "Found filesystem" << fsName;
|
||||||
|
if ( fsType )
|
||||||
|
*fsType = tmpType;
|
||||||
|
return fsName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Second pass: try case-insensitive
|
||||||
|
const auto fstypes = FileSystem::types();
|
||||||
|
for ( FileSystem::Type t : fstypes )
|
||||||
|
{
|
||||||
|
if ( 0 == QString::compare( fsName, FileSystem::nameForType( t, fsLanguage ), Qt::CaseInsensitive ) )
|
||||||
|
{
|
||||||
|
QString fsRealName = FileSystem::nameForType( t, fsLanguage );
|
||||||
|
cDebug() << "Filesystem name" << fsName << "translated to" << fsRealName;
|
||||||
|
if ( fsType )
|
||||||
|
*fsType = t;
|
||||||
|
return fsRealName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cDebug() << "Filesystem" << fsName << "not found, using ext4";
|
||||||
|
fsName = QStringLiteral( "ext4" );
|
||||||
|
// fsType can be used to check whether fsName was a valid filesystem.
|
||||||
|
if (fsType)
|
||||||
|
*fsType = FileSystem::Unknown;
|
||||||
|
#ifdef DEBUG_FILESYSTEMS
|
||||||
|
// This bit is for distro's debugging their settings, and shows
|
||||||
|
// all the strings that KPMCore is matching against for FS type.
|
||||||
|
{
|
||||||
|
Logger::CDebug d;
|
||||||
|
using TR = Logger::DebugRow< int, QString >;
|
||||||
|
const auto fstypes = FileSystem::types();
|
||||||
|
d << "Available types (" << fstypes.count() << ')';
|
||||||
|
for ( FileSystem::Type t : fstypes )
|
||||||
|
d << TR( static_cast<int>( t ), FileSystem::nameForType( t, fsLanguage ) );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return fsName;
|
||||||
|
}
|
||||||
|
|
||||||
} // nmamespace PartUtils
|
} // nmamespace PartUtils
|
||||||
|
|
||||||
/* Implementation of methods for FstabEntry, from OsproberEntry.h */
|
/* Implementation of methods for FstabEntry, from OsproberEntry.h */
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
|
|
||||||
#include "OsproberEntry.h"
|
#include "OsproberEntry.h"
|
||||||
|
|
||||||
|
// KPMcore
|
||||||
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
|
||||||
|
// Qt
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class PartitionCoreModule;
|
class PartitionCoreModule;
|
||||||
@ -73,6 +77,15 @@ bool isEfiSystem();
|
|||||||
* the partition table layout, this may mean different flags.
|
* the partition table layout, this may mean different flags.
|
||||||
*/
|
*/
|
||||||
bool isEfiBootable( const Partition* candidate );
|
bool isEfiBootable( const Partition* candidate );
|
||||||
|
|
||||||
|
/** @brief translate @p fsName into a recognized name and type
|
||||||
|
*
|
||||||
|
* Makes several attempts to translate the string into a
|
||||||
|
* name that KPMCore will recognize.
|
||||||
|
* The corresponding filesystem type is stored in @p fsType, and
|
||||||
|
* its value is FileSystem::Unknown if @p fsName is not recognized.
|
||||||
|
*/
|
||||||
|
QString findFS( QString fsName, FileSystem::Type* fsType );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // PARTUTILS_H
|
#endif // PARTUTILS_H
|
||||||
|
@ -18,27 +18,50 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include "core/PartitionLayout.h"
|
#include "core/PartitionLayout.h"
|
||||||
|
|
||||||
#include "core/KPMHelpers.h"
|
#include "core/KPMHelpers.h"
|
||||||
#include "core/PartitionActions.h"
|
#include "core/PartitionActions.h"
|
||||||
#include "core/PartitionInfo.h"
|
#include "core/PartitionInfo.h"
|
||||||
|
#include "core/PartUtils.h"
|
||||||
|
|
||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystem.h>
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
|
||||||
|
static FileSystem::Type
|
||||||
|
getDefaultFileSystemType()
|
||||||
|
{
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
FileSystem::Type defaultFS = FileSystem::Ext4;
|
||||||
|
|
||||||
|
if ( gs->contains( "defaultFileSystemType" ) )
|
||||||
|
{
|
||||||
|
PartUtils::findFS( gs->value( "defaultFileSystemType" ).toString(), &defaultFS);
|
||||||
|
if ( defaultFS == FileSystem::Unknown )
|
||||||
|
defaultFS = FileSystem::Ext4;
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultFS;
|
||||||
|
}
|
||||||
|
|
||||||
PartitionLayout::PartitionLayout()
|
PartitionLayout::PartitionLayout()
|
||||||
{
|
{
|
||||||
|
m_defaultFsType = getDefaultFileSystemType();
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionLayout::PartitionLayout( PartitionLayout::PartitionEntry entry )
|
PartitionLayout::PartitionLayout( PartitionLayout::PartitionEntry entry )
|
||||||
{
|
{
|
||||||
partLayout.append( entry );
|
m_defaultFsType = getDefaultFileSystemType();
|
||||||
|
m_partLayout.append( entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionLayout::PartitionLayout( const PartitionLayout& layout )
|
PartitionLayout::PartitionLayout( const PartitionLayout& layout )
|
||||||
: partLayout( layout.partLayout )
|
: m_partLayout( layout.m_partLayout )
|
||||||
|
, m_defaultFsType( layout.m_defaultFsType )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +72,7 @@ PartitionLayout::~PartitionLayout()
|
|||||||
void
|
void
|
||||||
PartitionLayout::addEntry( PartitionLayout::PartitionEntry entry )
|
PartitionLayout::addEntry( PartitionLayout::PartitionEntry entry )
|
||||||
{
|
{
|
||||||
partLayout.append( entry );
|
m_partLayout.append( entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
static double
|
||||||
@ -115,9 +138,9 @@ PartitionLayout::addEntry( const QString& mountPoint, const QString& size, const
|
|||||||
PartitionLayout::PartitionEntry entry( size, min );
|
PartitionLayout::PartitionEntry entry( size, min );
|
||||||
|
|
||||||
entry.partMountPoint = mountPoint;
|
entry.partMountPoint = mountPoint;
|
||||||
entry.partFileSystem = FileSystem::Ext4;
|
entry.partFileSystem = m_defaultFsType;
|
||||||
|
|
||||||
partLayout.append( entry );
|
m_partLayout.append( entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -127,9 +150,11 @@ PartitionLayout::addEntry( const QString& label, const QString& mountPoint, cons
|
|||||||
|
|
||||||
entry.partLabel = label;
|
entry.partLabel = label;
|
||||||
entry.partMountPoint = mountPoint;
|
entry.partMountPoint = mountPoint;
|
||||||
entry.partFileSystem = FileSystem::typeForName( fs );
|
PartUtils::findFS( fs, &entry.partFileSystem );
|
||||||
|
if ( entry.partFileSystem == FileSystem::Unknown )
|
||||||
|
entry.partFileSystem = m_defaultFsType;
|
||||||
|
|
||||||
partLayout.append( entry );
|
m_partLayout.append( entry );
|
||||||
}
|
}
|
||||||
|
|
||||||
static qint64
|
static qint64
|
||||||
@ -175,7 +200,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||||||
// TODO: Refine partition sizes to make sure there is room for every partition
|
// TODO: Refine partition sizes to make sure there is room for every partition
|
||||||
// Use a default (200-500M ?) minimum size for partition without minSize
|
// Use a default (200-500M ?) minimum size for partition without minSize
|
||||||
|
|
||||||
foreach( const PartitionLayout::PartitionEntry& part, partLayout )
|
foreach( const PartitionLayout::PartitionEntry& part, m_partLayout )
|
||||||
{
|
{
|
||||||
Partition *currentPartition = nullptr;
|
Partition *currentPartition = nullptr;
|
||||||
|
|
||||||
@ -194,7 +219,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||||||
parent,
|
parent,
|
||||||
*dev,
|
*dev,
|
||||||
role,
|
role,
|
||||||
static_cast<FileSystem::Type>(part.partFileSystem),
|
part.partFileSystem,
|
||||||
firstSector,
|
firstSector,
|
||||||
end,
|
end,
|
||||||
PartitionTable::FlagNone
|
PartitionTable::FlagNone
|
||||||
@ -206,7 +231,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||||||
parent,
|
parent,
|
||||||
*dev,
|
*dev,
|
||||||
role,
|
role,
|
||||||
static_cast<FileSystem::Type>(part.partFileSystem),
|
part.partFileSystem,
|
||||||
firstSector,
|
firstSector,
|
||||||
end,
|
end,
|
||||||
luksPassphrase,
|
luksPassphrase,
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
// KPMcore
|
// KPMcore
|
||||||
#include <kpmcore/core/partitiontable.h>
|
#include <kpmcore/core/partitiontable.h>
|
||||||
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@ -48,7 +49,7 @@ public:
|
|||||||
{
|
{
|
||||||
QString partLabel;
|
QString partLabel;
|
||||||
QString partMountPoint;
|
QString partMountPoint;
|
||||||
int partFileSystem = 0;
|
FileSystem::Type partFileSystem = FileSystem::Unknown;
|
||||||
double partSize = 0.0L;
|
double partSize = 0.0L;
|
||||||
SizeUnit partSizeUnit = Percent;
|
SizeUnit partSizeUnit = Percent;
|
||||||
double partMinSize = 0.0L;
|
double partMinSize = 0.0L;
|
||||||
@ -76,7 +77,8 @@ public:
|
|||||||
QList< Partition* > execute( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase, PartitionNode* parent, const PartitionRole& role );
|
QList< Partition* > execute( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase, PartitionNode* parent, const PartitionRole& role );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList< PartitionEntry > partLayout;
|
FileSystem::Type m_defaultFsType;
|
||||||
|
QList< PartitionEntry > m_partLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PARTITIONLAYOUT_H */
|
#endif /* PARTITIONLAYOUT_H */
|
||||||
|
@ -493,55 +493,6 @@ nameToChoice( QString name, bool& ok )
|
|||||||
return names.find( name, ok );
|
return names.find( name, ok );
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief translate @p defaultFS into a recognized name
|
|
||||||
*
|
|
||||||
* Makes several attempts to translate the string into a
|
|
||||||
* name that KPMCore will recognize.
|
|
||||||
*/
|
|
||||||
static QString
|
|
||||||
findFS( QString defaultFS )
|
|
||||||
{
|
|
||||||
QStringList fsLanguage { QLatin1Literal( "C" ) }; // Required language list to turn off localization
|
|
||||||
if ( defaultFS.isEmpty() )
|
|
||||||
{
|
|
||||||
cWarning() << "Partition-module setting *defaultFileSystemType* is missing, using ext4";
|
|
||||||
defaultFS = QStringLiteral( "ext4" );
|
|
||||||
}
|
|
||||||
if ( FileSystem::typeForName( defaultFS, fsLanguage ) != FileSystem::Unknown )
|
|
||||||
{
|
|
||||||
cDebug() << "Partition-module setting *defaultFileSystemType*" << defaultFS;
|
|
||||||
return defaultFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Second pass: try case-insensitive
|
|
||||||
const auto fstypes = FileSystem::types();
|
|
||||||
for ( FileSystem::Type t : fstypes )
|
|
||||||
{
|
|
||||||
if ( 0 == QString::compare( defaultFS, FileSystem::nameForType( t, fsLanguage ), Qt::CaseInsensitive ) )
|
|
||||||
{
|
|
||||||
defaultFS = FileSystem::nameForType( t, fsLanguage );
|
|
||||||
cWarning() << "Partition-module setting *defaultFileSystemType* changed" << defaultFS;
|
|
||||||
return defaultFS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << defaultFS << ") using ext4.";
|
|
||||||
defaultFS = QStringLiteral( "ext4" );
|
|
||||||
#ifdef DEBUG_FILESYSTEMS
|
|
||||||
// This bit is for distro's debugging their settings, and shows
|
|
||||||
// all the strings that KPMCore is matching against for FS type.
|
|
||||||
{
|
|
||||||
Logger::CDebug d;
|
|
||||||
using TR = Logger::DebugRow< int, QString >;
|
|
||||||
const auto fstypes = FileSystem::types();
|
|
||||||
d << "Available types (" << fstypes.count() << ')';
|
|
||||||
for ( FileSystem::Type t : fstypes )
|
|
||||||
d << TR( static_cast<int>( t ), FileSystem::nameForType( t, fsLanguage ) );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return defaultFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
@ -630,7 +581,21 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
gs->insert( "alwaysShowPartitionLabels", CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) );
|
gs->insert( "alwaysShowPartitionLabels", CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) );
|
||||||
gs->insert( "enableLuksAutomatedPartitioning", CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) );
|
gs->insert( "enableLuksAutomatedPartitioning", CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) );
|
||||||
gs->insert( "allowManualPartitioning", CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) );
|
gs->insert( "allowManualPartitioning", CalamaresUtils::getBool( configurationMap, "allowManualPartitioning", true ) );
|
||||||
gs->insert( "defaultFileSystemType", findFS( CalamaresUtils::getString( configurationMap, "defaultFileSystemType" ) ) );
|
|
||||||
|
// 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::findFS( fsName, &fsType );
|
||||||
|
if ( fsRealName == fsName )
|
||||||
|
cDebug() << "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 (" << fsRealName << ") using ext4.";
|
||||||
|
gs->insert( "defaultFileSystemType", fsRealName );
|
||||||
|
|
||||||
|
|
||||||
// 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
|
||||||
|
Loading…
Reference in New Issue
Block a user