diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index b1c6711ef..aa8486bd1 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -31,7 +31,6 @@ #include #include #include -#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 { diff --git a/src/modules/partition/gui/PartitionViewStep.h b/src/modules/partition/gui/PartitionViewStep.h index 283845e52..f1c9a6f90 100644 --- a/src/modules/partition/gui/PartitionViewStep.h +++ b/src/modules/partition/gui/PartitionViewStep.h @@ -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;