Skip to contentSkip to conversation

systemd: allow dots in arguments to template units

PATCH New Martin Hundebøll 1 participant 1 message Nov 23, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 systemd: allow dots in arguments to template units

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.:

[email protected] -> [email protected]

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.:

[email protected] -> [email protected]

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.

---
 meta/classes/systemd.bbclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta/classes/systemd.bbclass +4 -2
index c4b4bb9b70..1b134322fb 100644
@@ -154,8 +154,10 @@ python systemd_populate_packages() {
                 # Deal with adding, for example, '[email protected]' from
                 # '[email protected]'
                 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)):
Signature · 1 line
2.15.0