|
|
@ -17,14 +17,26 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "Settings.h"
|
|
|
|
#include "Settings.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "CalamaresApplication.h"
|
|
|
|
#include "utils/CalamaresUtils.h"
|
|
|
|
#include "utils/CalamaresUtils.h"
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <yaml-cpp/yaml.h>
|
|
|
|
#include <QJsonObject>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
operator>>( const YAML::Node& node, QStringList& v )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for ( int i = 0; i < node.size(); ++i )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
v.append( QString::fromStdString( node[ i ].as< std::string >() ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Calamares
|
|
|
|
namespace Calamares
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -41,55 +53,45 @@ Settings::instance()
|
|
|
|
Settings::Settings( QObject* parent )
|
|
|
|
Settings::Settings( QObject* parent )
|
|
|
|
: QObject( parent )
|
|
|
|
: QObject( parent )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QFile file( CalamaresUtils::appDataDir().absoluteFilePath( "settings.json" ) );
|
|
|
|
QFileInfo settingsFile( CalamaresUtils::appDataDir().absoluteFilePath( "settings.conf" ) );
|
|
|
|
if ( file.exists() && file.canReadLine() )
|
|
|
|
if ( APP->isDebug() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QByteArray ba = file.readAll();
|
|
|
|
QFileInfo localFile( QDir( QDir::currentPath() ).absoluteFilePath( "settings.conf" ) );
|
|
|
|
QJsonParseError* err = 0;
|
|
|
|
if ( localFile.exists() && localFile.isReadable() )
|
|
|
|
QJsonDocument document = QJsonDocument::fromJson( ba, err );
|
|
|
|
settingsFile.setFile( localFile.absoluteFilePath() );
|
|
|
|
if ( !err && !document.isNull() && !document.isEmpty() )
|
|
|
|
}
|
|
|
|
{
|
|
|
|
QFile file( settingsFile.absoluteFilePath() );
|
|
|
|
QJsonObject json = document.object();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ( const QJsonValue& val, json[ "modules-search" ].toArray() )
|
|
|
|
if ( file.exists() && file.open( QFile::ReadOnly | QFile::Text ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !val.isString() || val.toString().isEmpty() )
|
|
|
|
QByteArray ba = file.readAll();
|
|
|
|
continue;
|
|
|
|
cDebug() << ba;
|
|
|
|
|
|
|
|
|
|
|
|
QString entry = val.toString();
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
YAML::Node config = YAML::Load( ba.constData() );
|
|
|
|
|
|
|
|
Q_ASSERT( config.IsMap() );
|
|
|
|
|
|
|
|
|
|
|
|
if ( entry == "local" )
|
|
|
|
QStringList rawPaths;
|
|
|
|
|
|
|
|
config[ "modules-search" ] >> rawPaths;
|
|
|
|
|
|
|
|
for ( int i = 0; i < rawPaths.length(); ++i )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( rawPaths[ i ] == "local" )
|
|
|
|
m_modulesSearchPaths.append( CalamaresUtils::appDataDir().absolutePath() + QDir::separator() + "modules" );
|
|
|
|
m_modulesSearchPaths.append( CalamaresUtils::appDataDir().absolutePath() + QDir::separator() + "modules" );
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QDir path( entry );
|
|
|
|
QDir path( rawPaths[ i ] );
|
|
|
|
if ( path.exists() && path.isReadable() )
|
|
|
|
if ( path.exists() && path.isReadable() )
|
|
|
|
m_modulesSearchPaths.append( path.absolutePath() );
|
|
|
|
m_modulesSearchPaths.append( path.absolutePath() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach ( const QJsonValue& val, json[ "modules-prepare" ].toArray() )
|
|
|
|
config[ "modules-prepare" ] >> m_viewModulesPrepareList;
|
|
|
|
{
|
|
|
|
config[ "modules-postinstall" ] >> m_viewModulesPostInstallList;
|
|
|
|
if ( !val.isString() || val.toString().isEmpty() )
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_viewModulesPrepareList.append( val.toString() );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch( YAML::Exception& e )
|
|
|
|
foreach ( const QJsonValue& val, json[ "modules-postinstall" ].toArray() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( !val.isString() || val.toString().isEmpty() )
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_viewModulesPostInstallList.append( val.toString() );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cDebug() << "WARNING: Invalid document " << file.fileName()
|
|
|
|
cDebug() << "WARNING: YAML parser error " << e.what();
|
|
|
|
<< " error: " << err->errorString();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|