|
|
|
@ -133,60 +133,93 @@ CalamaresApplication::mainWindow()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CalamaresApplication::initQmlPath()
|
|
|
|
|
static QStringList
|
|
|
|
|
qmlDirCandidates( bool assumeBuilddir )
|
|
|
|
|
{
|
|
|
|
|
QDir importPath;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString subpath( "qml" );
|
|
|
|
|
static QStringList
|
|
|
|
|
settingsFileCandidates( bool assumeBuilddir )
|
|
|
|
|
{
|
|
|
|
|
static const char settings[] = "settings.conf";
|
|
|
|
|
|
|
|
|
|
QStringList settingsPaths;
|
|
|
|
|
if ( CalamaresUtils::isAppDataDirOverridden() )
|
|
|
|
|
settingsPaths << CalamaresUtils::appDataDir().absoluteFilePath( settings );
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
importPath = QDir( CalamaresUtils::appDataDir()
|
|
|
|
|
.absoluteFilePath( subpath ) );
|
|
|
|
|
if ( !importPath.exists() || !importPath.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 );
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
QStringList qmlDirCandidatesByPriority;
|
|
|
|
|
if ( isDebug() )
|
|
|
|
|
{
|
|
|
|
|
qmlDirCandidatesByPriority.append(
|
|
|
|
|
QDir::current().absoluteFilePath(
|
|
|
|
|
QString( "src/%1" )
|
|
|
|
|
.arg( subpath ) ) );
|
|
|
|
|
}
|
|
|
|
|
qmlDirCandidatesByPriority.append( CalamaresUtils::appDataDir()
|
|
|
|
|
.absoluteFilePath( subpath ) );
|
|
|
|
|
if ( assumeBuilddir )
|
|
|
|
|
brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename );
|
|
|
|
|
brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename );
|
|
|
|
|
brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ( const QString& path, qmlDirCandidatesByPriority )
|
|
|
|
|
{
|
|
|
|
|
QDir dir( path );
|
|
|
|
|
if ( dir.exists() && dir.isReadable() )
|
|
|
|
|
{
|
|
|
|
|
importPath = dir;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return brandingPaths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
CalamaresApplication::initQmlPath()
|
|
|
|
|
{
|
|
|
|
|
QDir importPath; // Right now, current-dir
|
|
|
|
|
QStringList qmlDirCandidatesByPriority = qmlDirCandidates( isDebug() );
|
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
|
|
if ( !importPath.exists() || !importPath.isReadable() )
|
|
|
|
|
foreach ( const QString& path, qmlDirCandidatesByPriority )
|
|
|
|
|
{
|
|
|
|
|
QDir dir( path );
|
|
|
|
|
if ( dir.exists() && dir.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
|
|
|
|
|
{
|
|
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
if ( !found || !settingsFile.exists() || !settingsFile.isReadable() )
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
if ( !found || !brandingFile.exists() || !brandingFile.isReadable() )
|
|
|
|
|
{
|
|
|
|
|
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 );
|
|
|
|
|