[partition] Factor out finding the swap-partitions
This commit is contained in:
parent
3e58639a68
commit
ac34cfadea
@ -72,42 +72,16 @@ getPartitionsForDevice( const QString& deviceName )
|
|||||||
return partitions;
|
return partitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearMountsJob::ClearMountsJob( Device* device )
|
STATICTEST static QStringList
|
||||||
: Calamares::Job()
|
getSwapsForDevice( const QString& deviceName )
|
||||||
, m_device( device )
|
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
QString
|
|
||||||
ClearMountsJob::prettyName() const
|
|
||||||
{
|
|
||||||
return tr( "Clear mounts for partitioning operations on %1" ).arg( m_device->deviceNode() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString
|
|
||||||
ClearMountsJob::prettyStatusMessage() const
|
|
||||||
{
|
|
||||||
return tr( "Clearing mounts for partitioning operations on %1." ).arg( m_device->deviceNode() );
|
|
||||||
}
|
|
||||||
|
|
||||||
Calamares::JobResult
|
|
||||||
ClearMountsJob::exec()
|
|
||||||
{
|
|
||||||
CalamaresUtils::Partition::Syncer s;
|
|
||||||
|
|
||||||
QString deviceName = m_device->deviceNode().split( '/' ).last();
|
|
||||||
|
|
||||||
QStringList goodNews;
|
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
|
||||||
QStringList partitionsList = getPartitionsForDevice( deviceName );
|
|
||||||
|
|
||||||
// Build a list of partitions of type 82 (Linux swap / Solaris).
|
// Build a list of partitions of type 82 (Linux swap / Solaris).
|
||||||
// We then need to clear them just in case they contain something resumable from a
|
// We then need to clear them just in case they contain something resumable from a
|
||||||
// previous suspend-to-disk.
|
// previous suspend-to-disk.
|
||||||
QStringList swapPartitions;
|
QStringList swapPartitions;
|
||||||
process.start( "sfdisk", { "-d", m_device->deviceNode() } );
|
process.start( "sfdisk", { "-d", deviceName } );
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
// Sample output:
|
// Sample output:
|
||||||
// % sudo sfdisk -d /dev/sda
|
// % sudo sfdisk -d /dev/sda
|
||||||
@ -126,6 +100,41 @@ ClearMountsJob::exec()
|
|||||||
*it = ( *it ).simplified().split( ' ' ).first();
|
*it = ( *it ).simplified().split( ' ' ).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return swapPartitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ClearMountsJob::ClearMountsJob( Device* device )
|
||||||
|
: Calamares::Job()
|
||||||
|
, m_device( device )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
ClearMountsJob::prettyName() const
|
||||||
|
{
|
||||||
|
return tr( "Clear mounts for partitioning operations on %1" ).arg( m_device->deviceNode() );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
ClearMountsJob::prettyStatusMessage() const
|
||||||
|
{
|
||||||
|
return tr( "Clearing mounts for partitioning operations on %1." ).arg( m_device->deviceNode() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Calamares::JobResult
|
||||||
|
ClearMountsJob::exec()
|
||||||
|
{
|
||||||
|
CalamaresUtils::Partition::Syncer s;
|
||||||
|
|
||||||
|
QString deviceName = m_device->deviceNode().split( '/' ).last();
|
||||||
|
|
||||||
|
QStringList goodNews;
|
||||||
|
QProcess process;
|
||||||
|
|
||||||
|
const QStringList partitionsList = getPartitionsForDevice( deviceName );
|
||||||
|
const QStringList swapPartitions = getSwapsForDevice( m_device->deviceNode() );
|
||||||
|
|
||||||
const QStringList cryptoDevices = getCryptoDevices();
|
const QStringList cryptoDevices = getCryptoDevices();
|
||||||
for ( const QString& mapperPath : cryptoDevices )
|
for ( const QString& mapperPath : cryptoDevices )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user