Short description
mkinitcpio-systemd-tool does not support adding template service units (e.g. my-fancy-tool@.service) to the initrd yet.
Steps to reproduce
Let's assume I have a service called my-fancy-tool, that I need to run from the initial ramdisk during early boot. This service is expected to be executed multiple times with different configurations, so I have a template unit at /usr/lib/systemd/system/my-fancy-tool@.service with
...
[Service]
ExecStart=/usr/bin/unlocked-client --config /etc/my-fancy-tool/%i.conf
...
Now I enable my service for a specific config with systemctl enable my-fancy-tool@my-config.service and then try to recreate the initrd.
Expected behavior
Recreating the initrd succeeds and my service is added to the initrd image.
Actual behavior
Recreating the initrd fails with
==> ERROR: can not find service unit: my-fancy-tool@my-config.service
Technical details
In the function add_systemd_unit_X in src/mkinitcpio-install.sh the unit of my service is parsed as my-fancy-tool@my-config.service.
Right after that, the tool tries to locate either /etc/systemd/system/my-fancy-tool@my-config.service or /usr/lib/systemd/system/my-fancy-tool@my-config.service.
However both files do not exist, as my unit is /usr/lib/systemd/system/my-fancy-tool@.service and the tool failes.
Suggested solution
The unit name should be stripped from all arguments. So my-fancy-tool@my-config.service should become my-fancy-tool@.service and initrd-cryptsetup.service should remain initrd-cryptsetup.service.
The name of the symlink should still be stored, as it should still be added to the initrd image with its argument in the name.
Short description
mkinitcpio-systemd-tooldoes not support adding template service units (e.g.my-fancy-tool@.service) to the initrd yet.Steps to reproduce
Let's assume I have a service called
my-fancy-tool, that I need to run from the initial ramdisk during early boot. This service is expected to be executed multiple times with different configurations, so I have a template unit at/usr/lib/systemd/system/my-fancy-tool@.servicewithNow I enable my service for a specific config with
systemctl enable my-fancy-tool@my-config.serviceand then try to recreate the initrd.Expected behavior
Recreating the initrd succeeds and my service is added to the initrd image.
Actual behavior
Recreating the initrd fails with
Technical details
In the function
add_systemd_unit_Xinsrc/mkinitcpio-install.shthe unit of my service is parsed asmy-fancy-tool@my-config.service.Right after that, the tool tries to locate either
/etc/systemd/system/my-fancy-tool@my-config.serviceor/usr/lib/systemd/system/my-fancy-tool@my-config.service.However both files do not exist, as my unit is
/usr/lib/systemd/system/my-fancy-tool@.serviceand the tool failes.Suggested solution
The unit name should be stripped from all arguments. So
my-fancy-tool@my-config.serviceshould becomemy-fancy-tool@.serviceandinitrd-cryptsetup.serviceshould remaininitrd-cryptsetup.service.The name of the symlink should still be stored, as it should still be added to the initrd image with its argument in the name.