mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[partition] Extract the get-LVM-volumes code to its own function
This commit is contained in:
parent
2a1ec84c87
commit
7fa02fd41c
1 changed files with 26 additions and 21 deletions
|
@ -144,6 +144,31 @@ getCryptoDevices()
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATICTEST QStringList
|
||||||
|
getLVMVolumes()
|
||||||
|
{
|
||||||
|
QProcess process;
|
||||||
|
|
||||||
|
// First we umount all LVM logical volumes we can find
|
||||||
|
process.start( "lvscan", { "-a" } );
|
||||||
|
process.waitForFinished();
|
||||||
|
if ( process.exitCode() == 0 ) //means LVM2 tools are installed
|
||||||
|
{
|
||||||
|
QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
|
||||||
|
// Get the second column (`value(1)`) sinec that is the device name,
|
||||||
|
// remove quoting.
|
||||||
|
std::transform( lvscanLines.begin(), lvscanLines.end(), lvscanLines.begin(), []( const QString& lvscanLine ) {
|
||||||
|
return lvscanLine.simplified().split( ' ' ).value( 1 ).replace( '\'', "" );
|
||||||
|
} );
|
||||||
|
return lvscanLines;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cWarning() << "this system does not seem to have LVM2 tools.";
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The tryX() free functions, below, return an empty QString on
|
* The tryX() free functions, below, return an empty QString on
|
||||||
* failure, or a non-empty QString on success. The string is
|
* failure, or a non-empty QString on success. The string is
|
||||||
|
@ -307,27 +332,7 @@ ClearMountsJob::exec()
|
||||||
const QStringList swapPartitions = getSwapsForDevice( m_deviceNode );
|
const QStringList swapPartitions = getSwapsForDevice( m_deviceNode );
|
||||||
|
|
||||||
apply( getCryptoDevices(), tryCryptoClose, goodNews );
|
apply( getCryptoDevices(), tryCryptoClose, goodNews );
|
||||||
|
apply( getLVMVolumes(), tryUmount, goodNews );
|
||||||
// First we umount all LVM logical volumes we can find
|
|
||||||
process.start( "lvscan", { "-a" } );
|
|
||||||
process.waitForFinished();
|
|
||||||
if ( process.exitCode() == 0 ) //means LVM2 tools are installed
|
|
||||||
{
|
|
||||||
const QStringList lvscanLines = QString::fromLocal8Bit( process.readAllStandardOutput() ).split( '\n' );
|
|
||||||
apply(
|
|
||||||
lvscanLines,
|
|
||||||
[]( const QString& lvscanLine ) {
|
|
||||||
QString lvPath = lvscanLine.simplified().split( ' ' ).value( 1 ); //second column
|
|
||||||
lvPath = lvPath.replace( '\'', "" );
|
|
||||||
|
|
||||||
return tryUmount( lvPath );
|
|
||||||
},
|
|
||||||
goodNews );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cWarning() << "this system does not seem to have LVM2 tools.";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then we go looking for volume groups that use this device for physical volumes
|
// Then we go looking for volume groups that use this device for physical volumes
|
||||||
process.start( "pvdisplay", { "-C", "--noheadings" } );
|
process.start( "pvdisplay", { "-C", "--noheadings" } );
|
||||||
|
|
Loading…
Add table
Reference in a new issue