Bug#924132: runit: Add support for runit in init-system-helpers

2024-08-27 Thread Lorenzo
Dear init-system-helpers maintainers,

> Now it's likely that I have to support also a catch-all package for
> runit services in addition to the standard dh-runit code

such support is now done, so I'm attaching an updated patchset:

* no patch is needed for update-rc.d: the rescan need to happen
  between enable and signal to a service; both actions are handled
  by runit-helper, so a rescan in update-rc.d is not useful.

* invoke-rc.d: what is needed is a way to block invoke-rc.d when
  a native runit service is found, so that duplicated and conflicting
  instances are avoided. I've added an override mechanism.

* service: patch updated for new service layout; also --status-all
  is changed so that runscripts status is distinguishable from the
  sysv status (runit currently uses a mix of native and sysv scripts
  so the distinction is useful)

Regards,
Lorenzo
>From f50645c3fa7b04204f6749afa4480a6d59077282 Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti 
Date: Wed, 28 Aug 2024 00:03:04 +0200
Subject: [PATCH 1/3] Add Depends: runit-helper

so that postrm (purge) code can be called safely.
---
 debian/control | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/control b/debian/control
index a804662..c1a5421 100644
--- a/debian/control
+++ b/debian/control
@@ -25,6 +25,7 @@ Multi-Arch: foreign
 Depends: ${misc:Depends},
  ${perl:Depends},
  usrmerge | usr-is-merged,
