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
|
void
|
||||||
CalamaresApplication::initQmlPath()
|
CalamaresApplication::initQmlPath()
|
||||||
{
|
{
|
||||||
QDir importPath;
|
QDir importPath; // Right now, current-dir
|
||||||
|
QStringList qmlDirCandidatesByPriority = qmlDirCandidates( isDebug() );
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
QString subpath( "qml" );
|
foreach ( const QString& path, qmlDirCandidatesByPriority )
|
||||||
|
|
||||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
|
||||||
{
|
{
|
||||||
importPath = QDir( CalamaresUtils::appDataDir()
|
QDir dir( path );
|
||||||
.absoluteFilePath( subpath ) );
|
if ( dir.exists() && dir.isReadable() )
|
||||||
if ( !importPath.exists() || !importPath.isReadable() )
|
|
||||||
{
|
{
|
||||||
cError() << "FATAL: explicitly configured application data directory"
|
importPath = dir;
|
||||||
<< CalamaresUtils::appDataDir().absolutePath()
|
found = true;
|
||||||
<< "does not contain a valid QML modules directory at"
|
break;
|
||||||
<< 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 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 );
|
CalamaresUtils::setQmlModulesDir( importPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,51 +227,31 @@ CalamaresApplication::initQmlPath()
|
|||||||
void
|
void
|
||||||
CalamaresApplication::initSettings()
|
CalamaresApplication::initSettings()
|
||||||
{
|
{
|
||||||
|
QStringList settingsFileCandidatesByPriority = settingsFileCandidates( isDebug() );
|
||||||
|
|
||||||
QFileInfo settingsFile;
|
QFileInfo settingsFile;
|
||||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
bool found = false;
|
||||||
|
|
||||||
|
foreach ( const QString& path, settingsFileCandidatesByPriority )
|
||||||
{
|
{
|
||||||
settingsFile = QFileInfo( CalamaresUtils::appDataDir().absoluteFilePath( "settings.conf" ) );
|
QFileInfo pathFi( path );
|
||||||
if ( !settingsFile.exists() || !settingsFile.isReadable() )
|
if ( pathFi.exists() && pathFi.isReadable() )
|
||||||
{
|
{
|
||||||
cError() << "FATAL: explicitly configured application data directory"
|
settingsFile = pathFi;
|
||||||
<< CalamaresUtils::appDataDir().absolutePath()
|
found = true;
|
||||||
<< "does not contain a valid settings.conf file."
|
break;
|
||||||
<< "\nCowardly refusing to continue startup without settings.";
|
|
||||||
::exit( EXIT_FAILURE );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if ( !found || !settingsFile.exists() || !settingsFile.isReadable() )
|
||||||
{
|
{
|
||||||
QStringList settingsFileCandidatesByPriority;
|
cError() << "Cowardly refusing to continue startup without settings."
|
||||||
if ( isDebug() )
|
<< Logger::DebugList( settingsFileCandidatesByPriority );
|
||||||
{
|
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||||
settingsFileCandidatesByPriority.append(
|
cError() << "FATAL: explicitly configured application data directory is missing settings.conf";
|
||||||
QDir::currentPath() +
|
else
|
||||||
QDir::separator() +
|
cError() << "FATAL: none of the expected configuration file paths exist.";
|
||||||
"settings.conf" );
|
::exit( EXIT_FAILURE );
|
||||||
}
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new Calamares::Settings( settingsFile.absoluteFilePath(), isDebug(), this );
|
new Calamares::Settings( settingsFile.absoluteFilePath(), isDebug(), this );
|
||||||
@ -255,59 +268,32 @@ CalamaresApplication::initBranding()
|
|||||||
::exit( EXIT_FAILURE );
|
::exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString brandingDescriptorSubpath = QString( "branding/%1/branding.desc" )
|
QString brandingDescriptorSubpath = QString( "branding/%1/branding.desc" ).arg( brandingComponentName );
|
||||||
.arg( brandingComponentName );
|
QStringList brandingFileCandidatesByPriority = brandingFileCandidates( isDebug(), brandingDescriptorSubpath);
|
||||||
|
|
||||||
QFileInfo brandingFile;
|
QFileInfo brandingFile;
|
||||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
bool found = false;
|
||||||
|
|
||||||
|
foreach ( const QString& path, brandingFileCandidatesByPriority )
|
||||||
{
|
{
|
||||||
brandingFile = QFileInfo( CalamaresUtils::appDataDir()
|
QFileInfo pathFi( path );
|
||||||
.absoluteFilePath( brandingDescriptorSubpath ) );
|
if ( pathFi.exists() && pathFi.isReadable() )
|
||||||
if ( !brandingFile.exists() || !brandingFile.isReadable() )
|
|
||||||
{
|
{
|
||||||
cError() << "FATAL: explicitly configured application data directory"
|
brandingFile = pathFi;
|
||||||
<< CalamaresUtils::appDataDir().absolutePath()
|
found = true;
|
||||||
<< "does not contain a valid branding component descriptor at"
|
break;
|
||||||
<< brandingFile.absoluteFilePath()
|
|
||||||
<< "\nCowardly refusing to continue startup without branding.";
|
|
||||||
::exit( EXIT_FAILURE );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if ( !found || !brandingFile.exists() || !brandingFile.isReadable() )
|
||||||
{
|
{
|
||||||
QStringList brandingFileCandidatesByPriority;
|
cError() << "Cowardly refusing to continue startup without branding."
|
||||||
if ( isDebug() )
|
<< Logger::DebugList( brandingFileCandidatesByPriority );
|
||||||
{
|
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||||
brandingFileCandidatesByPriority.append(
|
cError() << "FATAL: explicitly configured application data directory is missing" << brandingComponentName;
|
||||||
QDir::currentPath() +
|
else
|
||||||
QDir::separator() +
|
cError() << "FATAL: none of the expected branding descriptor file paths exist.";
|
||||||
"src" +
|
::exit( EXIT_FAILURE );
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new Calamares::Branding( brandingFile.absoluteFilePath(), this );
|
new Calamares::Branding( brandingFile.absoluteFilePath(), this );
|
||||||
|
@ -108,7 +108,14 @@ main( int argc, char* argv[] )
|
|||||||
returnCode = a.exec();
|
returnCode = a.exec();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
auto instancelist = guard.instances();
|
||||||
qDebug() << "Calamares is already running, shutting down.";
|
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;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,6 @@
|
|||||||
#include <QString>
|
#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";
|
static const char EMERGENCY[] = "emergency";
|
||||||
|
|
||||||
namespace Calamares
|
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
|
void
|
||||||
Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception
|
Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Exception
|
||||||
{
|
{
|
||||||
QStringList configFilesByPriority;
|
foreach ( const QString& path, moduleConfigurationCandidates( Settings::instance()->debugMode(), m_name, configFileName ) )
|
||||||
|
|
||||||
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 )
|
|
||||||
{
|
{
|
||||||
QFile configFile( path );
|
QFile configFile( path );
|
||||||
if ( configFile.exists() && configFile.open( QFile::ReadOnly | QFile::Text ) )
|
if ( configFile.exists() && configFile.open( QFile::ReadOnly | QFile::Text ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user