afm-unit.conf: Fix missing @ in service name
[src/app-framework-main.git] / conf / generate-unit-conf / afm-unit
1 divert(-1)
2 -----------------------------------------------------------------------
3 -- Set the comment character of m4 to ; instead of #
4 -- This is needed for substitution within lines starting with #
5 changecom( ';')
6
7 -----------------------------------------------------------------------
8 -- 
9 define( `X_EMITS', 1)
10 define( `X_DIVERTS', `divert(eval(-!X_EMITS()))')
11 define( `X_PUSH_DIVERTS', `pushdef(`X_EMITS', eval(X_EMITS() && $1))X_DIVERTS()')
12
13 define( `X_IF', `pushdef(`X_COND', $1)X_PUSH_DIVERTS($1)')
14 define( `X_ELSE', `popdef(`X_EMITS')X_PUSH_DIVERTS(eval(!X_COND))')
15 define( `X_ELIF', `X_ELSE()X_IF($1)')
16 define( `X_ENDIF', `popdef(`X_EMITS')popdef(`X_COND')X_DIVERTS()')
17
18 define( `IF', `pushdef(`ELSE',`X_ELSE()')pushdef(`ELIF',`X_ELIF($1)')pushdef(`ENDIF',`X_ENDIF()popdef(`ELSE',`ELIF',`ENDIF')')X_IF($1)')
19
20 -----------------------------------------------------------------------
21 -- 
22 define( `MUSTACH_ON', `ifelse(`$2',,,`{{#$1}}`$2'{{/$1}}')ifelse(`$3',,,`{{^$1}}`$3'{{/$1}}')')
23 define( `MUSTACH_IF', `{{#$1}}pushdef(`ELSE',`{{/$1}}{{^$1}}')pushdef(`ENDIF',`{{/$1}}popdef(`ELSE',`ENDIF')')')
24 define( `MUSTACH_IF_NOT', `{{^$1}}pushdef(`ELSE',`{{/$1}}{{#$1}}')pushdef(`ENDIF',`{{/$1}}popdef(`ELSE',`ENDIF')')')
25
26 -----------------------------------------------------------------------
27 -- 
28 define( `PERM', `urn:AGL:permission:$1')
29 define( `REQPERM', `required-permission.PERM($1)')
30
31 define( `ON_PERM', `MUSTACH_ON(REQPERM($1),$2,$3)')
32 define( `IF_PERM', `MUSTACH_IF(REQPERM($1))')
33 define( `IF_NOT_PERM', `MUSTACH_IF_NOT(REQPERM($1))')
34
35 define( `ON_CONTENT', `MUSTACH_ON(content.type=$1,$2,$3)')
36 define( `IF_CONTENT', `MUSTACH_IF(content.type=$1)')
37 define( `IF_NOT_CONTENT', `MUSTACH_IF_NOT(content.type=$1)')
38
39 define( `ON_VALUE', `MUSTACH_ON(value=$1,$2,$3)')
40 define( `IF_VALUE', `MUSTACH_IF(value=$1)')
41 define( `IF_NOT_VALUE', `MUSTACH_IF_NOT(value=$1)')
42
43 -----------------------------------------------------------------------
44 -- 
45  when home screen will use real ids
46  use TARGET={{:id}}--{{:ver}}--{{:#target}}
47  instead of TARGET={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
48
49 define( `TARGET', `{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}')
50 define( `UNIT_NAME_BASE', `afm-ON_PERM(`:public:hidden', `service', `appli')-{{:id}}--{{:ver}}--{{:#target}}@')
51 define( `UNIT_NAME_SERVICE', `UNIT_NAME_BASE%i.service')
52 define( `UNIT_NAME_SOCKET_FOR', `afm-api-ws-$1@%i.socket')
53 define( `APP_DATA_DIR', `/home/%i/app-data')
54
55 -----------------------------------------------------------------------
56 -- 
57 define( `ON_AGL_DEVEL', `ifdef(`AGL_DEVEL', $1, $2)')
58 define( `IF_AGL_DEVEL', `IF(ON_AGL_DEVEL(1,0))')
59
60 divert(0)dnl
61 ;---------------------------------------------------------------------------------
62 ; File:
63 ;
64 ;    afm-unit.conf
65 ;
66 ; Mode:
67 ;
68 ;    ON_AGL_DEVEL(DEVEL, RELEASE)
69 ;
70 ; Role:
71 ;
72 ;    Configure how installation of widget produces unit files for systemd
73 ;
74 ; Processing and format:
75 ;
76 ;    1. File load
77 ;
78 ;           Lines beginning with ; are firstly removed
79 ;
80 ;    2. File instantiation
81 ;
82 ;           Mustache (extended) substitutions are applied using JSON
83 ;           data deduced from config.xml file of the widget.
84 ;
85 ;    3. Extraction of units
86 ;
87 ;           Extract produced units, pack it (remove empty lines and directives)
88 ;
89 ; Directives:
90 ;
91 ;    Any directive occupy one whole line starting with %
92 ;
93 ;     - %nl
94 ;
95 ;             produce an empty line at the end
96 ;
97 ;     - %begin systemd-unit
98 ;     - %end systemd-unit
99 ;
100 ;             delimit the produced unit
101 ;
102 ;     - %systemd-unit user
103 ;     - %systemd-unit system
104 ;
105 ;             tells the kind of unit (user/system)
106 ;
107 ;     - %systemd-unit service NAME
108 ;     - %systemd-unit socket NAME
109 ;
110 ;             gives the name and type of the unit
111 ;
112 ;     - %systemd-unit wanted-by NAME
113 ;
114 ;             tells to install a link to unit in the wants of NAME
115 ;
116 ; Setting variables:
117 ;
118 ;    AFM uses the feature of systemd that completely ignores options prefixed
119 ;    with X-
120 ;
121 ;    Consequently, options starting with X-AFM- are recorded as public data
122 ;    about the application and options starting starting with X-AFM-- are
123 ;    recorded as private data.
124 ;
125 ;    Examples:
126 ;
127 ;        X-AFM-description={{description}}
128 ;
129 ;              Records the description of the unit in the field "description"
130 ;              of both the public and private object describing the unit.
131 ;
132 ;        X-AFM--wgtdir={{:#metadata.install-dir}}
133 ;
134 ;              Records the installation directory path in the field "wgtdir"
135 ;              of the private object only.
136 ;
137 ;---------------------------------------------------------------------------------
138 {{#targets}}
139
140 include(service.inc)
141
142 include(provided.inc)
143
144 {{/targets}}
145 ;---------------------------------------------------------------------------------
146 ; End of file afm-unit.conf mode ON_AGL_DEVEL(DEVEL, RELEASE)
147 ;---------------------------------------------------------------------------------