Bug 9337 - systemd .service "WantedBy" lines not parsed correctly by systemctl script
Summary: systemd .service "WantedBy" lines not parsed correctly by systemctl script
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium+ normal
Target Milestone: 2.1 M4
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-03-24 07:42 UTC by Sandro Stiller
Modified: 2019-09-17 13:07 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sandro Stiller 2016-03-24 07:42:34 UTC
If a .service file of a recipe contains a space / tab at the end of the WantedBy line, the service is not enabled in the image.
If a .ipk for the same recipe is installed in the target, the service is enabled after installation.
The problem is in the recipes-core/systemd/systemd-systemctl/systemctl shell script. The "real" systemctl binary on the target system works properly.

Preconditions/Environment
-------------------------
tested with
* Yocto 1.8 and
* the current git version of the systemctl script

Triggering Action/Cause
-----------------------
1. Add a space or tab to the end of the WantedBy line of a .service file
2. build an image
3. start the built system

The problem can also reproduced by simply executing
recipes-core/systemd/systemd-systemctl/systemctl --root=<rootfs-dir> <servicename>.service
and checking the result.

Expectation
-----------
The service should be enabled (symlink created)

Actual Result
-------------
The service is not enabled.
There is no message in the build process about it.

Reproducibility
---------------
always
Comment 1 Randy MacLeod 2016-03-24 15:17:28 UTC
As mentioned on the bugboard call, depending on the actual bug, we could add a QA, build time check so that we catch malformed .service files before runtime.
Comment 2 Ross Burton 2016-03-24 17:01:56 UTC
I don't have a working systemd build right now, but can you see if changing unit_types_re to:

	unit_types_re='\.\(service\|socket\|device\|mount\|automount\|swap\|target\|path\|timer\|snapshot\)\s*$'


Fixes this?  Basically, add \s* before the $.  (allow some whitespace before the line end)
Comment 3 Ross Burton 2016-04-06 19:46:15 UTC
Patch on the list
Comment 4 Ross Burton 2016-04-13 15:25:28 UTC
Fixed in oe-core 0395162aa45a416db6a0a38e7ee6c0f808272393.
Comment 5 f.bre 2019-09-17 13:06:40 UTC
The systemctl script in poky/meta/recipes-core/systemd/systemd-systemctl is a bit too complicated for me to understand. But a fast look let me tend that somewhere in the beginning it should do a tr '\r\n' '\n' or something of the whole .service file.
Comment 6 f.bre 2019-09-17 13:07:56 UTC
oops sorry, wrong ticked. This should go to Bug 13535