Commit 4623e986 authored by Aard's avatar Aard

Split out repository variable resolving

parent 6e74dc45
......@@ -170,47 +170,59 @@ void SsuRepoManager::update(){
}
}
// RND repos have flavour (devel, testing, release), and release (latest, next)
// Release repos only have release (latest, next, version number)
QString SsuRepoManager::url(QString repoName, bool rndRepo,
QHash<QString, QString> repoParameters,
QHash<QString, QString> parametersOverride){
QString r;
QStringList configSections;
QStringList SsuRepoManager::repoVariables(QHash<QString, QString> *storageHash, bool rnd){
SsuVariables var;
SsuLog *ssuLog = SsuLog::instance();
SsuCoreConfig *settings = SsuCoreConfig::instance();
QSettings *repoSettings = new QSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuDeviceInfo deviceInfo;
QStringList configSections;
QSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
//QSettings *repoSettings = new QSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
// fill in all arbitrary variables from ssu.ini
var.resolveSection(settings, "repository-url-variables", &repoParameters);
var.resolveSection(settings, "repository-url-variables", storageHash);
// add/overwrite some of the variables with sane ones
if (rndRepo){
repoParameters.insert("flavour",
repoSettings->value(
if (rnd){
storageHash->insert("flavour",
repoSettings.value(
settings->flavour()+"-flavour/flavour-pattern").toString());
repoParameters.insert("flavourPattern",
repoSettings->value(
storageHash->insert("flavourPattern",
repoSettings.value(
settings->flavour()+"-flavour/flavour-pattern").toString());
repoParameters.insert("flavourName", settings->flavour());
storageHash->insert("flavourName", settings->flavour());
configSections << settings->flavour()+"-flavour" << "rnd" << "all";
// Make it possible to give any values with the flavour as well.
// These values can be overridden later with domain if needed.
var.resolveSection(repoSettings, settings->flavour()+"-flavour", &repoParameters);
var.resolveSection(&repoSettings, settings->flavour()+"-flavour", storageHash);
} else {
configSections << "release" << "all";
}
repoParameters.insert("release", settings->release(rndRepo));
storageHash->insert("release", settings->release(rnd));
if (!repoParameters.contains("debugSplit"))
repoParameters.insert("debugSplit", "packages");
if (!storageHash->contains("debugSplit"))
storageHash->insert("debugSplit", "packages");
if (!storageHash->contains("arch"))
storageHash->insert("arch", settings->value("arch").toString());
return configSections;
}
// RND repos have flavour (devel, testing, release), and release (latest, next)
// Release repos only have release (latest, next, version number)
QString SsuRepoManager::url(QString repoName, bool rndRepo,
QHash<QString, QString> repoParameters,
QHash<QString, QString> parametersOverride){
QString r;
QStringList configSections;
SsuVariables var;
SsuLog *ssuLog = SsuLog::instance();
SsuCoreConfig *settings = SsuCoreConfig::instance();
QSettings repoSettings(SSU_REPO_CONFIGURATION, QSettings::IniFormat);
SsuDeviceInfo deviceInfo;
if (!repoParameters.contains("arch"))
repoParameters.insert("arch", settings->value("arch").toString());
configSections = repoVariables(&repoParameters, rndRepo);
// Override device model (and therefore all the family, ... stuff)
if (parametersOverride.contains("model"))
......@@ -223,10 +235,10 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
// Domain variables
// first read all variables from default-domain
var.resolveSection(repoSettings, "default-domain", &repoParameters);
var.resolveSection(&repoSettings, "default-domain", &repoParameters);
// then overwrite with domain specific things if that block is available
var.resolveSection(repoSettings, settings->domain()+"-domain", &repoParameters);
var.resolveSection(&repoSettings, settings->domain()+"-domain", &repoParameters);
// override arbitrary variables, mostly useful for generating mic URLs
QHash<QString, QString>::const_iterator i = parametersOverride.constBegin();
......@@ -239,13 +251,13 @@ QString SsuRepoManager::url(QString repoName, bool rndRepo,
r = settings->value("repository-urls/" + repoName).toString();
else {
foreach (const QString &section, configSections){
repoSettings->beginGroup(section);
if (repoSettings->contains(repoName)){
r = repoSettings->value(repoName).toString();
repoSettings->endGroup();
repoSettings.beginGroup(section);
if (repoSettings.contains(repoName)){
r = repoSettings.value(repoName).toString();
repoSettings.endGroup();
break;
}
repoSettings->endGroup();
repoSettings.endGroup();
}
}
......
......@@ -33,6 +33,14 @@ class SsuRepoManager: public QObject {
* Remove a repository
*/
void remove(QString repo);
/**
* Resolve repository specific variables, and store them in storageHash. Does
* not include adaptation specific variables, see SsuDeviceInfo::adaptationVariables
*
* Returns a list of sections in the configuration file that might contain repository
* URLs
*/
QStringList repoVariables(QHash<QString, QString> *storageHash, bool rnd=false);
/**
* Update the repository files on disk
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment