Merge branch 'master' into update-lvm-support
This commit is contained in:
commit
ba639beb9a
@ -133,60 +133,93 @@ CalamaresApplication::mainWindow()
|
||||
}
|
||||
|
||||
|
||||
static QStringList
|
||||
qmlDirCandidates( bool assumeBuilddir )
|
||||
{
|
||||
static const char QML[] = "qml";
|
||||
|
||||
QStringList qmlDirs;
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML );
|
||||
else
|
||||
{
|
||||
if ( assumeBuilddir )
|
||||
qmlDirs << QDir::current().absoluteFilePath( "src/qml" ); // In build-dir
|
||||
qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML );
|
||||
}
|
||||
|
||||
return qmlDirs;
|
||||
}
|
||||
|
||||
|
||||
static QStringList
|
||||
settingsFileCandidates( bool assumeBuilddir )
|
||||
{
|
||||
static const char settings[] = "settings.conf";
|
||||
|
||||
QStringList settingsPaths;
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
settingsPaths << CalamaresUtils::appDataDir().absoluteFilePath( settings );
|
||||
else
|
||||
{
|
||||
if ( assumeBuilddir )
|
||||
settingsPaths << QDir::current().absoluteFilePath( settings );
|
||||
settingsPaths << CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/settings.conf"; // String concat
|
||||
settingsPaths << CalamaresUtils::appDataDir().absoluteFilePath( settings );
|
||||
}
|
||||
|
||||
return settingsPaths;
|
||||
}
|
||||
|
||||
|
||||
static QStringList
|
||||
brandingFileCandidates( bool assumeBuilddir, const QString& brandingFilename )
|
||||
{
|
||||
QStringList brandingPaths;
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename );
|
||||
else
|
||||
{
|
||||
if ( assumeBuilddir )
|
||||
brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename );
|
||||
brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename );
|
||||
brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename);
|
||||
}
|
||||
|
||||
return brandingPaths;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CalamaresApplication::initQmlPath()
|
||||
{
|
||||
QDir importPath;
|
||||
QDir importPath; // Right now, current-dir
|
||||
QStringList qmlDirCandidatesByPriority = qmlDirCandidates( isDebug() );
|
||||
bool found = false;
|
||||
|
||||
QString subpath( "qml" );
|
||||
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
foreach ( const QString& path, qmlDirCandidatesByPriority )
|
||||
{
|
||||
importPath = QDir( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( subpath ) );
|
||||
if ( !importPath.exists() || !importPath.isReadable() )
|
||||
QDir dir( path );
|
||||
if ( dir.exists() && dir.isReadable() )
|
||||
{
|
||||
cError() << "FATAL: explicitly configured application data directory"
|
||||
<< CalamaresUtils::appDataDir().absolutePath()
|
||||
<< "does not contain a valid QML modules directory at"
|
||||
<< importPath.absolutePath()
|
||||
<< "\nCowardly refusing to continue startup without the QML directory.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList qmlDirCandidatesByPriority;
|
||||
if ( isDebug() )
|
||||
{
|
||||
qmlDirCandidatesByPriority.append(
|
||||
QDir::current().absoluteFilePath(
|
||||
QString( "src/%1" )
|
||||
.arg( subpath ) ) );
|
||||
}
|
||||
qmlDirCandidatesByPriority.append( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( subpath ) );
|
||||
|
||||
foreach ( const QString& path, qmlDirCandidatesByPriority )
|
||||
{
|
||||
QDir dir( path );
|
||||
if ( dir.exists() && dir.isReadable() )
|
||||
{
|
||||
importPath = dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !importPath.exists() || !importPath.isReadable() )
|
||||
{
|
||||
cError() << "FATAL: none of the expected QML paths ("
|
||||
<< qmlDirCandidatesByPriority.join( ", " )
|
||||
<< ") exist."
|
||||
<< "\nCowardly refusing to continue startup without the QML directory.";
|
||||
::exit( EXIT_FAILURE );
|
||||
importPath = dir;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !found || !importPath.exists() || !importPath.isReadable() )
|
||||
{
|
||||
cError() << "Cowardly refusing to continue startup without a QML directory."
|
||||
<< Logger::DebugList( qmlDirCandidatesByPriority );
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
cError() << "FATAL: explicitly configured application data directory is missing qml/";
|
||||
else
|
||||
cError() << "FATAL: none of the expected QML paths exist.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
cDebug() << "Using Calamares QML directory" << importPath.absolutePath();
|
||||
CalamaresUtils::setQmlModulesDir( importPath );
|
||||
}
|
||||
|
||||
@ -194,51 +227,31 @@ CalamaresApplication::initQmlPath()
|
||||
void
|
||||
CalamaresApplication::initSettings()
|
||||
{
|
||||
QStringList settingsFileCandidatesByPriority = settingsFileCandidates( isDebug() );
|
||||
|
||||
QFileInfo settingsFile;
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
bool found = false;
|
||||
|
||||
foreach ( const QString& path, settingsFileCandidatesByPriority )
|
||||
{
|
||||
settingsFile = QFileInfo( CalamaresUtils::appDataDir().absoluteFilePath( "settings.conf" ) );
|
||||
if ( !settingsFile.exists() || !settingsFile.isReadable() )
|
||||
QFileInfo pathFi( path );
|
||||
if ( pathFi.exists() && pathFi.isReadable() )
|
||||
{
|
||||
cError() << "FATAL: explicitly configured application data directory"
|
||||
<< CalamaresUtils::appDataDir().absolutePath()
|
||||
<< "does not contain a valid settings.conf file."
|
||||
<< "\nCowardly refusing to continue startup without settings.";
|
||||
::exit( EXIT_FAILURE );
|
||||
settingsFile = pathFi;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if ( !found || !settingsFile.exists() || !settingsFile.isReadable() )
|
||||
{
|
||||
QStringList settingsFileCandidatesByPriority;
|
||||
if ( isDebug() )
|
||||
{
|
||||
settingsFileCandidatesByPriority.append(
|
||||
QDir::currentPath() +
|
||||
QDir::separator() +
|
||||
"settings.conf" );
|
||||
}
|
||||
settingsFileCandidatesByPriority.append( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/settings.conf" );
|
||||
settingsFileCandidatesByPriority.append( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( "settings.conf" ) );
|
||||
|
||||
foreach ( const QString& path, settingsFileCandidatesByPriority )
|
||||
{
|
||||
QFileInfo pathFi( path );
|
||||
if ( pathFi.exists() && pathFi.isReadable() )
|
||||
{
|
||||
settingsFile = pathFi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !settingsFile.exists() || !settingsFile.isReadable() )
|
||||
{
|
||||
cError() << "FATAL: none of the expected configuration file paths ("
|
||||
<< settingsFileCandidatesByPriority.join( ", " )
|
||||
<< ") contain a valid settings.conf file."
|
||||
<< "\nCowardly refusing to continue startup without settings.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
cError() << "Cowardly refusing to continue startup without settings."
|
||||
<< Logger::DebugList( settingsFileCandidatesByPriority );
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
cError() << "FATAL: explicitly configured application data directory is missing settings.conf";
|
||||
else
|
||||
cError() << "FATAL: none of the expected configuration file paths exist.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
new Calamares::Settings( settingsFile.absoluteFilePath(), isDebug(), this );
|
||||
@ -255,59 +268,32 @@ CalamaresApplication::initBranding()
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
QString brandingDescriptorSubpath = QString( "branding/%1/branding.desc" )
|
||||
.arg( brandingComponentName );
|
||||
QString brandingDescriptorSubpath = QString( "branding/%1/branding.desc" ).arg( brandingComponentName );
|
||||
QStringList brandingFileCandidatesByPriority = brandingFileCandidates( isDebug(), brandingDescriptorSubpath);
|
||||
|
||||
QFileInfo brandingFile;
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
bool found = false;
|
||||
|
||||
foreach ( const QString& path, brandingFileCandidatesByPriority )
|
||||
{
|
||||
brandingFile = QFileInfo( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( brandingDescriptorSubpath ) );
|
||||
if ( !brandingFile.exists() || !brandingFile.isReadable() )
|
||||
QFileInfo pathFi( path );
|
||||
if ( pathFi.exists() && pathFi.isReadable() )
|
||||
{
|
||||
cError() << "FATAL: explicitly configured application data directory"
|
||||
<< CalamaresUtils::appDataDir().absolutePath()
|
||||
<< "does not contain a valid branding component descriptor at"
|
||||
<< brandingFile.absoluteFilePath()
|
||||
<< "\nCowardly refusing to continue startup without branding.";
|
||||
::exit( EXIT_FAILURE );
|
||||
brandingFile = pathFi;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if ( !found || !brandingFile.exists() || !brandingFile.isReadable() )
|
||||
{
|
||||
QStringList brandingFileCandidatesByPriority;
|
||||
if ( isDebug() )
|
||||
{
|
||||
brandingFileCandidatesByPriority.append(
|
||||
QDir::currentPath() +
|
||||
QDir::separator() +
|
||||
"src" +
|
||||
QDir::separator() +
|
||||
brandingDescriptorSubpath );
|
||||
}
|
||||
brandingFileCandidatesByPriority.append( QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" )
|
||||
.absoluteFilePath( brandingDescriptorSubpath ) );
|
||||
brandingFileCandidatesByPriority.append( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( brandingDescriptorSubpath ) );
|
||||
|
||||
foreach ( const QString& path, brandingFileCandidatesByPriority )
|
||||
{
|
||||
QFileInfo pathFi( path );
|
||||
if ( pathFi.exists() && pathFi.isReadable() )
|
||||
{
|
||||
brandingFile = pathFi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !brandingFile.exists() || !brandingFile.isReadable() )
|
||||
{
|
||||
cError() << "FATAL: none of the expected branding descriptor file paths ("
|
||||
<< brandingFileCandidatesByPriority.join( ", " )
|
||||
<< ") contain a valid branding.desc file."
|
||||
<< "\nCowardly refusing to continue startup without branding.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
cError() << "Cowardly refusing to continue startup without branding."
|
||||
<< Logger::DebugList( brandingFileCandidatesByPriority );
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
cError() << "FATAL: explicitly configured application data directory is missing" << brandingComponentName;
|
||||
else
|
||||
cError() << "FATAL: none of the expected branding descriptor file paths exist.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
new Calamares::Branding( brandingFile.absoluteFilePath(), this );
|
||||
|
@ -108,7 +108,14 @@ main( int argc, char* argv[] )
|
||||
returnCode = a.exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto instancelist = guard.instances();
|
||||
qDebug() << "Calamares is already running, shutting down.";
|
||||
if ( instancelist.count() > 0 )
|
||||
qDebug() << "Other running Calamares instances:";
|
||||
for ( const auto& i : instancelist )
|
||||
qDebug() << " " << i.isValid() << i.pid() << i.arguments();
|
||||
}
|
||||
|
||||
return returnCode;
|
||||
}
|
||||
|
@ -44,14 +44,6 @@
|
||||
#include <QString>
|
||||
|
||||
|
||||
// Example module.desc
|
||||
/*
|
||||
---
|
||||
type: "view" #job or view
|
||||
name: "foo" #the module name. must be unique and same as the parent directory
|
||||
interface: "qtplugin" #can be: qtplugin, python, process, ...
|
||||
*/
|
||||
|
||||
static const char EMERGENCY[] = "emergency";
|
||||
|
||||
namespace Calamares
|
||||
@ -144,34 +136,29 @@ Module::fromDescriptor( const QVariantMap& moduleDescriptor,
|
||||
}
|
||||
|
||||
|
||||
static QStringList
|
||||
moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, const QString& configFileName )
|
||||
{
|
||||
QStringList paths;
|
||||
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );
|
||||
else
|
||||
{
|
||||
if ( assumeBuildDir )
|
||||
paths << QDir().absoluteFilePath(QString( "src/modules/%1/%2" ).arg( moduleName ).arg( configFileName ) );
|
||||
|
||||
paths << QString( "/etc/calamares/modules/%1" ).arg( configFileName );
|
||||
paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
void
|
||||
Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception
|
||||
{
|
||||
QStringList configFilesByPriority;
|
||||
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
configFilesByPriority.append(
|
||||
CalamaresUtils::appDataDir().absoluteFilePath(
|
||||
QString( "modules/%1" ).arg( configFileName ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Settings::instance()->debugMode() )
|
||||
{
|
||||
configFilesByPriority.append(
|
||||
QDir( QDir::currentPath() ).absoluteFilePath(
|
||||
QString( "src/modules/%1/%2" ).arg( m_name ).arg( configFileName ) ) );
|
||||
}
|
||||
|
||||
configFilesByPriority.append(
|
||||
QString( "/etc/calamares/modules/%1" ).arg( configFileName ) );
|
||||
configFilesByPriority.append(
|
||||
CalamaresUtils::appDataDir().absoluteFilePath(
|
||||
QString( "modules/%2" ).arg( configFileName ) ) );
|
||||
}
|
||||
|
||||
foreach ( const QString& path, configFilesByPriority )
|
||||
foreach ( const QString& path, moduleConfigurationCandidates( Settings::instance()->debugMode(), m_name, configFileName ) )
|
||||
{
|
||||
QFile configFile( path );
|
||||
if ( configFile.exists() && configFile.open( QFile::ReadOnly | QFile::Text ) )
|
||||
|
Loading…
Reference in New Issue
Block a user