[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>
This commit is contained in:
parent
74a59ae68a
commit
2f14a21456
@ -791,10 +791,14 @@ void
|
|||||||
PartitionCoreModule::layoutApply( Device *dev,
|
PartitionCoreModule::layoutApply( Device *dev,
|
||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
QString luksPassphrase )
|
QString luksPassphrase,
|
||||||
|
PartitionNode* parent,
|
||||||
|
const PartitionRole& role )
|
||||||
{
|
{
|
||||||
bool isEfi = PartUtils::isEfiSystem();
|
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 )
|
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
|
void
|
||||||
PartitionCoreModule::revert()
|
PartitionCoreModule::revert()
|
||||||
{
|
{
|
||||||
|
@ -160,6 +160,8 @@ public:
|
|||||||
void initLayout( const QVariantList& config );
|
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 );
|
||||||
|
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
|
* @brief jobs creates and returns a list of jobs which can then apply the changes
|
||||||
* requested by the user.
|
* requested by the user.
|
||||||
|
@ -151,7 +151,9 @@ sizeToSectors( double size, PartitionLayout::SizeUnit unit, qint64 totalSize, qi
|
|||||||
|
|
||||||
QList< Partition* >
|
QList< Partition* >
|
||||||
PartitionLayout::execute( Device *dev, qint64 firstSector,
|
PartitionLayout::execute( Device *dev, qint64 firstSector,
|
||||||
qint64 lastSector, QString luksPassphrase )
|
qint64 lastSector, QString luksPassphrase,
|
||||||
|
PartitionNode* parent,
|
||||||
|
const PartitionRole& role )
|
||||||
{
|
{
|
||||||
QList< Partition* > partList;
|
QList< Partition* > partList;
|
||||||
qint64 size, minSize, end;
|
qint64 size, minSize, end;
|
||||||
@ -177,9 +179,9 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||||||
if ( luksPassphrase.isEmpty() )
|
if ( luksPassphrase.isEmpty() )
|
||||||
{
|
{
|
||||||
currentPartition = KPMHelpers::createNewPartition(
|
currentPartition = KPMHelpers::createNewPartition(
|
||||||
dev->partitionTable(),
|
parent,
|
||||||
*dev,
|
*dev,
|
||||||
PartitionRole( PartitionRole::Primary ),
|
role,
|
||||||
static_cast<FileSystem::Type>(part.partFileSystem),
|
static_cast<FileSystem::Type>(part.partFileSystem),
|
||||||
firstSector,
|
firstSector,
|
||||||
end,
|
end,
|
||||||
@ -189,9 +191,9 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentPartition = KPMHelpers::createNewEncryptedPartition(
|
currentPartition = KPMHelpers::createNewEncryptedPartition(
|
||||||
dev->partitionTable(),
|
parent,
|
||||||
*dev,
|
*dev,
|
||||||
PartitionRole( PartitionRole::Primary ),
|
role,
|
||||||
static_cast<FileSystem::Type>(part.partFileSystem),
|
static_cast<FileSystem::Type>(part.partFileSystem),
|
||||||
firstSector,
|
firstSector,
|
||||||
end,
|
end,
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
* @brief Apply the current partition layout to the selected drive space.
|
* @brief Apply the current partition layout to the selected drive space.
|
||||||
* @return A list of Partition objects.
|
* @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:
|
private:
|
||||||
QList< PartitionEntry > partLayout;
|
QList< PartitionEntry > partLayout;
|
||||||
|
@ -670,41 +670,10 @@ ChoicePage::doAlongsideApply()
|
|||||||
dev->logicalSize();
|
dev->logicalSize();
|
||||||
|
|
||||||
m_core->resizePartition( dev, candidate, firstSector, newLastSector );
|
m_core->resizePartition( dev, candidate, firstSector, newLastSector );
|
||||||
Partition* newPartition = nullptr;
|
m_core->layoutApply( dev, newLastSector + 2, oldLastSector,
|
||||||
QString luksPassphrase = m_encryptWidget->passphrase();
|
m_encryptWidget->passphrase(), candidate->parent(),
|
||||||
if ( luksPassphrase.isEmpty() )
|
candidate->roles()
|
||||||
{
|
);
|
||||||
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->dumpQueue();
|
m_core->dumpQueue();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user