[libcalamares] Warn more about badly-formed config
This commit is contained in:
parent
49622a6a30
commit
a732ce11bc
@ -30,6 +30,32 @@
|
|||||||
#include <yaml-cpp/yaml.h>
|
#include <yaml-cpp/yaml.h>
|
||||||
|
|
||||||
|
|
||||||
|
/** Helper function to grab a QString out of the config, and to warn if not present. */
|
||||||
|
static QString
|
||||||
|
requireString( const YAML::Node& config, const char* key )
|
||||||
|
{
|
||||||
|
if ( config[ key ] )
|
||||||
|
return QString::fromStdString( config[ key ].as< std::string >() );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cWarning() << "Required settings.conf key" << key << "is missing.";
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Helper function to grab a bool out of the config, and to warn if not present. */
|
||||||
|
static bool
|
||||||
|
requireBool( const YAML::Node& config, const char* key, bool d )
|
||||||
|
{
|
||||||
|
if ( config[ key ] )
|
||||||
|
return config[ key ].as< bool >();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cWarning() << "Required settings.conf key" << key << "is missing.";
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -41,7 +67,6 @@ Settings::instance()
|
|||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Settings::Settings( const QString& settingsFilePath,
|
Settings::Settings( const QString& settingsFilePath,
|
||||||
bool debugMode,
|
bool debugMode,
|
||||||
QObject* parent )
|
QObject* parent )
|
||||||
@ -148,11 +173,9 @@ Settings::Settings( const QString& settingsFilePath,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_brandingComponentName = QString::fromStdString( config[ "branding" ]
|
m_brandingComponentName = requireString( config, "branding" );
|
||||||
.as< std::string >() );
|
m_promptInstall = requireBool( config, "prompt-install", false );
|
||||||
m_promptInstall = config[ "prompt-install" ].as< bool >();
|
m_doChroot = requireBool( config, "dont-chroot", true );
|
||||||
|
|
||||||
m_doChroot = config[ "dont-chroot" ] ? !config[ "dont-chroot" ].as< bool >() : true;
|
|
||||||
}
|
}
|
||||||
catch ( YAML::Exception& e )
|
catch ( YAML::Exception& e )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user