+ runit-helper,
 Description: helper tools for all init systems
  This package contains helper tools that are necessary for switching between
  the various init systems that Debian contains (e. g. sysvinit or
-- 
2.45.2

>From d889c63ec30b38d31aec973bb6706e1f6d669669 Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti 
Date: Wed, 28 Aug 2024 00:17:48 +0200
Subject: [PATCH 2/3] invoke-rc.d: add support for runit

add an override for runit so that is possible to avoid duplicate
(sometimes conflicting) instances of services
---
 script/invoke-rc.d | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/script/invoke-rc.d b/script/invoke-rc.d
index ca1bdbe..9294de6 100755
--- a/script/invoke-rc.d
+++ b/script/invoke-rc.d
@@ -39,6 +39,7 @@ RETURNFAILURE=
 RC=
 is_systemd=
 is_openrc=
+is_runit=
 SKIP_SYSTEMD_NATIVE=
 
 # Shell options
@@ -279,6 +280,8 @@ if test -d /run/systemd/system ; then
 UNIT="${INITSCRIPTID%.sh}.service"
 elif test -f /run/openrc/softlevel ; then
 is_openrc=1
+elif test -f /run/runit.stopit ; then
+is_runit=1
 elif test ! -f "${INITDPREFIX}${INITSCRIPTID}" ; then
 ## Verifies if the given initscript ID is known
 ## For sysvinit, this error is critical
@@ -456,6 +459,17 @@ if test x${MODE} = xquery ; then
 exit ${RC}
 fi
 
+## runit sysv-override: first the sysv policy layer
+## is tested so that runit override does not interfere
+## with installer or other packages that uses policy-rc.d
+if [ ${RC} -eq 104 ];then
+if [ -n "$is_runit" ] && [ -x /etc/runit/override-sysv.d/runit-default ]; then
+/etc/runit/override-sysv.d/runit-default "${INITSCRIPTID}" "${ACTION}" "$@"
+if [ "$?" -ne "104"  ]; then
+exit 0
+fi
+fi
+fi
 
 setechoactions () {
 if test $# -gt 1 ; then
-- 
2.45.2

>From cb71628d9900b9ab69a894f96a589fd6b62afcd2 Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti 
Date: Wed, 28 Aug 2024 01:04:56 +0200
Subject: [PATCH 3/3] service: add support for runit

exec action on native runit service if it exists, otherwise fallback
on sysv script; sysv 'full-restart' is mapped as sv's 'exit'.
--status-all first shows the status of runit-services, then, for
services where a native runit script is not found, the sysv script
status is printed.
---
 script/service | 62 +-
 1 file changed, 61 insertions(+), 1 deletion(-)

diff --git a/script/service b/script/service
index 08f69bb..623bfd4 100755
--- a/script/service
+++ b/script/service
@@ -49,7 +49,10 @@ ACTION=
 SERVICEDIR="/etc/init.d"
 OPTIONS=
 is_systemd=
-
+is_runit=
+# runit service dirs
+ETCSVDIR="/etc/sv"
+USRSVDIR="/usr/share/runit/sv.current"
 
 if [ $# -eq 0 ]; then
echo "${USAGE}" >&2
@@ -59,6 +62,9 @@ fi
 if [ -d /run/systemd/system ]; then
is_systemd=1
 fi
+if [ -f /run/runit.stopit ]; then
+   is_runit=1
+fi
 
 cd /
 while [ $# -gt 0 ]; do
@@ -73,6 +79,29 @@ while [ $# -gt 0 ]; do
;;
 *)
if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
+  if [ -n "$is_runit" ]; then
+printf "=== Native runit services ===\n"
+sv s /etc/service/*
+cd "$ETCSVDIR"
+for SVS in * ; do
+if [ -h /etc/service/"${SVS}" ]; then
+continue # skip: already done
+else
+echo "disabled: ${SVS}"
+fi
+done
+cd "$USRSVDIR"
+for SVS in * ; do
+if [ -d "$ETCSVDIR"/"${SVS}" ]; then
+continue # skip: sup

Bug#924132: runit: Add support for runit in init-system-helpers

2024-05-04 Thread Mo Jun
Package: init-system-helpers
Version: 1.66
Followup-For: Bug #924132

Dear Maintainer,

Kindly ask if is there any progress of this bug. It will be very grateful for
adding support of runit in init-system-helpers as it will make use runit as
system init a bit easier.

I just start to use runit, so please correct me if I am wrong. Honestly it
seems to me that runit's support for sysvinit is poor, making use runit as
system init hard. Yes, runit-init will start scripts under /etc/rc2.d/ for me
as done in /etc/runit/2 during boot. But after boot completes, sv status/up/down
is not working for scripts under /etc/init.d/. Maybe it is better to solve this
by improving support for sysvinit in runit. But if this can be easily done in
init-system-helpers, it may still be a choice. And doing this in
init-system-helpers
has a benefit that have a consistent interface between different init. When I
used systemd as init, I still was used to use `service start/stop' to manage
system daemons. It will be thankful to still use that when use runit as init.

So really please consider adding support for runit in this package.

Regarding to the merge requests by Lorenzo Puliti[1], I have applied it into
and rebuild the init-system-helpers package. It helps me immediately. Although
maybe more polish(or update) is still needed. The first one is that the patch
only consider service under /etc/sv/. Under /etc/service/, I see there are
symlinks to not only /etc/sv/*, but also /usr/share/runit/sv.current/*.
/usr/share/runit/sv.current/* is provided by the runit-services
package and may also
be treated. Another one is `service --status-all' now only shows runit services.
It will better to show both runit services and sysvinit services. This
may be done
by the following changes:

--- a/script/service
+++ b/script/service
@@ -79,6 +87,26 @@
   functions | halt | killall | single| linuxconf| kudzu)
   ;;
   *)
+if [ -n "$is_runit" ]; then
+   runit_service=
+   if [ -d "/etc/sv/${SERVICE}" ]; then
+ runit_service="/etc/sv/${SERVICE}"
+   elif [ -d "/usr/share/runit/sv.current/${SERVICE}" ]; then
+ runit_service="/usr/share/runit/sv.current/${SERVICE}"
+   fi
+
+   if [ -n "$runit_service" ]; then
+ sv status "$runit_service" \
+   | sed -e 's|run: /etc/sv/| \[ + ] run: |' \
+ -e 's|down: /etc/sv/| \[ - ] down: |' \
+ -e 's|fail: /etc/sv/|disabled: |' \
+ -e 's|run: /usr/share/runit/sv.current/|
\[ + ] run: |' \
+ -e 's|down:
/usr/share/runit/sv.current/| \[ - ] down: |' \
+ -e 's|fail:
/usr/share/runit/sv.current/|disabled: |'
+ continue
+   fi
+fi
+
 if ! is_ignored_file "${SERVICE}" \
 && [ -x "${SERVICEDIR}/${SERVICE}" ]; then
 out=$(env -i LANG="$LANG"
LANGUAGE="$LANGUAGE" LC_CTYPE="$LC_CTYPE" LC_NUMERIC="$LC_NUMERIC"
LC_TIME="$LC_TIME" LC_COLLATE="$LC_COLLATE" LC_MONETARY="$LC_MONETARY"
LC_MESSAGES="$LC_MESSAGES" LC_PAPER="$LC_PAPER" LC_NAME="$LC_NAME"
LC_ADDRESS="$LC_ADDRESS" LC_TELEPHONE="$LC_TELEPHONE"
LC_MEASUREMENT="$LC_MEASUREMENT"
LC_IDENTIFICATION="$LC_IDENTIFICATION" LC_ALL="$LC_ALL" PATH="$PATH"
TERM="$TERM" "$SERVICEDIR/$SERVICE" status 2>&1)

instead of the original changes:

--- a/script/service
+++ b/script/service
@@ -73,6 +80,11 @@ while [ $# -gt 0 ]; do
;;
 *)
if [ -z "${SERVICE}" -a $# -eq 1 -a "${1}" = "--status-all" ]; then
+  if [ -n "$is_runit" ]; then
+ exec sv status /etc/sv/* \
+ | sed -e 's|run: /etc/sv/|\[ + ] run: |' -e 's|down:
/etc/sv/|\[ - ] down: |' -e 's|fail: /etc/sv/|disabled: |'
+ exit 0
+  fi
   cd ${SERVICEDIR}
   for SERVICE in * ; do
 case "${SERVICE}" in

I attach the debdiff between my build against 1.66 if it will help.

[1]: https://salsa.debian.org/debian/init-system-helpers/merge_requests/10

Regards,
Jun Mo

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.7.12-amd64 (SMP w/2 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE,
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8),
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: runit (via /run/runit.stopit)
LSM: AppArmor: enabled

Versions of packages init-system-helpers depends on:
ii  runit-helper  2.16.2
ii  usr-is-merged 39
ii  usrmerge [usr-is-merged]  39

init-system-helpers recommends no packages.

init-system-helpers suggests no packages.

Version

Bug#924132: runit: Add support for runit in init-system-helpers

2021-04-07 Thread Lorenzo
On Tue, 17 Mar 2020 02:54:35 +0100 Lorenzo Puliti
 wrote:
> Package: init-system-helpers
> Version: 1.57runit1
> Followup-For: Bug #924132
> 
> Control: affects -1 + runit-init
> 
> Hi,
> I'm now maintaining runit:
> is there any update on the progress of this bug?
> If you don't have time to spend on this, would be ok
> if I ask another DD for an NMU?
> 
> Thanks
> Lorenzo
> 

Hi again,

This bug report is stuck since a long time and also the discussion on
salsa MR ended without reply nor upload on your side.
Now it's likely that I have to support also a catch-all package for
runit services in addition to the standard dh-runit code, but the idea
of runit relying on update-rc.d/invoke-rc.d code that would work for
that case has already been discarded..

Overall I think that the best way to go forward is that I divert
helpers with runit-init (as openrc and file-rc did in the past) so that
I can experiment and find a working solution for runit users without
generating bug on this package. 
We can always merge runit support later if we find a solution that
works for both sides.

Let me know if you disagree, but in that case please make sure you have
the time to join the discussion untill we find a solution.

Regards,
Lorenzo



Bug#924132: runit: Add support for runit in init-system-helpers

2020-03-17 Thread Lorenzo
Control: affects -1 + runit-init



Bug#924132: runit: Add support for runit in init-system-helpers

2020-03-16 Thread Lorenzo Puliti
Package: init-system-helpers
Version: 1.57runit1
Followup-For: Bug #924132

Control: affects -1 + runit-init

Hi,
I'm now maintaining runit:
is there any update on the progress of this bug?
If you don't have time to spend on this, would be ok
if I ask another DD for an NMU?

Thanks
Lorenzo


-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.5.9-van (SMP w/4 CPU cores; PREEMPT)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: runit (via /run/runit.stopit)

Versions of packages init-system-helpers depends on:
ii  perl-base  5.30.0-9

init-system-helpers recommends no packages.

init-system-helpers suggests no packages.

Versions of packages init-system-helpers is related to:
ii  insserv  1.21.0-1

-- no debconf information

-- debsums errors found:
debsums: changed file /usr/sbin/invoke-rc.d (from init-system-helpers package)
debsums: changed file /usr/sbin/update-rc.d (from init-system-helpers package)



Bug#924132: runit: Add support for runit in init-system-helpers

2019-05-27 Thread Felipe Sateler
On Sat, May 25, 2019 at 3:01 PM Lorenz  wrote:

> Sure, here is the link
>
> https://salsa.debian.org/debian/init-system-helpers/merge_requests/10
>
>
Thanks!

I'll take a look as soon as possible.

>

-- 

Saludos,
Felipe Sateler


Bug#924132: runit: Add support for runit in init-system-helpers

2019-05-25 Thread Lorenz
Sure, here is the link

https://salsa.debian.org/debian/init-system-helpers/merge_requests/10

Thanks

Il giorno ven 24 mag 2019 alle ore 19:59 Felipe Sateler 
ha scritto:

> Hi Lorenz
>
> On Tue, May 21, 2019, 11:42 Lorenzo Puliti  wrote:
>
>> Control: reassign 924132 init-system-helpers
>>
>> Dear init-system-helpers Maintainers,
>>
>>  here are a series of 5 commits that add support for runit-init into
>>  'update-rc.d', 'invoke-rc.d' and 'service' scripts.
>>
>>
>> https://salsa.debian.org/Lorenzo.ru.g-guest/init-system-helpers/commits/runit
>>
>>  This has been already reviewed by Dmitry Bogatov.
>>  If you don't have further question or requirements, can you upload to
>> experimental
>>  and then, after Buster release, to unstable?
>>
>
> Could you post the patches as a salsa MR? It would make for easier review.
>
>
> Saludos
>


Bug#924132: runit: Add support for runit in init-system-helpers

2019-05-24 Thread Felipe Sateler
Hi Lorenz

On Tue, May 21, 2019, 11:42 Lorenzo Puliti  wrote:

> Control: reassign 924132 init-system-helpers
>
> Dear init-system-helpers Maintainers,
>
>  here are a series of 5 commits that add support for runit-init into
>  'update-rc.d', 'invoke-rc.d' and 'service' scripts.
>
>
> https://salsa.debian.org/Lorenzo.ru.g-guest/init-system-helpers/commits/runit
>
>  This has been already reviewed by Dmitry Bogatov.
>  If you don't have further question or requirements, can you upload to
> experimental
>  and then, after Buster release, to unstable?
>

Could you post the patches as a salsa MR? It would make for easier review.


Saludos


Bug#924132: runit: Add support for runit in init-system-helpers

2019-05-21 Thread Lorenzo Puliti
Control: reassign 924132 init-system-helpers

Dear init-system-helpers Maintainers,
 
 here are a series of 5 commits that add support for runit-init into
 'update-rc.d', 'invoke-rc.d' and 'service' scripts.
 
 https://salsa.debian.org/Lorenzo.ru.g-guest/init-system-helpers/commits/runit
 
 This has been already reviewed by Dmitry Bogatov.
 If you don't have further question or requirements, can you upload to 
experimental 
 and then, after Buster release, to unstable?
 
 Thanks,
 Lorenzo



-- System Information:
Debian Release: 10.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.20.3-van (SMP w/4 CPU cores; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: runit (via /run/runit.stopit)

Versions of packages runit depends on:
ii  libc6   2.28-10
ii  runit-helper2.8.10
ii  sysuser-helper  1.3.3

Versions of packages runit recommends:
ii  runit-init  2.1.2-30

runit suggests no packages.

-- Configuration Files:
/etc/runit/2 changed [not included]
/etc/runit/3 changed [not included]

-- no debconf information



Bug#924132: runit: Add support for runit in init-system-helpers

2019-03-11 Thread Dmitry Bogatov


[2019-03-09 21:05] Lorenzo Puliti 
> this is for buster +1
>
> Here is my proposal for adding runit-init support in 
> 'init-system-helpers'; please do not reassign to init-system-helpers
> as this need also some changes in runit and dh-runit to work properly.
> This is still a work in progress but it's enough to do some testing:
>  
>  * for init-system-helpers look here
> https://salsa.debian.org/Lorenzo.ru.g-guest/init-system-helpers
> 
>  * for runit look here
> https://salsa.debian.org/Lorenzo.ru.g-guest/runit/tree/runsvchd+helpers
> (this include also commits for #916973 and for #924038)
>
> For more details and (hopefully) a discussion look here
> https://www.freelists.org/post/debian-runit/Runitinit-support-in-initsystemhelpers

Thank you for your work. It will take me some time to understand your
proposal, see code and think about it.
-- 
Note, that I send and fetch email in batch, once every 24 hours.
 If matter is urgent, try https://t.me/kaction
 --



Bug#924132: runit: Add support for runit in init-system-helpers

2019-03-09 Thread Lorenzo Puliti
Package: runit
Version: 2.1.2-24helpers1
Severity: wishlist
Tags: patch

Hi,

this is for buster +1

Here is my proposal for adding runit-init support in 
'init-system-helpers'; please do not reassign to init-system-helpers
as this need also some changes in runit and dh-runit to work properly.
This is still a work in progress but it's enough to do some testing:
 
 * for init-system-helpers look here
https://salsa.debian.org/Lorenzo.ru.g-guest/init-system-helpers

 * for runit look here
https://salsa.debian.org/Lorenzo.ru.g-guest/runit/tree/runsvchd+helpers
(this include also commits for #916973 and for #924038)

For more details and (hopefully) a discussion look here
https://www.freelists.org/post/debian-runit/Runitinit-support-in-initsystemhelpers

Thanks,
Lorenzo


-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.20.3-van (SMP w/4 CPU cores; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: runit (via /run/runit.stopit)

Versions of packages runit depends on:
ii  libc6   2.28-8
ii  runit-helper2.8.7
ii  sysuser-helper  1.3.3

Versions of packages runit recommends:
ii  runit-init  2.1.2-24helpers1

runit suggests no packages.

-- Configuration Files:
/etc/runit/3 changed [not included]

-- no debconf information