[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
|
void
|
||||||
CalamaresApplication::initQmlPath()
|
CalamaresApplication::initQmlPath()
|
||||||
{
|
{
|
||||||
@ -250,40 +271,11 @@ 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;
|
||||||
{
|
|
||||||
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 ) );
|
|
||||||
|
|
||||||
foreach ( const QString& path, brandingFileCandidatesByPriority )
|
foreach ( const QString& path, brandingFileCandidatesByPriority )
|
||||||
{
|
{
|
||||||
@ -291,19 +283,21 @@ CalamaresApplication::initBranding()
|
|||||||
if ( pathFi.exists() && pathFi.isReadable() )
|
if ( pathFi.exists() && pathFi.isReadable() )
|
||||||
{
|
{
|
||||||
brandingFile = pathFi;
|
brandingFile = pathFi;
|
||||||
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !brandingFile.exists() || !brandingFile.isReadable() )
|
if ( !found || !brandingFile.exists() || !brandingFile.isReadable() )
|
||||||
{
|
{
|
||||||
cError() << "FATAL: none of the expected branding descriptor file paths ("
|
cError() << "Cowardly refusing to continue startup without branding."
|
||||||
<< brandingFileCandidatesByPriority.join( ", " )
|
<< Logger::DebugList( brandingFileCandidatesByPriority );
|
||||||
<< ") contain a valid branding.desc file."
|
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||||
<< "\nCowardly refusing to continue startup without branding.";
|
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 );
|
::exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
new Calamares::Branding( brandingFile.absoluteFilePath(), this );
|
new Calamares::Branding( brandingFile.absoluteFilePath(), this );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user