1 ;---------------------------------------------------------------------------------
8 ; Configure how installation of widget produces unit files for systemd
10 ; Processing and format:
14 ; Lines beginning with ; are firstly removed
16 ; 2. File instantiation
18 ; Mustache (extended) substitutions are applied using JSON
19 ; data deduced from config.xml file of the widget.
21 ; 3. Extraction of units
23 ; Extract produced units, pack it (remove empty lines and directives)
27 ; Any directive occupy one whole line starting with %
31 ; produce an empty line at the end
33 ; - %begin systemd-unit
36 ; delimit the produced unit
38 ; - %systemd-unit user
39 ; - %systemd-unit system
41 ; tells the kind of unit (user/system)
43 ; - %systemd-unit service NAME
44 ; - %systemd-unit socket NAME
46 ; gives the name and type of the unit
48 ; - %systemd-unit wanted-by NAME
50 ; tells to install a link to unit in the wants of NAME
54 ; AFM uses the feature of systemd that completely ignores options prefixed
57 ; Consequently, options starting with X-AFM- are recorded as public data
58 ; about the application and options starting starting with X-AFM-- are
59 ; recorded as private data.
63 ; X-AFM-description={{description}}
65 ; Records the description of the unit in the field "description"
66 ; of both the public and private object describing the unit.
68 ; X-AFM--wgtdir={{:#metadata.install-dir}}
70 ; Records the installation directory path in the field "wgtdir"
71 ; of the private object only.
73 ;---------------------------------------------------------------------------------
76 ;---------------------------------------------------------------------------------
77 ;---- P R O V I D E D U N I T S ----
78 ;---------------------------------------------------------------------------------
81 # auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
85 Description={{description}}
86 X-AFM-description={{description}}
87 X-AFM-name={{name.content}}
88 X-AFM-shortname={{name.short}}
90 # use X-AFM-id={{:id}}--{{:ver}}--{{:#target}}
92 X-AFM-id={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
93 # when home screen will use real ids
95 X-AFM-version={{:version}}
96 X-AFM-author={{author.content}}
97 X-AFM-author-email={{author.email}}
99 X-AFM-height={{height}}
101 X-AFM-icon={{:#metadata.install-dir}}/{{:src}}
104 X-AFM--target-name={{:#target}}
105 X-AFM--content={{content.src}}
106 X-AFM--type={{content.type}}
107 X-AFM--wgtdir={{:#metadata.install-dir}}
108 X-AFM--workdir={{&#metadata.app-data-dir}}/{{:id}}
113 # Adds check to smack
114 ConditionSecurity=smack
117 # Automatic bound to required api
120 BindsTo=afm-api-ws-{{name}}@%i.socket
121 After=afm-api-ws-{{name}}@%i.socket
127 EnvironmentFile=-@afm_confdir@/unit.env.d/*
128 SmackProcessLabel=User::App::{{:id}}
129 SuccessExitStatus=0 SIGKILL
135 CapabilityBoundingSet=
138 {{#required-permission}}
139 {{#urn:AGL:permission::platform:no-oom}} OOMScoreAdjust=-500 {{/urn:AGL:permission::platform:no-oom}}
140 {{#urn:AGL:permission::partner:real-time}} IOSchedulingClass=realtime {{/urn:AGL:permission::partner:real-time}}
141 # {{^urn:AGL:permission::partner:real-time}} RestrictRealtime=on {{/urn:AGL:permission::partner:real-time}}
142 {{#urn:AGL:permission::public:display}} SupplementaryGroups=display {{/urn:AGL:permission::public:display}}
143 {{^urn:AGL:permission::public:syscall:clock}} SystemCallFilter=~@clock {{/urn:AGL:permission::public:syscall:clock}}
144 {{/required-permission}}
147 WorkingDirectory=-{{&#metadata.app-data-dir}}/{{:id}}
148 ExecStartPre=/bin/mkdir -p {{&#metadata.app-data-dir}}/{{:id}}
149 Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
150 Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}
151 Environment=XDG_DATA_HOME={{&#metadata.app-data-dir}}/{{:id}}
152 Environment=XDG_CONFIG_HOME={{&#metadata.app-data-dir}}/{{:id}}
153 Environment=XDG_CACHE_HOME={{&#metadata.app-data-dir}}/{{:id}}
154 Environment=XDG_RUNTIME_DIR=/run/user/%i
155 Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%i/bus
157 ; Needed to enable debug
158 Environment=AFM_ID={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
159 EnvironmentFile=-/var/run/afm-debug/{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}.env
162 {{#required-permission.urn:AGL:permission::public:hidden}}\
163 %systemd-unit service afm-service-{{:id}}--{{:ver}}--{{:#target}}@
164 {{/required-permission.urn:AGL:permission::public:hidden}}\
165 {{^required-permission.urn:AGL:permission::public:hidden}}\
166 %systemd-unit service afm-appli-{{:id}}--{{:ver}}--{{:#target}}@
167 {{/required-permission.urn:AGL:permission::public:hidden}}\
169 Environment=LD_LIBRARY_PATH=$ORIGIN/lib
171 SyslogIdentifier=afbd-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
173 StandardOutput=journal
174 StandardError=journal
176 ;---------------------------------------------------------------------------------
177 ;---- text/html application/vnd.agl.native application/vnd.agl.service ----
178 ;---------------------------------------------------------------------------------
179 {{#content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
181 X-AFM--http-port={{:#metadata.http-port}}
183 ExecStart=/usr/bin/afb-daemon \
184 --name afbd-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}} \
185 --rootdir={{:#metadata.install-dir}} \
186 --workdir={{&#metadata.app-data-dir}}/{{id}} \
187 --port={{:#metadata.http-port}} \
191 {{^content.type=application/vnd.agl.service}} \
192 {{#required-permission.urn:AGL:permission::public:no-htdocs}}\
194 {{/required-permission.urn:AGL:permission::public:no-htdocs}}\
195 {{^required-permission.urn:AGL:permission::public:no-htdocs}}\
197 {{/required-permission.urn:AGL:permission::public:no-htdocs}}\
198 {{/content.type=application/vnd.agl.service}} \
199 {{#content.type=application/vnd.agl.service}} \
201 {{/content.type=application/vnd.agl.service}} \
202 {{#required-permission.urn:AGL:permission::public:applications:read}}\
203 --alias=/icons:{{:#metadata.icons-dir}} \
204 {{/required-permission.urn:AGL:permission::public:applications:read}}\
207 --ws-client=unix:%t/apis/ws/{{name}} \
210 --ws-client=unix:%t/apis/ws/{{name}} \
213 --dbus-client={{name}} \
216 --binding=%t/apis/lib/{{name}} \
219 --cloud-client={{name}} \
222 --binding={{:#metadata.install-dir}}/{{name}} \
227 {{^required-permission.urn:AGL:permission::partner:service:no-ws}}\
228 --ws-server=sd:{{name}} \
229 {{/required-permission.urn:AGL:permission::partner:service:no-ws}}\
230 {{^required-permission.urn:AGL:permission::partner:service:no-dbus}}\
231 --dbus-server={{name}} \
232 {{/required-permission.urn:AGL:permission::partner:service:no-dbus}}\
235 --ws-server=sd:{{name}} \
238 --dbus-server={{name}} \
241 {{#content.type=text/html}}\
242 --exec /usr/bin/web-runtime http://localhost:@p/{{content.src}}?token=@t
243 {{/content.type=text/html}}\
244 {{#content.type=application/vnd.agl.native}}\
245 --exec {{:#metadata.install-dir}}/{{content.src}} @p @t
246 {{/content.type=application/vnd.agl.native}}
248 {{/content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
251 ;---------------------------------------------------------------------------------
252 ;---- application/x-executable ----
253 ;---------------------------------------------------------------------------------
254 {{#content.type=application/x-executable}}
256 ExecStart={{:#metadata.install-dir}}/{{content.src}}
258 {{/content.type=application/x-executable}}
260 ;---------------------------------------------------------------------------------
262 ;---------------------------------------------------------------------------------
263 {{#required-permission.urn:AGL:permission::system:run-by-default}}
266 WantedBy=default.target
267 %systemd-unit wanted-by default.target
268 {{/required-permission.urn:AGL:permission::system:run-by-default}}
273 ;---------------------------------------------------------------------------------
274 ;---- P R O V I D E D A P I S ----
275 ;---------------------------------------------------------------------------------
282 # auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
285 %systemd-unit socket afm-api-ws-{{name}}@
289 ListenStream=%t/apis/ws/{{name}}
290 FileDescriptorName={{name}}
292 {{#required-permission.urn:AGL:permission::public:hidden}}\
293 Service=afm-service-{{:id}}--{{:ver}}--{{:#target}}@%i.service
294 {{/required-permission.urn:AGL:permission::public:hidden}}\
295 {{^required-permission.urn:AGL:permission::public:hidden}}\
296 Service=afm-appli-{{:id}}--{{:ver}}--{{:#target}}@%i.service
297 {{/required-permission.urn:AGL:permission::public:hidden}}\
299 ;---------------------------------------------------------------------------------
302 WantedBy=sockets.target
303 %systemd-unit wanted-by sockets.target
304 ;---------------------------------------------------------------------------------