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> === /* === 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 * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * 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 void
doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition ) doReplacePartition( PartitionCoreModule* core,
Device* dev,
Partition* partition,
const QString& luksPassphrase )
{ {
cDebug() << "doReplacePartition for device" << partition->partitionPath(); cDebug() << "doReplacePartition for device" << partition->partitionPath();
@ -250,13 +253,30 @@ doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition
} }
} }
Partition* newPartition = KPMHelpers::createNewPartition( Partition* newPartition = nullptr;
if ( luksPassphrase.isEmpty() )
{
newPartition = KPMHelpers::createNewPartition(
partition->parent(), partition->parent(),
*dev, *dev,
newRoles, newRoles,
FileSystem::Ext4, FileSystem::Ext4,
partition->firstSector(), partition->firstSector(),
partition->lastSector() ); partition->lastSector()
);
}
else
{
newPartition = KPMHelpers::createNewEncryptedPartition(
partition->parent(),
*dev,
newRoles,
FileSystem::Ext4,
partition->firstSector(),
partition->lastSector(),
luksPassphrase
);
}
PartitionInfo::setMountPoint( newPartition, "/" ); PartitionInfo::setMountPoint( newPartition, "/" );
PartitionInfo::setFormat( newPartition, true ); PartitionInfo::setFormat( newPartition, true );

View File

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> === /* === 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 * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * 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, void doReplacePartition( PartitionCoreModule* core,
Device* dev, Device* dev,
Partition* partition ); Partition* partition,
const QString& luksPassphrase = QString() );
} }
#endif // PARTITIONACTIONS_H #endif // PARTITIONACTIONS_H

View File

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