]> code.ossystems Code Review - openembedded-core.git/commitdiff
systemd: allow dots in arguments to template units
authorMartin Hundebøll <mnhu@prevas.dk>
Thu, 23 Nov 2017 12:24:10 +0000 (13:24 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 6 Jan 2018 10:11:42 +0000 (10:11 +0000)
When installing systemd template units with an argument, the current code
removes characters between the '@' and the '.' from service names in
SYSTEMD_SERVICE_${PN}, e.g.:

  getty@tty1.service -> getty@.service

This fails for services with dots in the argument (which is perfectly
legal in systemd), since the code searches only until the first dot.
E.g.:

  vlan@eth0.1.service -> vlan@1.service

This is obviously wrong, and fails in systemd_populate_packages(), where
it fails to find the unit file.

Fix this by reworking the removal of the argument part of the service
name, so that parts before '@' and after teh last '.' are used as base
name.

Signed-off-by: Martin Hundebøll <mnhu@prevas.dk>
Signed-off-by: Ross Burton <ross.burton@intel.com>
(cherry picked from commit 4704bd91458a728f28cbdc57dcf78f5d04cfd0cd)
Signed-off-by: Armin Kuster <akuster808@gmail.com>
meta/classes/systemd.bbclass

index c4b4bb9b703d6985264eb3e6fa19d7b8ab78cbd9..1b134322fbcb57ae223ecdde8c2787e7bb155b37 100644 (file)
@@ -154,8 +154,10 @@ python systemd_populate_packages() {
                 # Deal with adding, for example, 'ifplugd@eth0.service' from
                 # 'ifplugd@.service'
                 base = None
-                if service.find('@') != -1:
-                    base = re.sub('@[^.]+.', '@.', service)
+                at = service.find('@')
+                if at != -1:
+                    ext = service.rfind('.')
+                    base = service[:at] + '@' + service[ext:]
 
                 for path in searchpaths:
                     if os.path.exists(oe.path.join(d.getVar("D"), path, service)):