Merge branch 'fix-partition-layout' into calamares
This commit is contained in:
commit
f00a095acb
@ -861,9 +861,9 @@ PartitionCoreModule::setBootLoaderInstallPath( const QString& path )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionCoreModule::initLayout( const QVariantList& config )
|
PartitionCoreModule::initLayout( FileSystem::Type defaultFsType, const QVariantList& config )
|
||||||
{
|
{
|
||||||
m_partLayout.init( config );
|
m_partLayout.init( defaultFsType, config );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -875,7 +875,8 @@ PartitionCoreModule::layoutApply( Device* dev,
|
|||||||
const PartitionRole& role )
|
const PartitionRole& role )
|
||||||
{
|
{
|
||||||
bool isEfi = PartUtils::isEfiSystem();
|
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
|
// Partition::mountPoint() tells us where it is mounted **now**, while
|
||||||
// PartitionInfo::mountPoint() says where it will be mounted in the target system.
|
// 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
|
/// @brief Set the path where the bootloader will be installed
|
||||||
void setBootLoaderInstallPath( const QString& path );
|
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, qint64 firstSector, qint64 lastSector, QString luksPassphrase );
|
||||||
void layoutApply( Device* dev,
|
void layoutApply( Device* dev,
|
||||||
|
@ -27,32 +27,10 @@
|
|||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystem.h>
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
|
||||||
static FileSystem::Type
|
PartitionLayout::PartitionLayout() {}
|
||||||
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( const PartitionLayout& layout )
|
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 )
|
PartitionLayout::PartitionEntry::PartitionEntry( FileSystem::Type fs,
|
||||||
: partType( type )
|
const QString& mountPoint,
|
||||||
, partAttributes( 0 )
|
const QString& size,
|
||||||
|
const QString& minSize,
|
||||||
|
const QString& maxSize )
|
||||||
|
: partAttributes( 0 )
|
||||||
, partMountPoint( mountPoint )
|
, partMountPoint( mountPoint )
|
||||||
|
, partFileSystem( fs )
|
||||||
, partSize( size )
|
, partSize( size )
|
||||||
, partMinSize( minSize )
|
, partMinSize( minSize )
|
||||||
, partMaxSize( maxSize )
|
, partMaxSize( maxSize )
|
||||||
@ -111,7 +93,7 @@ PartitionLayout::addEntry( const PartitionEntry& entry )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionLayout::init( const QVariantList& config )
|
PartitionLayout::init( FileSystem::Type defaultFsType, const QVariantList& config )
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
@ -149,7 +131,7 @@ PartitionLayout::init( const QVariantList& config )
|
|||||||
|
|
||||||
if ( !m_partLayout.count() )
|
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 )
|
if ( entry.partSize.unit() == CalamaresUtils::Partition::SizeUnit::Percent )
|
||||||
{
|
{
|
||||||
qint64 sectors = entry.partSize.toSectors( availableSectors + partSectorsMap.value( &entry ),
|
qint64 sectors
|
||||||
dev->logicalSize() );
|
= entry.partSize.toSectors( availableSectors + partSectorsMap.value( &entry ), dev->logicalSize() );
|
||||||
if ( entry.partMinSize.isValid() )
|
if ( entry.partMinSize.isValid() )
|
||||||
{
|
{
|
||||||
sectors = std::max( sectors, entry.partMinSize.toSectors( totalSectors, dev->logicalSize() ) );
|
sectors = std::max( sectors, entry.partMinSize.toSectors( totalSectors, dev->logicalSize() ) );
|
||||||
@ -245,13 +227,24 @@ PartitionLayout::createPartitions( Device* dev,
|
|||||||
Partition* part = nullptr;
|
Partition* part = nullptr;
|
||||||
if ( luksPassphrase.isEmpty() )
|
if ( luksPassphrase.isEmpty() )
|
||||||
{
|
{
|
||||||
part = KPMHelpers::createNewPartition(
|
part = KPMHelpers::createNewPartition( parent,
|
||||||
parent, *dev, role, entry.partFileSystem, currentSector, currentSector + sectors - 1, KPM_PARTITION_FLAG( None ) );
|
*dev,
|
||||||
|
role,
|
||||||
|
entry.partFileSystem,
|
||||||
|
currentSector,
|
||||||
|
currentSector + sectors - 1,
|
||||||
|
KPM_PARTITION_FLAG( None ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
part = KPMHelpers::createNewEncryptedPartition(
|
part = KPMHelpers::createNewEncryptedPartition( parent,
|
||||||
parent, *dev, role, entry.partFileSystem, currentSector, currentSector + sectors - 1, luksPassphrase, KPM_PARTITION_FLAG( None ) );
|
*dev,
|
||||||
|
role,
|
||||||
|
entry.partFileSystem,
|
||||||
|
currentSector,
|
||||||
|
currentSector + sectors - 1,
|
||||||
|
luksPassphrase,
|
||||||
|
KPM_PARTITION_FLAG( None ) );
|
||||||
}
|
}
|
||||||
PartitionInfo::setFormat( part, true );
|
PartitionInfo::setFormat( part, true );
|
||||||
PartitionInfo::setMountPoint( part, entry.partMountPoint );
|
PartitionInfo::setMountPoint( part, entry.partMountPoint );
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
* Sets a specific FS type (not parsed from string like the other
|
* Sets a specific FS type (not parsed from string like the other
|
||||||
* constructor).
|
* constructor).
|
||||||
*/
|
*/
|
||||||
PartitionEntry( FileSystem::Type type,
|
PartitionEntry( FileSystem::Type fs,
|
||||||
const QString& mountPoint,
|
const QString& mountPoint,
|
||||||
const QString& size,
|
const QString& size,
|
||||||
const QString& minSize = QString(),
|
const QString& minSize = QString(),
|
||||||
@ -83,7 +83,13 @@ public:
|
|||||||
PartitionLayout( const PartitionLayout& layout );
|
PartitionLayout( const PartitionLayout& layout );
|
||||||
~PartitionLayout();
|
~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 );
|
bool addEntry( const PartitionEntry& entry );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,7 +104,6 @@ public:
|
|||||||
const PartitionRole& role );
|
const PartitionRole& role );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileSystem::Type m_defaultFsType;
|
|
||||||
QList< PartitionEntry > m_partLayout;
|
QList< PartitionEntry > m_partLayout;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -602,7 +602,8 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
||||||
m_future->setFuture( future );
|
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