Commit 9879903c authored by Aard's avatar Aard

Start using adaptation-repos stringlist for adaptations, allow freeform variables for adaptations

parent f5f4f698
......@@ -24,14 +24,32 @@
# The found model (after resolving variants) will be used as category. The
# following keys are valid there:
# - family -- the device family, used for the family specific adaptation
# - adaptations -- list of additional adaptations, shared between families
# - adaptation-repos -- list of adaptation repositories for this family
#
# The value of adaptations gets converted into a QStringList, which uses
# commas as separator. If one of the adaptation names contains a comma it
# needs to be quoted:
# adaptation=foo
# adaptation="foo, bar", baz
# adaptation=foo, bar, baz
# The value of adaptation-repos gets converted into a QStringList, which
# uses commas as separator. If one of the adaptation names contains a comma
# it needs to be quoted:
# adaptation-repos=foo
# adaptation-repos="foo, bar", baz
# adaptation-repos=foo, bar, baz
#
# The adaptation list is used to create repo files for adaptation repos.
# A repository named 'adaptation0' operates on the first list element,
# 'adaptation2' on the 3rd, etc. The matching item in the list will be
# exported as adaptation variable.
#
# Freeform variable sections start with 'var-'. A variable section for an
# adaptation named 'n9xx' would be 'var-n9xx'. A variable section may
# contain freeform variables, or the keyword 'variables' to include any
# other section. Currently only one section may be included, and you may
# not specify additional variables:
#
# [var-n9]
# foo=bar
# bar=baz
#
# [var-n950]
# variables=n9
#
# The N9x mappings should be solved through sysinfo, but that's currently
# broken on Mer/Nemo
......@@ -54,17 +72,17 @@ N950=N9
[N9]
family=n950-n9
adaptations=n9xx
adaptation-repos=n9xx-common,n950-n9
[N900]
family=n900
adaptations=n9xx
adaptation-repos=n9xx-common,n900
[SDK]
[generic-x86]
family=x86
adaptations=x86
adaptation-repos=x86
[UNKNOWN]
family=UNKNOWN
......@@ -153,6 +153,7 @@ QString Ssu::repoUrl(QString repoName, bool rndRepo, QHash<QString, QString> rep
QString r;
QStringList configSections;
SsuVariables var;
SsuLog *ssuLog = SsuLog::instance();
errorFlag = false;
......@@ -181,19 +182,57 @@ QString Ssu::repoUrl(QString repoName, bool rndRepo, QHash<QString, QString> rep
if (!repoParameters.contains("arch"))
repoParameters.insert("arch", settings->value("arch").toString());
repoParameters.insert("adaptation", settings->value("adaptation").toString());
// todo: allow override of deviceModel for cli url resolving
QStringList adaptationRepos = deviceInfo.adaptationRepos();
// read adaptation from settings, in case it can't be determined from
// board mappings. this is obsolete, and will be dropped soon
if (settings->contains("adaptation"))
repoParameters.insert("adaptation", settings->value("adaptation").toString());
repoParameters.insert("deviceFamily", deviceInfo.deviceFamily());
repoParameters.insert("deviceModel", deviceInfo.deviceModel());
// Those keys have now been obsoleted by generic variables, support for
// it will be removed soon
QStringList keys;
keys << "chip" << "adaptation" << "vendor";
foreach(QString key, keys){
QString value;
if (deviceInfo.getValue(key,value))
repoParameters.insert(key, value);
}
// special handling for adaptation-repositories
// - check if repo is in right format (adaptation\d*)
// - check if the configuration has that many adaptation repos
// - export the entry in the adaptation list as %(adaptation)
// - look up variables for that adaptation, and export matching
// adaptation variable
QRegExp regex("adaptation\\\d*", Qt::CaseSensitive, QRegExp::RegExp2);
if (regex.exactMatch(repoName)){
regex.setPattern("\\\d*");
regex.lastIndexIn(repoName);
int n = regex.cap().toInt();
if (adaptationRepos.size() > n) {
QString adaptationRepo = adaptationRepos.at(n);
repoParameters.insert("adaptation", adaptationRepo);
ssuLog->print(LOG_DEBUG, "Found first adaptation " + repoName);
QHash<QString, QString> h = deviceInfo.variableSection(adaptationRepo);
QHash<QString, QString>::const_iterator i = h.constBegin();
while (i != h.constEnd()){
repoParameters.insert(i.key(), i.value());
i++;
}
} else
ssuLog->print(LOG_INFO, "Note: adaptation repo for invalid repo requested " + repoName);
repoName = "adaptation";
}
// Domain variables
// first read all variables from default-domain
var.resolveSection(repoSettings, "default-domain", &repoParameters);
......
......@@ -20,18 +20,28 @@ SsuDeviceInfo::SsuDeviceInfo(): QObject(){
boardMappings = new SsuSettings(SSU_BOARD_MAPPING_CONFIGURATION, SSU_BOARD_MAPPING_CONFIGURATION_DIR);
}
QString SsuDeviceInfo::deviceFamily(){
QString model = deviceModel();
QStringList SsuDeviceInfo::adaptationRepos(){
QStringList result;
QString model = deviceVariant();
if (model == "")
model = deviceModel();
if (boardMappings->contains(model + "/adaptation-repos"))
result = boardMappings->value(model + "/adaptation-repos").toStringList();
return result;
}
QString SsuDeviceInfo::deviceFamily(){
if (!cachedFamily.isEmpty())
return cachedFamily;
cachedFamily = "UNKNOWN";
QString model = deviceVariant();
if (model == "")
model = deviceModel();
if (boardMappings->contains("variants/" + model)) {
model = boardMappings->value("variants/" + model).toString();
cachedVariant = model;
}
cachedFamily = "UNKNOWN";
if (boardMappings->contains(model + "/family"))
cachedFamily = boardMappings->value(model + "/family").toString();
......@@ -143,6 +153,28 @@ QString SsuDeviceInfo::deviceUid(){
return IMEI;
}
QHash<QString, QString> SsuDeviceInfo::variableSection(QString section){
QHash<QString, QString> result;
if (!section.startsWith("var-"))
section = "var-" + section;
if (boardMappings->contains(section + "/variables")){
return variableSection(boardMappings->value(section + "/variables").toString());
}
boardMappings->beginGroup(section);
if (boardMappings->group() != section)
return result;
QStringList keys = boardMappings->allKeys();
foreach (const QString &key, keys){
result.insert(key, boardMappings->value(key).toString());
}
return result;
}
bool SsuDeviceInfo::getValue(const QString& key, QString& value){
if (boardMappings->contains(deviceVariant()+"/"+key)){
value = boardMappings->value(deviceVariant()+"/"+key).toString();
......@@ -154,3 +186,13 @@ bool SsuDeviceInfo::getValue(const QString& key, QString& value){
}
return false;
}
void SsuDeviceInfo::setDeviceModel(QString model){
if (model == "")
cachedModel = "";
else
cachedModel = model;
cachedFamily = "";
cachedVariant = "";
}
......@@ -18,6 +18,10 @@ class SsuDeviceInfo: public QObject {
public:
SsuDeviceInfo();
/**
* Return the list of adaptations used for the set model
*/
QStringList adaptationRepos();
/**
* Try to find the device family for the system this is running on
*/
......@@ -35,7 +39,19 @@ class SsuDeviceInfo: public QObject {
* @return QSystemDeviceInfo::imei(), if available, or QSystemDeviceInfo::uniqueDeviceID()
*/
Q_INVOKABLE QString deviceUid();
/**
* Override device model autodetection
*/
Q_INVOKABLE void setDeviceModel(QString model="");
/**
* Return the requested variable section. 'var-' is automatically
* prepended to the section name if not specified already.
*/
QHash<QString, QString> variableSection(QString section);
/**
* Get a key from an adaptation section. Deprecated, don't use.
*/
bool getValue(const QString& key, QString& value);
private:
......
* Wed Mar 27 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.26
- Take all adaptations from adaptation-repos list, allow freeform variables for adaptations
* Fri Mar 22 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.25
- Add variable substitution
......
Name: ssu
Version: 0.25
Version: 0.26
Release: 1
Summary: SSU enabler for RND
Group: System/Base
......
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