Move osprober management out of ctor.
This commit is contained in:
parent
a2f1d49983
commit
905835295a
@ -31,7 +31,6 @@
|
||||
#include <gui/PartitionPage.h>
|
||||
#include <gui/ReplacePage.h>
|
||||
#include <gui/PartitionPreview.h>
|
||||
#include "OsproberEntry.h"
|
||||
|
||||
#include "CalamaresVersion.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
@ -72,51 +71,7 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
|
||||
connect( timer, &QTimer::timeout,
|
||||
[=]()
|
||||
{
|
||||
QString osproberOutput;
|
||||
QProcess osprober;
|
||||
osprober.setProgram( "os-prober" );
|
||||
osprober.setProcessChannelMode( QProcess::SeparateChannels );
|
||||
osprober.start();
|
||||
if ( !osprober.waitForStarted() )
|
||||
{
|
||||
cDebug() << "ERROR: os-prober cannot start.";
|
||||
}
|
||||
else if ( !osprober.waitForFinished( 60000 ) )
|
||||
{
|
||||
cDebug() << "ERROR: os-prober timed out.";
|
||||
}
|
||||
else
|
||||
{
|
||||
osproberOutput.append(
|
||||
QString::fromLocal8Bit(
|
||||
osprober.readAllStandardOutput() ).trimmed() );
|
||||
}
|
||||
|
||||
QString osProberReport( "Osprober lines, clean:\n" );
|
||||
QStringList osproberCleanLines;
|
||||
OsproberEntryList osproberEntries;
|
||||
foreach ( const QString& line, osproberOutput.split( '\n' ) )
|
||||
{
|
||||
if ( !line.simplified().isEmpty() )
|
||||
{
|
||||
QStringList lineColumns = line.split( ':' );
|
||||
QString prettyName;
|
||||
if ( !lineColumns.value( 1 ).simplified().isEmpty() )
|
||||
prettyName = lineColumns.value( 1 ).simplified();
|
||||
else if ( !lineColumns.value( 2 ).simplified().isEmpty() )
|
||||
prettyName = lineColumns.value( 2 ).simplified();
|
||||
|
||||
QString path = lineColumns.value( 0 ).simplified();
|
||||
if ( !path.startsWith( "/dev/" ) ) //basic sanity check
|
||||
continue;
|
||||
|
||||
osproberEntries.append( { prettyName, path, canBeResized( path ), lineColumns } );
|
||||
osproberCleanLines.append( line );
|
||||
}
|
||||
}
|
||||
osProberReport.append( osproberCleanLines.join( '\n' ) );
|
||||
cDebug() << osProberReport;
|
||||
Calamares::JobQueue::instance()->globalStorage()->insert( "osproberLines", osproberCleanLines );
|
||||
OsproberEntryList osproberEntries = runOsprober();
|
||||
|
||||
m_choicePage->init( m_core, osproberEntries );
|
||||
m_erasePage->init( m_core );
|
||||
@ -156,6 +111,60 @@ PartitionViewStep::~PartitionViewStep()
|
||||
}
|
||||
|
||||
|
||||
OsproberEntryList
|
||||
PartitionViewStep::runOsprober()
|
||||
{
|
||||
QString osproberOutput;
|
||||
QProcess osprober;
|
||||
osprober.setProgram( "os-prober" );
|
||||
osprober.setProcessChannelMode( QProcess::SeparateChannels );
|
||||
osprober.start();
|
||||
if ( !osprober.waitForStarted() )
|
||||
{
|
||||
cDebug() << "ERROR: os-prober cannot start.";
|
||||
}
|
||||
else if ( !osprober.waitForFinished( 60000 ) )
|
||||
{
|
||||
cDebug() << "ERROR: os-prober timed out.";
|
||||
}
|
||||
else
|
||||
{
|
||||
osproberOutput.append(
|
||||
QString::fromLocal8Bit(
|
||||
osprober.readAllStandardOutput() ).trimmed() );
|
||||
}
|
||||
|
||||
QString osProberReport( "Osprober lines, clean:\n" );
|
||||
QStringList osproberCleanLines;
|
||||
OsproberEntryList osproberEntries;
|
||||
foreach ( const QString& line, osproberOutput.split( '\n' ) )
|
||||
{
|
||||
if ( !line.simplified().isEmpty() )
|
||||
{
|
||||
QStringList lineColumns = line.split( ':' );
|
||||
QString prettyName;
|
||||
if ( !lineColumns.value( 1 ).simplified().isEmpty() )
|
||||
prettyName = lineColumns.value( 1 ).simplified();
|
||||
else if ( !lineColumns.value( 2 ).simplified().isEmpty() )
|
||||
prettyName = lineColumns.value( 2 ).simplified();
|
||||
|
||||
QString path = lineColumns.value( 0 ).simplified();
|
||||
if ( !path.startsWith( "/dev/" ) ) //basic sanity check
|
||||
continue;
|
||||
|
||||
osproberEntries.append( { prettyName, path, canBeResized( path ), lineColumns } );
|
||||
osproberCleanLines.append( line );
|
||||
}
|
||||
}
|
||||
osProberReport.append( osproberCleanLines.join( '\n' ) );
|
||||
cDebug() << osProberReport;
|
||||
|
||||
Calamares::JobQueue::instance()->globalStorage()->insert( "osproberLines", osproberCleanLines );
|
||||
|
||||
return osproberEntries;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PartitionViewStep::prettyName() const
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "viewpages/ViewStep.h"
|
||||
#include "PluginDllMacro.h"
|
||||
#include "OsproberEntry.h"
|
||||
|
||||
class ChoicePage;
|
||||
class EraseDiskPage;
|
||||
@ -69,6 +70,7 @@ public:
|
||||
QList< Calamares::job_ptr > jobs() const override;
|
||||
|
||||
private:
|
||||
OsproberEntryList runOsprober();
|
||||
bool canBeResized( const QString& partitionPath );
|
||||
|
||||
PartitionCoreModule* m_core;
|
||||
|
Loading…
Reference in New Issue
Block a user