[calamares] Refactor searching for branding descriptor
This commit is contained in:
parent
22ee24a5ad
commit
b0e55c059a
@ -172,6 +172,27 @@ settingsFileCandidates( bool assumeBuilddir )
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
@ -250,40 +271,11 @@ 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() )
|
||||
{
|
||||
brandingFile = QFileInfo( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( brandingDescriptorSubpath ) );
|
||||
if ( !brandingFile.exists() || !brandingFile.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 );
|
||||
}
|
||||
}
|
||||
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 ) );
|
||||
bool found = false;
|
||||
|
||||
foreach ( const QString& path, brandingFileCandidatesByPriority )
|
||||
{
|
||||
@ -291,19 +283,21 @@ CalamaresApplication::initBranding()
|
||||
if ( pathFi.exists() && pathFi.isReadable() )
|
||||
{
|
||||
brandingFile = pathFi;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !brandingFile.exists() || !brandingFile.isReadable() )
|
||||
if ( !found || !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.";
|
||||
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 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user