[partition] Apply custom layout when installing "Alongside"

When choosing "Install alongside another system", the custom partition
layout is applied to the space freed by resizing the selected partition.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
main
Arnaud Ferraris 6 years ago
parent 74a59ae68a
commit 2f14a21456

@ -791,10 +791,14 @@ void
PartitionCoreModule::layoutApply( Device *dev,
qint64 firstSector,
qint64 lastSector,
QString luksPassphrase )
QString luksPassphrase,
PartitionNode* parent,
const PartitionRole& role )
{
bool isEfi = PartUtils::isEfiSystem();
QList< Partition* > partList = m_partLayout->execute( dev, firstSector, lastSector, luksPassphrase );
QList< Partition* > partList = m_partLayout->execute( dev, firstSector, lastSector,
luksPassphrase, parent, role
);
foreach ( Partition *part, partList )
{
@ -811,6 +815,17 @@ PartitionCoreModule::layoutApply( Device *dev,
}
}
void
PartitionCoreModule::layoutApply( Device *dev,
qint64 firstSector,
qint64 lastSector,
QString luksPassphrase )
{
layoutApply( dev, firstSector, lastSector, luksPassphrase, dev->partitionTable(),
PartitionRole( PartitionRole::Primary )
);
}
void
PartitionCoreModule::revert()
{

@ -160,6 +160,8 @@ public:
void initLayout( const QVariantList& config );
void layoutApply( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase );
void layoutApply( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase, PartitionNode* parent, const PartitionRole& role );
/**
* @brief jobs creates and returns a list of jobs which can then apply the changes
* requested by the user.

@ -151,7 +151,9 @@ sizeToSectors( double size, PartitionLayout::SizeUnit unit, qint64 totalSize, qi
QList< Partition* >
PartitionLayout::execute( Device *dev, qint64 firstSector,
qint64 lastSector, QString luksPassphrase )
qint64 lastSector, QString luksPassphrase,
PartitionNode* parent,
const PartitionRole& role )
{
QList< Partition* > partList;
qint64 size, minSize, end;
@ -177,9 +179,9 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
if ( luksPassphrase.isEmpty() )
{
currentPartition = KPMHelpers::createNewPartition(
dev->partitionTable(),
parent,
*dev,
PartitionRole( PartitionRole::Primary ),
role,
static_cast<FileSystem::Type>(part.partFileSystem),
firstSector,
end,
@ -189,9 +191,9 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
else
{
currentPartition = KPMHelpers::createNewEncryptedPartition(
dev->partitionTable(),
parent,
*dev,
PartitionRole( PartitionRole::Primary ),
role,
static_cast<FileSystem::Type>(part.partFileSystem),
firstSector,
end,

@ -67,7 +67,7 @@ public:
* @brief Apply the current partition layout to the selected drive space.
* @return A list of Partition objects.
*/
QList< Partition* > execute( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase );
QList< Partition* > execute( Device *dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase, PartitionNode* parent, const PartitionRole& role );
private:
QList< PartitionEntry > partLayout;

@ -670,41 +670,10 @@ ChoicePage::doAlongsideApply()
dev->logicalSize();
m_core->resizePartition( dev, candidate, firstSector, newLastSector );
Partition* newPartition = nullptr;
QString luksPassphrase = m_encryptWidget->passphrase();
if ( luksPassphrase.isEmpty() )
{
newPartition = KPMHelpers::createNewPartition(
candidate->parent(),
*dev,
candidate->roles(),
FileSystem::typeForName( m_defaultFsType ),
newLastSector + 2, // *
oldLastSector,
PartitionTable::FlagNone
);
}
else
{
newPartition = KPMHelpers::createNewEncryptedPartition(
candidate->parent(),
*dev,
candidate->roles(),
FileSystem::typeForName( m_defaultFsType ),
newLastSector + 2, // *
oldLastSector,
luksPassphrase,
PartitionTable::FlagNone
);
}
PartitionInfo::setMountPoint( newPartition, "/" );
PartitionInfo::setFormat( newPartition, true );
// * for some reason ped_disk_add_partition refuses to create a new partition
// if it starts on the sector immediately after the last used sector, so we
// have to push it one sector further, therefore + 2 instead of + 1.
m_core->createPartition( dev, newPartition );
m_core->layoutApply( dev, newLastSector + 2, oldLastSector,
m_encryptWidget->passphrase(), candidate->parent(),
candidate->roles()
);
m_core->dumpQueue();
break;

Loading…
Cancel
Save