Commit e87a49c6 authored by Aard's avatar Aard

Add support for := variable substitution

parent b6ba584d
......@@ -103,6 +103,19 @@ QString SsuVariables::resolveVariable(QString variable, QHash<QString, QString>
if (variableValue != "")
return variableSub.toString();
break;
case '=': {
// %(%(foo):=bar?foobar|baz)
// if foo == bar then return foobar, else baz
QString sub = variableSub.toString();
QString a = sub.left(sub.indexOf("?"));
QString b = sub.right(sub.length() - sub.indexOf("?") - 1);
if (b.indexOf("|") == -1)
return b;
if (variableName == a)
return b.left(b.indexOf("|"));
else
return b.right(b.length() - b.indexOf("|") - 1);
}
}
// no proper substitution found -> return default value
......
......@@ -22,6 +22,9 @@
# Basic variable substitution is supported:
# %(foo:+bar) -- expands to "" if foo is set, bar otherwise
# %(foo:-bar) -- expands to %(foo) if foo is set, bar otherwise
# %(%(foo):=bar?foobar|baz) -- expands to foobar if %(foo) == bar, to baz
# otherwise. %(foo) should only be alphanumeric. It must not
# contain the character '?'.
#
# Repository lookup will happen based on the 'repo' parameter in repository
# URLs. For RnD repositories order will be <flavour> -> rnd -> all, for
......
* Wed Mar 27 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.27
- Add support for := in variable substitution
* Wed Mar 27 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.26
- Take all adaptations from adaptation-repos list, allow freeform variables for adaptations
......
Name: ssu
Version: 0.26
Version: 0.27
Release: 1
Summary: SSU enabler for RND
Group: System/Base
......
......@@ -44,6 +44,11 @@ void VariablesTest::initTestCase(){
// substitution of variable with empty variable + /set -- should substitute to ""
urls.insert("%(rndProtocol)://%(unsetDomain:+%(unsetDomain)/set)/nemo/%(release)-%(flavourName)/platform/%(arch)/",
"https:///nemo/devel-flavour/platform/armv8/");
// test :=
urls.insert("%(%(rndProtocol):=https?https://%(releaseDomain)/%(release)-%(flavourName)|http://%(releaseDomain)/%(release)-%(flavourName))",
"https://releases.example.com/devel-flavour");
urls.insert("%(%(rndProtocol):=http?https://%(releaseDomain)/%(release)-%(flavourName)|http://%(releaseDomain)/%(release)-%(flavourName))",
"http://releases.example.com/devel-flavour");
}
......
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