Merge branch 'issue-1603' into calamares

FIXES #1603
This commit is contained in:
Adriaan de Groot 2021-09-22 01:45:36 +02:00
commit 744979a095
6 changed files with 36 additions and 33 deletions

View File

@ -112,17 +112,19 @@ public:
QString message; ///< Filled in with errors QString message; ///< Filled in with errors
QString details; QString details;
Logger::Once o;
m_jobIndex = 0; m_jobIndex = 0;
for ( const auto& jobitem : *m_runningJobs ) for ( const auto& jobitem : *m_runningJobs )
{ {
if ( failureEncountered && !jobitem.job->isEmergency() ) if ( failureEncountered && !jobitem.job->isEmergency() )
{ {
cDebug() << "Skipping non-emergency job" << jobitem.job->prettyName(); cDebug() << o << "Skipping non-emergency job" << jobitem.job->prettyName();
} }
else else
{ {
cDebug() << "Starting" << ( failureEncountered ? "EMERGENCY JOB" : "job" ) << jobitem.job->prettyName() cDebug() << o << "Starting" << ( failureEncountered ? "EMERGENCY JOB" : "job" ) << jobitem.job->prettyName()
<< '(' << ( m_jobIndex + 1 ) << '/' << m_runningJobs->count() << ')'; << '(' << ( m_jobIndex + 1 ) << '/' << m_runningJobs->count() << ')';
o.refresh(); // So next time it shows the function header again
emitProgress( 0.0 ); // 0% for *this job* emitProgress( 0.0 ); // 0% for *this job*
connect( jobitem.job.data(), &Job::progress, this, &JobThread::emitProgress ); connect( jobitem.job.data(), &Job::progress, this, &JobThread::emitProgress );
auto result = jobitem.job->exec(); auto result = jobitem.job->exec();

View File

@ -101,7 +101,7 @@ Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::E
YAML::Node doc = YAML::Load( ba.constData() ); YAML::Node doc = YAML::Load( ba.constData() );
if ( doc.IsNull() ) if ( doc.IsNull() )
{ {
cDebug() << "Found empty module configuration" << path; cWarning() << "Found empty module configuration" << path;
// Special case: empty config files are valid, // Special case: empty config files are valid,
// but aren't a map. // but aren't a map.
return; return;
@ -112,14 +112,13 @@ Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::E
return; return;
} }
cDebug() << "Loaded module configuration" << path;
m_configurationMap = CalamaresUtils::yamlMapToVariant( doc ); m_configurationMap = CalamaresUtils::yamlMapToVariant( doc );
m_emergency = m_maybe_emergency && m_configurationMap.contains( EMERGENCY ) m_emergency = m_maybe_emergency && m_configurationMap.contains( EMERGENCY )
&& m_configurationMap[ EMERGENCY ].toBool(); && m_configurationMap[ EMERGENCY ].toBool();
return; return;
} }
} }
cDebug() << "No config file for" << name() << "found anywhere at" << Logger::DebugList( configCandidates ); cWarning() << "No config file for" << name() << "found anywhere at" << Logger::DebugList( configCandidates );
} }

View File

@ -100,12 +100,10 @@ getInternal()
KPMManager::KPMManager() KPMManager::KPMManager()
: m_d( getInternal() ) : m_d( getInternal() )
{ {
cDebug() << "KPMManager" << s_backend.use_count() << "created.";
} }
KPMManager::~KPMManager() KPMManager::~KPMManager()
{ {
cDebug() << "KPMManager" << s_backend.use_count() << "being destroyed.";
} }
KPMManager::operator bool() const KPMManager::operator bool() const

View File

@ -169,7 +169,7 @@ System::runCommand( System::RunLocation location,
} }
} }
cDebug() << "Running" << program << RedactedList( arguments ); cDebug() << Logger::SubEntry << "Running" << program << RedactedList( arguments );
process.start(); process.start();
if ( !process.waitForStarted() ) if ( !process.waitForStarted() )
{ {
@ -208,10 +208,6 @@ System::runCommand( System::RunLocation location,
{ {
cDebug() << Logger::SubEntry << "Finished. Exit code:" << r << "output:\n" << Logger::NoQuote << output; cDebug() << Logger::SubEntry << "Finished. Exit code:" << r << "output:\n" << Logger::NoQuote << output;
} }
else
{
cDebug() << Logger::SubEntry << "Finished. Exit code:" << r;
}
} }
else // if ( r != 0 ) else // if ( r != 0 )
{ {

View File

@ -310,6 +310,14 @@ public:
} }
friend CDebug& operator<<( CDebug&&, const Once& ); friend CDebug& operator<<( CDebug&&, const Once& );
/** @brief Restore the object to "fresh" state
*
* It may be necessary to allow the Once object to stream the
* function header again -- for instance, after logging an error,
* any following debug log might want to re-introduce the header.
*/
void refresh() { m = true; }
private: private:
mutable bool m = false; mutable bool m = false;
}; };

View File

