* [PATCH] systemd.bbclass: support template files with dots
@ 2025-10-15 14:59 Jason M. Bills
2025-10-22 10:40 ` [OE-core] " Ross Burton
0 siblings, 1 reply; 3+ messages in thread
From: Jason M. Bills @ 2025-10-15 14:59 UTC (permalink / raw)
To: openembedded-core; +Cc: Jason M. Bills
If the SYSTEMD_SERVICE variable contains a template instance that has
dots in the name such as "xyz.openbmc_project.my@instance.service", the
regex splits on all the dots resulting in the following python
exception:
Exception: ValueError: too many values to unpack (expected 3)
To continue to support service files with dots in the name, this changes
to first split only on the '@' to isolate the name, then split the
second half on the dot to get the remaining two parameters.
Confirmed when building that the three parameters for template instances
without dots came out the same and that template instances with dots
include the full name with dots in the first parameter.
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
---
meta/classes-recipe/systemd.bbclass | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
index 5a0550b287..fcd47809b2 100644
--- a/meta/classes-recipe/systemd.bbclass
+++ b/meta/classes-recipe/systemd.bbclass
@@ -247,7 +247,8 @@ python systemd_populate_packages() {
if not systemd_service_exists(service, user, d):
continue
if '@' in service and '@.' not in service:
- (servicename, instance, service_type) = re.split('[@.]', service)
+ (servicename, postfix) = service.split('@')
+ (instance, service_type) = postfix.split('.')
template_services.setdefault(servicename + '@.' + service_type, []).append(instance)
else:
template_services.setdefault(service, [])
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [OE-core] [PATCH] systemd.bbclass: support template files with dots
2025-10-15 14:59 [PATCH] systemd.bbclass: support template files with dots Jason M. Bills
@ 2025-10-22 10:40 ` Ross Burton
2025-10-22 13:46 ` Bills, Jason M
0 siblings, 1 reply; 3+ messages in thread
From: Ross Burton @ 2025-10-22 10:40 UTC (permalink / raw)
To: jason.m.bills@linux.intel.com; +Cc: openembedded-core@lists.openembedded.org
On 15 Oct 2025, at 15:59, Bills, Jason M via lists.openembedded.org <jason.m.bills=linux.intel.com@lists.openembedded.org> wrote:
>
> If the SYSTEMD_SERVICE variable contains a template instance that has
> dots in the name such as "xyz.openbmc_project.my@instance.service", the
> regex splits on all the dots resulting in the following python
> exception:
>
> Exception: ValueError: too many values to unpack (expected 3)
>
> To continue to support service files with dots in the name, this changes
> to first split only on the '@' to isolate the name, then split the
> second half on the dot to get the remaining two parameters.
>
> Confirmed when building that the three parameters for template instances
> without dots came out the same and that template instances with dots
> include the full name with dots in the first parameter.
>
> Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
> ---
> meta/classes-recipe/systemd.bbclass | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
> index 5a0550b287..fcd47809b2 100644
> --- a/meta/classes-recipe/systemd.bbclass
> +++ b/meta/classes-recipe/systemd.bbclass
> @@ -247,7 +247,8 @@ python systemd_populate_packages() {
> if not systemd_service_exists(service, user, d):
> continue
> if '@' in service and '@.' not in service:
> - (servicename, instance, service_type) = re.split('[@.]', service)
> + (servicename, postfix) = service.split('@')
> + (instance, service_type) = postfix.split('.')
The assumption here is that the service name only contains a single dot and the instance isn’t something like foo.bar, right? Are we certain that is the case?
Ross
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [OE-core] [PATCH] systemd.bbclass: support template files with dots
2025-10-22 10:40 ` [OE-core] " Ross Burton
@ 2025-10-22 13:46 ` Bills, Jason M
0 siblings, 0 replies; 3+ messages in thread
From: Bills, Jason M @ 2025-10-22 13:46 UTC (permalink / raw)
To: Ross Burton; +Cc: openembedded-core@lists.openembedded.org
On 10/22/2025 4:40 AM, Ross Burton wrote:
> On 15 Oct 2025, at 15:59, Bills, Jason M via lists.openembedded.org <jason.m.bills=linux.intel.com@lists.openembedded.org> wrote:
>>
>> If the SYSTEMD_SERVICE variable contains a template instance that has
>> dots in the name such as "xyz.openbmc_project.my@instance.service", the
>> regex splits on all the dots resulting in the following python
>> exception:
>>
>> Exception: ValueError: too many values to unpack (expected 3)
>>
>> To continue to support service files with dots in the name, this changes
>> to first split only on the '@' to isolate the name, then split the
>> second half on the dot to get the remaining two parameters.
>>
>> Confirmed when building that the three parameters for template instances
>> without dots came out the same and that template instances with dots
>> include the full name with dots in the first parameter.
>>
>> Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
>> ---
>> meta/classes-recipe/systemd.bbclass | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/meta/classes-recipe/systemd.bbclass b/meta/classes-recipe/systemd.bbclass
>> index 5a0550b287..fcd47809b2 100644
>> --- a/meta/classes-recipe/systemd.bbclass
>> +++ b/meta/classes-recipe/systemd.bbclass
>> @@ -247,7 +247,8 @@ python systemd_populate_packages() {
>> if not systemd_service_exists(service, user, d):
>> continue
>> if '@' in service and '@.' not in service:
>> - (servicename, instance, service_type) = re.split('[@.]', service)
>> + (servicename, postfix) = service.split('@')
>> + (instance, service_type) = postfix.split('.')
>
> The assumption here is that the service name only contains a single dot and the instance isn’t something like foo.bar, right? Are we certain that is the case?
>
> Ross
>
This splits first on the '@', so the assumption is the whole thing
contains only one '@' and the service name can have many dots. But the
instance is assumed to have no dots which is currently the case in
OpenBMC, but I don't know is guaranteed in systemd.
The documentation ([1]) isn't explicit, but assuming "instance name"
allows the same characters as "unit name prefix", then it looks like
it's possible.
I will rework the second split to split on the last dot to allow for the
case where someone may use an instance with dots.
[1]:
https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html
-Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-22 13:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 14:59 [PATCH] systemd.bbclass: support template files with dots Jason M. Bills
2025-10-22 10:40 ` [OE-core] " Ross Burton
2025-10-22 13:46 ` Bills, Jason M
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox