From a58857baa6f8c3271f08d7a0581be7d930a817ae Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Fri, 10 Oct 2014 18:18:59 +0200 Subject: [PATCH] Hook up the branding component code path in CalamaresApplication. --- src/calamares/CalamaresApplication.cpp | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index a3ff631af..17a8297ff 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -28,6 +28,7 @@ #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" #include "JobQueue.h" +#include "Branding.h" #include "Settings.h" #include "viewpages/ViewStep.h" #include "ViewManager.h" @@ -188,7 +189,69 @@ CalamaresApplication::initSettings() void CalamaresApplication::initBranding() { + QString brandingComponentName = Calamares::Settings::instance()->brandingComponentName(); + if ( brandingComponentName.simplified().isEmpty() ) + { + cLog() << "FATAL ERROR: branding component not set in settings.conf"; + ::exit( EXIT_FAILURE ); + } + + QString brandingDescriptorSubpath = QString( "branding/%1/branding.desc" ) + .arg( brandingComponentName ); + + QFileInfo brandingFile; + if ( CalamaresUtils::isAppDataDirOverridden() ) + { + brandingFile = QFileInfo( CalamaresUtils::appDataDir() + .absoluteFilePath( brandingDescriptorSubpath ) ); + if ( !brandingFile.exists() || !brandingFile.isReadable() ) + { + cLog() << "FATAL ERROR: 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 ) + { + QFileInfo pathFi( path ); + if ( pathFi.exists() && pathFi.isReadable() ) + { + brandingFile = pathFi; + break; + } + } + + if ( !brandingFile.exists() || !brandingFile.isReadable() ) + { + cLog() << "FATAL ERROR: 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 ); }