[calamares] Better config-loading diagnostics
- Be more verbose when things go wrong while loading module- configuration files. - Allow more forms of paths to be specified. In debug mode, this is mostyle helpful for the module test-loader.
This commit is contained in:
parent
c6e8cdf65b
commit
39a0d2315b
@ -145,8 +145,15 @@ moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, c
|
|||||||
paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );
|
paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// If an absolute path is given, in debug mode, look for it
|
||||||
|
// first. The case contains('/'), below, will add the absolute
|
||||||
|
// path a second time, though.
|
||||||
|
if ( assumeBuildDir && configFileName.startsWith( '/' ) )
|
||||||
|
paths << configFileName;
|
||||||
if ( assumeBuildDir )
|
if ( assumeBuildDir )
|
||||||
paths << QDir().absoluteFilePath(QString( "src/modules/%1/%2" ).arg( moduleName ).arg( configFileName ) );
|
paths << QDir().absoluteFilePath(QString( "src/modules/%1/%2" ).arg( moduleName ).arg( configFileName ) );
|
||||||
|
if ( assumeBuildDir && configFileName.contains( '/' ) )
|
||||||
|
paths << QDir().absoluteFilePath( configFileName );
|
||||||
|
|
||||||
paths << QString( "/etc/calamares/modules/%1" ).arg( configFileName );
|
paths << QString( "/etc/calamares/modules/%1" ).arg( configFileName );
|
||||||
paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );
|
paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );
|
||||||
@ -168,6 +175,7 @@ Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Ex
|
|||||||
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;
|
||||||
// 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;
|
||||||
@ -178,14 +186,13 @@ Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Ex
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cDebug() << "Loaded module configuration" << path;
|
||||||
m_configurationMap = CalamaresUtils::yamlMapToVariant( doc ).toMap();
|
m_configurationMap = CalamaresUtils::yamlMapToVariant( doc ).toMap();
|
||||||
m_emergency = m_maybe_emergency
|
m_emergency = m_maybe_emergency
|
||||||
&& m_configurationMap.contains( EMERGENCY )
|
&& m_configurationMap.contains( EMERGENCY )
|
||||||
&& m_configurationMap[ EMERGENCY ].toBool();
|
&& m_configurationMap[ EMERGENCY ].toBool();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user