Add encryption support in PartitionActions::doReplacePartition.

This commit is contained in:
Teo Mrnjavac 2016-06-03 16:39:28 +02:00
parent 6cd1bf6b3d
commit e84108e234
3 changed files with 34 additions and 12 deletions

View File

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -230,7 +230,10 @@ doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPass
void
doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition )
doReplacePartition( PartitionCoreModule* core,
Device* dev,
Partition* partition,
const QString& luksPassphrase )
{
cDebug() << "doReplacePartition for device" << partition->partitionPath();
@ -250,13 +253,30 @@ doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition
}
}
Partition* newPartition = KPMHelpers::createNewPartition(
partition->parent(),
*dev,
newRoles,
FileSystem::Ext4,
partition->firstSector(),
partition->lastSector() );
Partition* newPartition = nullptr;
if ( luksPassphrase.isEmpty() )
{
newPartition = KPMHelpers::createNewPartition(
partition->parent(),
*dev,
newRoles,
FileSystem::Ext4,
partition->firstSector(),
partition->lastSector()
);
}
else
{
newPartition = KPMHelpers::createNewEncryptedPartition(
partition->parent(),
*dev,
newRoles,
FileSystem::Ext4,
partition->firstSector(),
partition->lastSector(),
luksPassphrase
);
}
PartitionInfo::setMountPoint( newPartition, "/" );
PartitionInfo::setFormat( newPartition, true );

View File

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -33,7 +33,8 @@ void doAutopartition( PartitionCoreModule* core,
void doReplacePartition( PartitionCoreModule* core,
Device* dev,
Partition* partition );
Partition* partition,
const QString& luksPassphrase = QString() );
}
#endif // PARTITIONACTIONS_H

View File

@ -661,7 +661,8 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current,
if ( selectedPartition )
PartitionActions::doReplacePartition( m_core,
selectedDevice(),
selectedPartition );
selectedPartition,
m_encryptWidget->passphrase() );
}
} ),
[=]