aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-03-21 17:54:30 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2017-03-21 17:54:30 +0100
commitdcf194289a6af8c0a6b6263a2686af8fa44a37f2 (patch)
tree006beef1d4685120f4f1d7f2f44c93613a18954b
parent2c566e2dc9df934fb3884f9d4a9ad7ffc73a4aab (diff)
Allows or in mustache instanciation
This allows to simplify the configuration file afm-unit.conf. Restore the type application/vnd.agl.service Change-Id: Iaadde2c2d96155cea6d1b8bee4d3c78e885cf44a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--conf/afm-unit.conf113
-rw-r--r--docs/config.xml.md12
-rw-r--r--src/wgtpkg-mustach.c35
3 files changed, 63 insertions, 97 deletions
diff --git a/conf/afm-unit.conf b/conf/afm-unit.conf
index 82113ef..5fbba96 100644
--- a/conf/afm-unit.conf
+++ b/conf/afm-unit.conf
@@ -137,14 +137,19 @@ Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
{{/required-permission.urn:AGL:permission::public:hidden}}\
;---------------------------------------------------------------------------------
-;---- text/html ----
+;---- text/html application/vnd.agl.native application/vnd.agl.service ----
;---------------------------------------------------------------------------------
-{{#content.type=text/html}}
+{{#content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
+{{^content.type=application/vnd.agl.service}}
X-AFM--http-port={{:#metadata.http-port}}
+{{/content.type=application/vnd.agl.service}}
+
ExecStart=/usr/bin/afb-daemon \
- --port={{:#metadata.http-port}} \
- --random-token \
+ {{^content.type=application/vnd.agl.service}}\
+ --port={{:#metadata.http-port}} \
+ --random-token \
+ {{/content.type=application/vnd.agl.service}}\
--rootdir={{:#metadata.install-dir}} \
--workdir={{&#metadata.app-data-dir}}/{{id}} \
{{#required-permission.urn:AGL:permission::public:no-htdocs}}\
@@ -192,9 +197,18 @@ ExecStart=/usr/bin/afb-daemon \
--dbus-server={{name}} \
{{/value=dbus}}\
{{/provided-api}}\
- --exec /usr/bin/web-runtime http://localhost:@p/{{content.src}}?token=@t
+ {{#content.type=text/html}}\
+ --exec /usr/bin/web-runtime http://localhost:@p/{{content.src}}?token=@t \
+ {{/content.type=text/html}}\
+ {{#content.type=application/vnd.agl.native}}\
+ --exec {{:#metadata.install-dir}}/{{content.src}} @p @t \
+ {{/content.type=application/vnd.agl.native}}\
+ {{#content.type=application/vnd.agl.service}}\
+ --no-httpd \
+ {{/content.type=application/vnd.agl.service}}
+
+{{/content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
-{{/content.type=text/html}}
;---------------------------------------------------------------------------------
;---- application/x-executable ----
@@ -208,56 +222,6 @@ ExecStart={{:#metadata.install-dir}}/{{content.src}}
{{/content.type=application/x-executable}}
;---------------------------------------------------------------------------------
-;---- application/vnd.agl.service ----
-;---------------------------------------------------------------------------------
-{{#content.type=application/vnd.agl.service}}
-
-ExecStart=/usr/bin/afb-daemon \
- --rootdir={{:#metadata.install-dir}} \
- --workdir={{&#metadata.install-dir}}/{{id}} \
- {{#required-api}}\
- {{#value=auto}}\
- --ws-client=unix:%t/apis/ws/{{name}} \
- {{/value=auto}}\
- {{#value=ws}}\
- --ws-client=unix:%t/apis/ws/{{name}} \
- {{/value=ws}}\
- {{#value=dbus}}\
- --dbus-client={{name}} \
- {{/value=dbus}}\
- {{#value=link}}\
- --binding=%t/apis/lib/{{name}} \
- {{/value=link}}\
- {{#value=cloud}}\
- --cloud-client={{name}} \
- {{/value=cloud}}\
- {{#value=local}}\
- --binding={{:#metadata.install-dir}}/{{name}} \
- {{/value=local}}\
- {{/required-api}}\
- {{#provided-api}}\
- {{#value=auto}}\
- {{^required-permission.urn:AGL:permission::partner:service:no-ws}}\
- --ws-server=sd:{{name}} \
- {{/required-permission.urn:AGL:permission::partner:service:no-ws}}\
- {{^required-permission.urn:AGL:permission::partner:service:no-dbus}}\
- --dbus-server={{name}} \
- {{/required-permission.urn:AGL:permission::partner:service:no-dbus}}\
- {{/value=auto}}\
- {{#value=ws}}\
- --ws-server=sd:{{name}} \
- {{/value=ws}}\
- {{#value=dbus}}\
- --dbus-server={{name}} \
- {{/value=dbus}}\
- {{/provided-api}}\
- --no-httpd
-
-
-{{/content.type=application/vnd.agl.service}}
-
-
-;---------------------------------------------------------------------------------
; auto start
;---------------------------------------------------------------------------------
{{#required-permission.urn:AGL:permission::system:run-by-default}}
@@ -277,40 +241,7 @@ WantedBy=default.target
;---------------------------------------------------------------------------------
{{#provided-api}}
-{{#value=ws}}
-
-%begin systemd-unit
-
-# auto generated by wgtpkg-unit for {{id}} version {{version}} target {{:#target}} of {{idaver}}
-#
-%systemd-unit user
-%systemd-unit socket afm-socket-{{name}}
-
-[Socket]
-SmackLabel=*
-ListenStream=%t/bindings/{{name}}
-FileDescriptorName={{name}}
-
-{{#required-permission.urn:AGL:permission::public:hidden}}\
-Service=afm-service-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
-{{/required-permission.urn:AGL:permission::public:hidden}}\
-{{^required-permission.urn:AGL:permission::public:hidden}}\
-Service=afm-appli-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
-{{/required-permission.urn:AGL:permission::public:hidden}}\
-
-;---------------------------------------------------------------------------------
-{{#required-permission.urn:AGL:permission::system:run-by-default}}
-%nl
-[Install]
-WantedBy=default.target
-%systemd-unit wanted-by default.target
-{{/required-permission.urn:AGL:permission::system:run-by-default}}
-;---------------------------------------------------------------------------------
-
-%end systemd-unit
-
-{{/value=ws}}
-{{#value=auto}}
+{{#value=ws|auto}}
%begin systemd-unit
@@ -342,7 +273,7 @@ WantedBy=default.target
%end systemd-unit
-{{/value=auto}}
+{{/value=ws|auto}}
{{/provided-api}}
{{/targets}}
diff --git a/docs/config.xml.md b/docs/config.xml.md
index 7939ebe..8894667 100644
--- a/docs/config.xml.md
+++ b/docs/config.xml.md
@@ -371,13 +371,18 @@ Known types for the type of content are:
HTML application,
content.src designates the home page of the application
-- ***application/x-executable***:
- Native application,
- content.src designates the relative path of the binary
+- ***application/vnd.agl.native***
+ AGL compatible native,
+ content.src designates the relative path of the binary.
- ***application/vnd.agl.service***:
AGL service, content.src is not used.
+- ***application/x-executable***:
+ Native application,
+ content.src designates the relative path of the binary.
+ For such application, only security setup is made.
+
Adding more types is easy, it just need to edit the configuration
file ***afm-unit.conf***.
@@ -388,7 +393,6 @@ leveraging systemd. The transition to systemd let these types
out at the moment.
- ***application/vnd.agl.url***
-- ***application/vnd.agl.native***
- ***text/vnd.qt.qml***, ***application/vnd.agl.qml***
- ***application/vnd.agl.qml.hybrid***
- ***application/vnd.agl.html.hybrid***
diff --git a/src/wgtpkg-mustach.c b/src/wgtpkg-mustach.c
index cc79505..110f11b 100644
--- a/src/wgtpkg-mustach.c
+++ b/src/wgtpkg-mustach.c
@@ -28,7 +28,9 @@
#define MAX_DEPTH 256
-
+/*
+ * exploration state when instanciating mustache
+ */
struct expl {
struct json_object *root;
int depth;
@@ -111,6 +113,31 @@ static char *first(char **name, int isptr)
}
/*
+ * Returns the unescaped version of the first value
+ * and update 'val' to point the next value if any.
+ */
+static char *value(char **val)
+{
+ char *r, *read, *write, c;
+
+ c = *(read = *val);
+ if (!c)
+ r = NULL;
+ else {
+ r = write = read;
+ while (c && c != '|') {
+ if (c == '\\' && (read[1] == '|' || read[1] == '\\'))
+ c = *++read;
+ *write++ = c;
+ c = *++read;
+ }
+ *write = 0;
+ *val = read + !!c;
+ }
+ return r;
+}
+
+/*
* Replace the last occurence of ':' followed by
* any character not being '*' by ':*', the
* globalisation of the key.
@@ -179,7 +206,11 @@ static struct json_object *find(struct expl *e, const char *name)
/* check the value if requested */
if (v) {
i = v[0] == '!';
- if (i == !strcmp(&v[i], json_object_get_string(o)))
+ v += i;
+ do {
+ c = value(&v);
+ } while (c && strcmp(c, json_object_get_string(o)));
+ if (i != !c)
o = NULL;
}
return o;