]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commit
systemd.bbclass: deduplicate template and instance lines in preset file
authorKhang D Nguyen <khangng@os.amperecomputing.com>
Wed, 20 Aug 2025 02:55:24 +0000 (09:55 +0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 20 Aug 2025 20:47:33 +0000 (21:47 +0100)
commit7cdf10840c200a327b6336775698342af7212ee4
tree376b561ee569ac02646bac31c92891a16825f157
parent7f9e3c2c60a2d73b3728d07519471f0614c03130
systemd.bbclass: deduplicate template and instance lines in preset file

If SYSTEMD_SERVICE contains both template and instance names, the
preset file will contain two lines: one describing the template name
and one describing the instance names.

This is problematic because systemd.preset only use the first matching
one [1], leading to the instances not getting enabled.

For example, openbmc's obmc-console recipe has the following
final SYSTEMD_SERVICE variable:

```
SYSTEMD_SERVICE:obmc-console = " \
obmc-console@.service \
obmc-console-ssh@.service \
obmc-console-ssh@2200.service \
"
```

The resulting preset file will contain lines with the same name:

```
enable obmc-console@.service
enable obmc-console-ssh@.service
enable obmc-console-ssh@.service 2200
```

Fix this by interpreting the template name as a special case of empty
instances.

Tested: preset files are generated correctly:

```
enable obmc-console@.service
enable obmc-console-ssh@.service 2200
```

[1]: https://www.freedesktop.org/software/systemd/man/257/systemd.preset.html#Preset%20File%20Format

Fixes: f33d9b1f434e ("systemd.bbclass: generate preset for templates")
Signed-off-by: Khang D Nguyen <khangng@os.amperecomputing.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/systemd.bbclass