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

Jan Kiszka <[email protected]>
Newsgroups dev.linux.lists.xenomai
Message-ID <[email protected]>
On 31.07.26 10:53, 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. ⚠
> 
> The systemd unit uses the script /usr/lib/xenomai/xenomai-group for GID
> handling.
> See #54.
> 
> Signed-off-by: Clara Kowalsky <[email protected]>
> ---
>  debian/libxenomai1.xenomai-group   | 26 +++++++++++++++++++++
>  debian/libxenomai1.xenomai.init    | 36 ------------------------------
>  debian/libxenomai1.xenomai.service | 12 ++++++++++
>  debian/rules                       |  3 ++-
>  4 files changed, 40 insertions(+), 37 deletions(-)
>  create mode 100644 debian/libxenomai1.xenomai-group
>  delete mode 100644 debian/libxenomai1.xenomai.init
>  create mode 100644 debian/libxenomai1.xenomai.service
> 
> diff --git a/debian/libxenomai1.xenomai-group b/debian/libxenomai1.xenomai-group
> new file mode 100644
> index 000000000..ecb99ff20
> --- /dev/null
> +++ b/debian/libxenomai1.xenomai-group
> @@ -0,0 +1,26 @@
> +#!/bin/sh -e
> +
> +GROUP=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: $0 {start|stop|restart|force-reload}" >&2
> +        exit 1
> +        ;;
> +esac
> +
> +exit 0
> 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..50ca3bcc1
> --- /dev/null
> +++ b/debian/libxenomai1.xenomai.service
> @@ -0,0 +1,12 @@
> +[Unit]
> +Description=Set Xenomai group
> +After=systemd-modules-load.service
> +
> +[Service]
> +Type=oneshot
> +RemainAfterExit=yes
> +ExecStart=/usr/lib/xenomai/xenomai-group start
> +ExecStop=/usr/lib/xenomai/xenomai-group stop
> +
> +[Install]
> +WantedBy=multi-user.target
> diff --git a/debian/rules b/debian/rules
> index 9e56de260..0ef5557fa 100755
> --- a/debian/rules
> +++ b/debian/rules
> @@ -75,6 +75,7 @@ install: build
>  	    cat $$f >> $(CURDIR)/debian/libxenomai1/etc/udev/xenomai.rules ; \
>  	done
>  	install -m 644 debian/libxenomai1.modprobe $(CURDIR)/debian/libxenomai1/etc/modprobe.d/xenomai.conf
> +	install -D -m 755 debian/libxenomai1.xenomai-group $(CURDIR)/debian/libxenomai1/usr/lib/xenomai/xenomai-group
>  	# remove empty directory
>  	rm -rf $(CURDIR)/debian/xenomai-doc/usr/share/doc/xenomai-doc/ps
>  	cp debian/libxenomai1.lintian $(CURDIR)/debian/libxenomai1/usr/share/lintian/overrides/libxenomai1
> @@ -103,7 +104,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

Thanks, applied.

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.