@ -126,23 +126,22 @@ canBeResized( Partition* candidate, const Logger::Once& o )
return false; return false;
} }
cDebug() << o << "Checking if" << convenienceName( candidate ) << "can be resized.";
if ( !candidate->fileSystem().supportGrow() || !candidate->fileSystem().supportShrink() ) if ( !candidate->fileSystem().supportGrow() || !candidate->fileSystem().supportShrink() )
{ {
cDebug() << Logger::SubEntry << "NO, filesystem" << candidate->fileSystem().name() cDebug() << o << "Can not resize" << convenienceName( candidate ) << ", filesystem"
<< "does not support resize."; << candidate->fileSystem().name() << "does not support resize.";
return false; return false;
} }
if ( isPartitionFreeSpace( candidate ) ) if ( isPartitionFreeSpace( candidate ) )
{ {
cDebug() << Logger::SubEntry << "NO, partition is free space"; cDebug() << o << "Can not resize" << convenienceName( candidate ) << ", partition is free space";
return false; return false;
} }
if ( candidate->isMounted() ) if ( candidate->isMounted() )
{ {
cDebug() << Logger::SubEntry << "NO, partition is mounted"; cDebug() << o << "Can not resize" << convenienceName( candidate ) << ", partition is mounted";
return false; return false;
} }
@ -151,14 +150,14 @@ canBeResized( Partition* candidate, const Logger::Once& o )
PartitionTable* table = dynamic_cast< PartitionTable* >( candidate->parent() ); PartitionTable* table = dynamic_cast< PartitionTable* >( candidate->parent() );
if ( !table ) if ( !table )
{ {
cDebug() << Logger::SubEntry << "NO, no partition table found"; cDebug() << o << "Can not resize" << convenienceName( candidate ) << ", no partition table found";
return false; return false;
} }
if ( table->numPrimaries() >= table->maxPrimaries() ) if ( table->numPrimaries() >= table->maxPrimaries() )
{ {
cDebug() << Logger::SubEntry << "NO, partition table already has" << table->maxPrimaries() cDebug() << o << "Can not resize" << convenienceName( candidate ) << ", partition table already has"
<< "primary partitions."; << table->maxPrimaries() << "primary partitions.";
return false; return false;
} }
} }
@ -167,7 +166,8 @@ canBeResized( Partition* candidate, const Logger::Once& o )
double requiredStorageGiB = getRequiredStorageGiB( ok ); double requiredStorageGiB = getRequiredStorageGiB( ok );
if ( !ok ) if ( !ok )
{ {
cDebug() << Logger::SubEntry << "NO, requiredStorageGiB is not set correctly."; cDebug() << o << "Can not resize" << convenienceName( candidate )
<< ", requiredStorageGiB is not set correctly.";
return false; return false;
} }
@ -200,24 +200,25 @@ canBeResized( Partition* candidate, const Logger::Once& o )
bool bool
canBeResized( DeviceModel* dm, const QString& partitionPath, const Logger::Once& o ) canBeResized( DeviceModel* dm, const QString& partitionPath, const Logger::Once& o )
{ {
cDebug() << o << "Checking if" << partitionPath << "can be resized."; if ( partitionPath.startsWith( "/dev/" ) )
QString partitionWithOs = partitionPath;
if ( partitionWithOs.startsWith( "/dev/" ) )
{ {
for ( int i = 0; i < dm->rowCount(); ++i ) for ( int i = 0; i < dm->rowCount(); ++i )
{ {
Device* dev = dm->deviceForIndex( dm->index( i ) ); Device* dev = dm->deviceForIndex( dm->index( i ) );
Partition* candidate = CalamaresUtils::Partition::findPartitionByPath( { dev }, partitionWithOs ); Partition* candidate = CalamaresUtils::Partition::findPartitionByPath( { dev }, partitionPath );
if ( candidate ) if ( candidate )
{ {
return canBeResized( candidate, o ); return canBeResized( candidate, o );
} }
} }
cDebug() << Logger::SubEntry << "no Partition* found for" << partitionWithOs; cWarning() << "Can not resize" << partitionPath << ", no Partition* found.";
}
cDebug() << Logger::SubEntry << "Partition" << partitionWithOs << "CANNOT BE RESIZED FOR AUTOINSTALL.";
return false; return false;
}
else
{
cWarning() << "Can not resize" << partitionPath << ", does not start with /dev";
return false;
}
} }
@ -250,8 +251,6 @@ lookForFstabEntries( const QString& partitionPath )
{ {
QFile fstabFile( mount.path() + "/etc/fstab" ); QFile fstabFile( mount.path() + "/etc/fstab" );
cDebug() << Logger::SubEntry << "reading" << fstabFile.fileName();
if ( fstabFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) if ( fstabFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
{ {
const QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() ).split( '\n' ); const QStringList fstabLines = QString::fromLocal8Bit( fstabFile.readAll() ).split( '\n' );
@ -261,10 +260,11 @@ lookForFstabEntries( const QString& partitionPath )
fstabEntries.append( FstabEntry::fromEtcFstab( rawLine ) ); fstabEntries.append( FstabEntry::fromEtcFstab( rawLine ) );
} }
fstabFile.close(); fstabFile.close();
cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "lines."; const int lineCount = fstabEntries.count();
std::remove_if( std::remove_if(
fstabEntries.begin(), fstabEntries.end(), []( const FstabEntry& x ) { return !x.isValid(); } ); fstabEntries.begin(), fstabEntries.end(), []( const FstabEntry& x ) { return !x.isValid(); } );
cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "fstab entries."; cDebug() << Logger::SubEntry << "got" << fstabEntries.count() << "fstab entries from" << lineCount
<< "lines in" << fstabFile.fileName();
} }
else else
{ {