[partition] Factor out finding the swap-partitions

This commit is contained in:
Adriaan de Groot 2021-11-01 20:23:49 +01:00
parent 3e58639a68
commit ac34cfadea

View File

@ -72,42 +72,16 @@ getPartitionsForDevice( const QString& deviceName )
return partitions;
}
ClearMountsJob::ClearMountsJob( Device* device )
: Calamares::Job()
, m_device( device )
STATICTEST static QStringList
getSwapsForDevice( const QString& deviceName )
{
}
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;
QStringList partitionsList = getPartitionsForDevice( deviceName );
// 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
// previous suspend-to-disk.
QStringList swapPartitions;
process.start( "sfdisk", { "-d", m_device->deviceNode() } );
process.start( "sfdisk", { "-d", deviceName } );
process.waitForFinished();
// Sample output:
// % sudo sfdisk -d /dev/sda
@ -126,6 +100,41 @@ ClearMountsJob::exec()
*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();
for ( const QString& mapperPath : cryptoDevices )
{