Re: [PATCH] debian: Replace SysV init script with native systemd unit

Clara Kowalsky <[email protected]> Fri, 31 Jul 2026 10:49:55 +0200
Newsgroups dev.linux.lists.xenomai
Message-ID <[email protected]>

On 7/30/26 19:21, Jan Kiszka wrote:
> On 30.07.26 17:47, Clara Kowalsky wrote:
>> Debian trixie warns when relying on the generated compatibility unit for
>> /etc/init.d/xenomai.
>>
>> This addresses
>>
>> systemd-sysv-generator[1423]: SysV service '/etc/init.d/xenomai' lacks a native systemd unit file, automatically generating a unit file for compatibility.
>> systemd-sysv-generator[1423]: Please update package to include a native systemd unit file.
>> systemd-sysv-generator[1423]: ⚠ This compatibility logic is deprecated, expect removal soon. ⚠
>>
>> See #54.
>>
>> Signed-off-by: Clara Kowalsky <[email protected]>
>> ---
>>   debian/libxenomai1.xenomai.init    | 36 ------------------------------
>>   debian/libxenomai1.xenomai.service | 13 +++++++++++
>>   debian/rules                       |  2 +-
>>   3 files changed, 14 insertions(+), 37 deletions(-)
>>   delete mode 100644 debian/libxenomai1.xenomai.init
>>   create mode 100644 debian/libxenomai1.xenomai.service
>>
>> diff --git a/debian/libxenomai1.xenomai.init b/debian/libxenomai1.xenomai.init
>> deleted file mode 100644
>> index 811fe25fd..000000000
>> --- a/debian/libxenomai1.xenomai.init
>> +++ /dev/null
>> @@ -1,36 +0,0 @@
>> -#!/bin/sh -e
>> -### BEGIN INIT INFO
>> -# Provides:          xenomai
>> -# Required-Start:    mountkernfs
>> -# Required-Stop:
>> -# Default-Start:     2 3 4 5
>> -# Default-Stop:      0 1 6
>> -# Short-Description: Set Xenomai group
>> -### END INIT INFO
>> -
>> -GROUP=xenomai
>> -INITNAME=/etc/init.d/xenomai
>> -FILENAME=/sys/module/xenomai/parameters/allowed_group
>> -GID=$(getent group $GROUP | cut -d: -f3)
>> -
>> -test -e $FILENAME || exit 0
>> -test -n "$GID" || exit 0
>> -
>> -case "$1" in
>> -  start)
>> -        echo "$GID" > $FILENAME
>> -        ;;
>> -  stop)
>> -        echo "-1" > $FILENAME
>> -        ;;
>> -  restart|force-reload)
>> -        $0 start
>> -        ;;
>> -  *)
>> -        echo "Usage: $INITNAME {start|stop|restart|force-reload}"
>> -        exit 1
>> -        ;;
>> -esac
>> -
>> -exit 0
>> -
>> diff --git a/debian/libxenomai1.xenomai.service b/debian/libxenomai1.xenomai.service
>> new file mode 100644
>> index 000000000..4494dc00c
>> --- /dev/null
>> +++ b/debian/libxenomai1.xenomai.service
>> @@ -0,0 +1,13 @@
>> +[Unit]
>> +Description=Set Xenomai group
>> +ConditionPathExists=/sys/module/xenomai/parameters/allowed_group
>> +After=systemd-modules-load.service
>> +
>> +[Service]
>> +Type=oneshot
>> +RemainAfterExit=yes
>> +ExecStart=/bin/sh -ec 'gid=$(/usr/bin/getent group xenomai | /usr/bin/cut -d: -f3); [ -n "$gid" ] && echo "$gid" > /sys/module/xenomai/parameters/allowed_group || true'
>> +ExecStop=/bin/sh -ec 'echo -1 > /sys/module/xenomai/parameters/allowed_group || true'
> 
> Why "|| true"? Can't we detect the condition when we should not write
> (like in the original script) and give the write the chance to properly
> fail the unit? You may even use a script to deduplicate that part of the
> logic.
> 
> BTW, how did you test this?
> 
> Jan

Yes, that's not ideal. I'll send a v2 where the systemd unit calls a 
separate script (basically the original one) with all checks included.

I tested this by building the libxenomai1 package in xenomai with 
dpkg-buildpackage. Booted a Debian trixie based image built with 
xenomai-images, installed the libxenomai1 package with my changes into 
it, "systemctl daemon-reload", reboot.
Checked "dmesg | grep sysv" -> no more warnings.
Checked status of xenomai.service and played around to set/unset the GID 
in allowed_groups.

Clara

> 
>> +
>> +[Install]
>> +WantedBy=multi-user.target
>> diff --git a/debian/rules b/debian/rules
>> index 9e56de260..dd52cbaf0 100755
>> --- a/debian/rules
>> +++ b/debian/rules
>> @@ -103,7 +103,7 @@ binary-indep: build install
>>   binary-arch: build install
>>   	dh_testdir -a
>>   	dh_testroot -a
>> -	dh_installinit -a --name=xenomai
>> +	dh_installsystemd -a --name=xenomai
>>   	dh_installman -a
>>   	dh_installdocs -a -A README
>>   	dh_link -a
> 
>