Merge branch 'fix-partition-layout' into calamares
This commit is contained in:
commit
f00a095acb
@ -861,9 +861,9 @@ PartitionCoreModule::setBootLoaderInstallPath( const QString& path )
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::initLayout( const QVariantList& config )
|
||||
PartitionCoreModule::initLayout( FileSystem::Type defaultFsType, const QVariantList& config )
|
||||
{
|
||||
m_partLayout.init( config );
|
||||
m_partLayout.init( defaultFsType, config );
|
||||
}
|
||||
|
||||
void
|
||||
@ -875,7 +875,8 @@ PartitionCoreModule::layoutApply( Device* dev,
|
||||
const PartitionRole& role )
|
||||
{
|
||||
bool isEfi = PartUtils::isEfiSystem();
|
||||
QList< Partition* > partList = m_partLayout.createPartitions( dev, firstSector, lastSector, luksPassphrase, parent, role );
|
||||
QList< Partition* > partList
|
||||
= m_partLayout.createPartitions( dev, firstSector, lastSector, luksPassphrase, parent, role );
|
||||
|
||||
// Partition::mountPoint() tells us where it is mounted **now**, while
|
||||
// PartitionInfo::mountPoint() says where it will be mounted in the target system.
|
||||
|
@ -156,7 +156,11 @@ public:
|
||||
/// @brief Set the path where the bootloader will be installed
|
||||
void setBootLoaderInstallPath( const QString& path );
|
||||
|
||||
void initLayout( const QVariantList& config = QVariantList() );
|
||||
/** @brief Initialize the default layout that will be applied
|
||||
*
|
||||
* See PartitionLayout::init()
|
||||
*/
|
||||
void initLayout( FileSystem::Type defaultFsType, const QVariantList& config = QVariantList() );
|
||||
|
||||
void layoutApply( Device* dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase );
|
||||
void layoutApply( Device* dev,
|
||||
|
@ -27,32 +27,10 @@
|
||||
#include <kpmcore/core/partition.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()
|
||||
: m_defaultFsType( getDefaultFileSystemType() )
|
||||
{
|
||||
}
|
||||
PartitionLayout::PartitionLayout() {}
|
||||
|
||||
PartitionLayout::PartitionLayout( const PartitionLayout& layout )
|
||||
: m_defaultFsType( layout.m_defaultFsType )
|
||||
, m_partLayout( layout.m_partLayout )
|
||||
: m_partLayout( layout.m_partLayout )
|
||||
{
|
||||
}
|
||||
|
||||
@ -63,10 +41,14 @@ PartitionLayout::PartitionEntry::PartitionEntry()
|
||||
{
|
||||
}
|
||||
|
||||
PartitionLayout::PartitionEntry::PartitionEntry( FileSystem::Type type, const QString& mountPoint, const QString& size, const QString& minSize, const QString& maxSize )
|
||||
: partType( type )
|
||||
, partAttributes( 0 )
|
||||
PartitionLayout::PartitionEntry::PartitionEntry( FileSystem::Type fs,
|
||||
const QString& mountPoint,
|
||||
const QString& size,
|
||||
const QString& minSize,
|
||||
const QString& maxSize )
|
||||
: partAttributes( 0 )
|
||||
, partMountPoint( mountPoint )
|
||||
, partFileSystem( fs )
|
||||
, partSize( size )
|
||||
, partMinSize( minSize )
|
||||
, partMaxSize( maxSize )
|
||||
@ -111,7 +93,7 @@ PartitionLayout::addEntry( const PartitionEntry& entry )
|
||||
}
|
||||
|
||||
void
|
||||
PartitionLayout::init( const QVariantList& config )
|
||||
PartitionLayout::init( FileSystem::Type defaultFsType, const QVariantList& config )
|
||||
{
|
||||
bool ok;
|
||||
|
||||
@ -149,7 +131,7 @@ PartitionLayout::init( const QVariantList& config )
|
||||
|
||||
if ( !m_partLayout.count() )
|
||||
{
|
||||
addEntry( { m_defaultFsType, QString( "/" ), QString( "100%" ) } );
|
||||
addEntry( { defaultFsType, QString( "/" ), QString( "100%" ) } );
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,8 +197,8 @@ PartitionLayout::createPartitions( Device* dev,
|
||||
{
|
||||
if ( entry.partSize.unit() == CalamaresUtils::Partition::SizeUnit::Percent )
|
||||
{
|
||||
qint64 sectors = entry.partSize.toSectors( availableSectors + partSectorsMap.value( &entry ),
|
||||
dev->logicalSize() );
|
||||
qint64 sectors
|
||||
= entry.partSize.toSectors( availableSectors + partSectorsMap.value( &entry ), dev->logicalSize() );
|
||||
if ( entry.partMinSize.isValid() )
|
||||
{
|
||||
sectors = std::max( sectors, entry.partMinSize.toSectors( totalSectors, dev->logicalSize() ) );
|
||||
@ -245,13 +227,24 @@ PartitionLayout::createPartitions( Device* dev,
|
||||
Partition* part = nullptr;
|
||||
if ( luksPassphrase.isEmpty() )
|
||||
{
|
||||
part = KPMHelpers::createNewPartition(
|
||||
parent, *dev, role, entry.partFileSystem, currentSector, currentSector + sectors - 1, KPM_PARTITION_FLAG( None ) );
|
||||
part = KPMHelpers::createNewPartition( parent,
|
||||
*dev,
|
||||
role,
|
||||
entry.partFileSystem,
|
||||
currentSector,
|
||||
currentSector + sectors - 1,
|
||||
KPM_PARTITION_FLAG( None ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
part = KPMHelpers::createNewEncryptedPartition(
|
||||
parent, *dev, role, entry.partFileSystem, currentSector, currentSector + sectors - 1, luksPassphrase, KPM_PARTITION_FLAG( None ) );
|
||||
part = KPMHelpers::createNewEncryptedPartition( parent,
|
||||
*dev,
|
||||
role,
|
||||
entry.partFileSystem,
|
||||
currentSector,
|
||||
currentSector + sectors - 1,
|
||||
luksPassphrase,
|
||||
KPM_PARTITION_FLAG( None ) );
|
||||
}
|
||||
PartitionInfo::setFormat( part, true );
|
||||
PartitionInfo::setMountPoint( part, entry.partMountPoint );
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
* Sets a specific FS type (not parsed from string like the other
|
||||
* constructor).
|
||||
*/
|
||||
PartitionEntry( FileSystem::Type type,
|
||||
PartitionEntry( FileSystem::Type fs,
|
||||
const QString& mountPoint,
|
||||
const QString& size,
|
||||
const QString& minSize = QString(),
|
||||
@ -83,7 +83,13 @@ public:
|
||||
PartitionLayout( const PartitionLayout& layout );
|
||||
~PartitionLayout();
|
||||
|
||||
void init( const QVariantList& config );
|
||||
/** @brief create the configuration from @p config
|
||||
*
|
||||
* @p config is a list of partition entries (in QVariant form,
|
||||
* read from YAML). If no entries are given, then a single
|
||||
* partition is created with the given @p defaultFsType
|
||||
*/
|
||||
void init( FileSystem::Type defaultFsType, const QVariantList& config );
|
||||
bool addEntry( const PartitionEntry& entry );
|
||||
|
||||
/**
|
||||
@ -98,7 +104,6 @@ public:
|
||||
const PartitionRole& role );
|
||||
|
||||
private:
|
||||
FileSystem::Type m_defaultFsType;
|
||||
QList< PartitionEntry > m_partLayout;
|
||||
};
|
||||
|
||||
|
@ -602,7 +602,8 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
||||
m_future->setFuture( future );
|
||||
|
||||
m_core->initLayout( configurationMap.value( "partitionLayout" ).toList() );
|
||||
m_core->initLayout( fsType == FileSystem::Unknown ? FileSystem::Ext4 : fsType,
|
||||
configurationMap.value( "partitionLayout" ).toList() );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user