mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-25 16:38:21 -04:00
Merge branch 'more-configuration-dirs'
This commit is contained in:
commit
4eba91b8e9
5 changed files with 71 additions and 0 deletions
|
@ -145,6 +145,9 @@ qmlDirCandidates( bool assumeBuilddir )
|
||||||
{
|
{
|
||||||
if ( assumeBuilddir )
|
if ( assumeBuilddir )
|
||||||
qmlDirs << QDir::current().absoluteFilePath( "src/qml" ); // In build-dir
|
qmlDirs << QDir::current().absoluteFilePath( "src/qml" ); // In build-dir
|
||||||
|
if ( CalamaresUtils::haveExtraDirs() )
|
||||||
|
for ( auto s : CalamaresUtils::extraDataDirs() )
|
||||||
|
qmlDirs << ( s + QML );
|
||||||
qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML );
|
qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +167,9 @@ settingsFileCandidates( bool assumeBuilddir )
|
||||||
{
|
{
|
||||||
if ( assumeBuilddir )
|
if ( assumeBuilddir )
|
||||||
settingsPaths << QDir::current().absoluteFilePath( settings );
|
settingsPaths << QDir::current().absoluteFilePath( settings );
|
||||||
|
if ( CalamaresUtils::haveExtraDirs() )
|
||||||
|
for ( auto s : CalamaresUtils::extraConfigDirs() )
|
||||||
|
settingsPaths << ( s + settings );
|
||||||
settingsPaths << CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/settings.conf"; // String concat
|
settingsPaths << CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/settings.conf"; // String concat
|
||||||
settingsPaths << CalamaresUtils::appDataDir().absoluteFilePath( settings );
|
settingsPaths << CalamaresUtils::appDataDir().absoluteFilePath( settings );
|
||||||
}
|
}
|
||||||
|
@ -182,6 +188,9 @@ brandingFileCandidates( bool assumeBuilddir, const QString& brandingFilename )
|
||||||
{
|
{
|
||||||
if ( assumeBuilddir )
|
if ( assumeBuilddir )
|
||||||
brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename );
|
brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename );
|
||||||
|
if ( CalamaresUtils::haveExtraDirs() )
|
||||||
|
for ( auto s : CalamaresUtils::extraDataDirs() )
|
||||||
|
brandingPaths << ( s + brandingFilename );
|
||||||
brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename );
|
brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename );
|
||||||
brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename);
|
brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ handle_args( CalamaresApplication& a )
|
||||||
"Verbose output for debugging purposes (0-8).", "level" );
|
"Verbose output for debugging purposes (0-8).", "level" );
|
||||||
QCommandLineOption configOption( QStringList{ "c", "config"},
|
QCommandLineOption configOption( QStringList{ "c", "config"},
|
||||||
"Configuration directory to use, for testing purposes.", "config" );
|
"Configuration directory to use, for testing purposes.", "config" );
|
||||||
|
QCommandLineOption xdgOption( QStringList{"X", "xdg-config"},
|
||||||
|
"Use XDG_{CONFIG,DATA}_DIRS as well." );
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription( "Distribution-independent installer framework" );
|
parser.setApplicationDescription( "Distribution-independent installer framework" );
|
||||||
|
@ -53,6 +55,7 @@ handle_args( CalamaresApplication& a )
|
||||||
parser.addOption( debugOption );
|
parser.addOption( debugOption );
|
||||||
parser.addOption( debugLevelOption );
|
parser.addOption( debugLevelOption );
|
||||||
parser.addOption( configOption );
|
parser.addOption( configOption );
|
||||||
|
parser.addOption( xdgOption );
|
||||||
|
|
||||||
parser.process( a );
|
parser.process( a );
|
||||||
|
|
||||||
|
@ -72,6 +75,8 @@ handle_args( CalamaresApplication& a )
|
||||||
}
|
}
|
||||||
if ( parser.isSet( configOption ) )
|
if ( parser.isSet( configOption ) )
|
||||||
CalamaresUtils::setAppDataDir( QDir( parser.value( configOption ) ) );
|
CalamaresUtils::setAppDataDir( QDir( parser.value( configOption ) ) );
|
||||||
|
if ( parser.isSet( xdgOption ) )
|
||||||
|
CalamaresUtils::setXdgDirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -49,6 +49,9 @@ static QTranslator* s_brandingTranslator = nullptr;
|
||||||
static QTranslator* s_translator = nullptr;
|
static QTranslator* s_translator = nullptr;
|
||||||
static QString s_translatorLocaleName;
|
static QString s_translatorLocaleName;
|
||||||
|
|
||||||
|
static bool s_haveExtraDirs = false;
|
||||||
|
static QStringList s_extraConfigDirs;
|
||||||
|
static QStringList s_extraDataDirs;
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
isWritableDir( const QDir& dir )
|
isWritableDir( const QDir& dir )
|
||||||
|
@ -94,6 +97,46 @@ setAppDataDir( const QDir& dir )
|
||||||
s_isAppDataDirOverridden = true;
|
s_isAppDataDirOverridden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Split $ENV{@p name} on :, append to @p l, making sure each ends in / */
|
||||||
|
static void
|
||||||
|
mungeEnvironment( QStringList& l, const char *name )
|
||||||
|
{
|
||||||
|
for ( auto s : QString( qgetenv( name ) ).split(':') )
|
||||||
|
if ( s.endsWith( '/' ) )
|
||||||
|
l << s;
|
||||||
|
else
|
||||||
|
l << ( s + '/' );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setXdgDirs()
|
||||||
|
{
|
||||||
|
s_haveExtraDirs = true;
|
||||||
|
mungeEnvironment( s_extraConfigDirs, "XDG_CONFIG_DIRS" );
|
||||||
|
mungeEnvironment( s_extraDataDirs, "XDG_DATA_DIRS" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
extraConfigDirs()
|
||||||
|
{
|
||||||
|
if ( s_haveExtraDirs )
|
||||||
|
return s_extraConfigDirs;
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
extraDataDirs()
|
||||||
|
{
|
||||||
|
if ( s_haveExtraDirs )
|
||||||
|
return s_extraDataDirs;
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
haveExtraDirs()
|
||||||
|
{
|
||||||
|
return s_haveExtraDirs && ( !s_extraConfigDirs.isEmpty() || !s_extraDataDirs.isEmpty() );
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isAppDataDirOverridden()
|
isAppDataDirOverridden()
|
||||||
|
|
|
@ -79,6 +79,16 @@ namespace CalamaresUtils
|
||||||
|
|
||||||
DLLEXPORT void setQmlModulesDir( const QDir& dir );
|
DLLEXPORT void setQmlModulesDir( const QDir& dir );
|
||||||
|
|
||||||
|
/** @brief Setup extra config and data dirs from the XDG variables.
|
||||||
|
*/
|
||||||
|
DLLEXPORT void setXdgDirs();
|
||||||
|
/** @brief Are any extra directories configured? */
|
||||||
|
DLLEXPORT bool haveExtraDirs();
|
||||||
|
/** @brief XDG_CONFIG_DIRS, each guaranteed to end with / */
|
||||||
|
DLLEXPORT QStringList extraConfigDirs();
|
||||||
|
/** @brief XDG_DATA_DIRS, each guaranteed to end with / */
|
||||||
|
DLLEXPORT QStringList extraDataDirs();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief removeDiacritics replaces letters with diacritics and ligatures with
|
* @brief removeDiacritics replaces letters with diacritics and ligatures with
|
||||||
* alternative forms and digraphs.
|
* alternative forms and digraphs.
|
||||||
|
|
|
@ -155,6 +155,10 @@ moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, c
|
||||||
if ( assumeBuildDir && configFileName.contains( '/' ) )
|
if ( assumeBuildDir && configFileName.contains( '/' ) )
|
||||||
paths << QDir().absoluteFilePath( configFileName );
|
paths << QDir().absoluteFilePath( configFileName );
|
||||||
|
|
||||||
|
if ( CalamaresUtils::haveExtraDirs() )
|
||||||
|
for ( auto s : CalamaresUtils::extraConfigDirs() )
|
||||||
|
paths << ( s + QString( "modules/%1" ).arg( configFileName ) );
|
||||||
|
|
||||||
paths << QString( "/etc/calamares/modules/%1" ).arg( configFileName );
|
paths << QString( "/etc/calamares/modules/%1" ).arg( configFileName );
|
||||||
paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );
|
paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue