Source: daemontools
Version: 1:0.76-15
Severity: wishlist
Tags: patch
X-Debbugs-Cc: [email protected]

Dear Maintainer,

The daemontools-inspired family of supervision suites typically share the
ability to emulate some subset of the daemontools tools with compatible
behaviour.

For example, chpst from runit can emulate envdir, envuidgid, pgrphack, setlock,
setuidgid and softlimit.

Similarly, run scripts for daemons using these suites, if they don't take
advantage of features unique to those suites, may be compatible between them.

In practice, that compatibility is limited because of features included in
distributions, such as runit service directories in Debian typically using
/usr/lib/runit/invoke-run to perform some standard actions. However, third
party-provided service directories especially may well stick to the basics. The
debian package 'publicfile' is compatible with daemontools and runit
supervision.

Ideally someone writing a run script that only needed the behaviour of
'setlock' would simply call 'setlock', for example. However, that would
mean unnecessarily depending on the daemontools package when your
service might be running with runit that already has 'chpst' installed,
and so will be written to use 'chpst -l' instead.

We can fix this by installing all the common tools using the Debian
'alternatives' mechanism. This is very lightweight - symlink traversal is
extremely cheap in Linux.

I attach a patch for daemontools that does this. For simplicitly it groups
together all the tools that 'chpst' can emulate (headlined by the 'envdir'
tool), but theses could be split into a different alternative for each tool if
one wanted that granularity. An additional group just contains 'fghack', which
my 'xchpst' tool can also emulate.

I also attach example patches for the 'runit' and 'xchpst' packages to show how
this could work.

Here is some example output:

  # sudo update-alternatives --config  daemontools
  There are 3 choices for the alternative daemontools (providing 
/usr/bin/envdir).
  
    Selection    Path                 Priority   Status
  ------------------------------------------------------------
    0            /usr/bin/envdir.djb   50        auto mode
    1            /usr/bin/chpst        30        manual mode
    2            /usr/bin/envdir.djb   50        manual mode
  * 3            /usr/bin/xchpst       40        manual mode
  
  Press <enter> to keep the current choice[*], or type selection number: 1
  update-alternatives: using /usr/bin/chpst to provide /usr/bin/envdir 
(daemontools) in manual mode

The presence of alternatives will also help developers trying to compare
behaviours across different toolsets.

What do you think about this idea?

Andrew

-- System Information:
Debian Release: forky/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.18.9+deb14-amd64 (SMP w/24 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled
diff --git a/debian/daemontools-man/envdir.8 b/debian/daemontools-man/envdir.djb.8
similarity index 100%
rename from debian/daemontools-man/envdir.8
rename to debian/daemontools-man/envdir.djb.8
diff --git a/debian/daemontools-man/envuidgid.8 b/debian/daemontools-man/envuidgid.djb.8
similarity index 100%
rename from debian/daemontools-man/envuidgid.8
rename to debian/daemontools-man/envuidgid.djb.8
diff --git a/debian/daemontools-man/fghack.8 b/debian/daemontools-man/fghack.djb.8
similarity index 100%
rename from debian/daemontools-man/fghack.8
rename to debian/daemontools-man/fghack.djb.8
diff --git a/debian/daemontools-man/pgrphack.8 b/debian/daemontools-man/pgrphack.djb.8
similarity index 100%
rename from debian/daemontools-man/pgrphack.8
rename to debian/daemontools-man/pgrphack.djb.8
diff --git a/debian/daemontools-man/setlock.8 b/debian/daemontools-man/setlock.djb.8
similarity index 100%
rename from debian/daemontools-man/setlock.8
rename to debian/daemontools-man/setlock.djb.8
diff --git a/debian/daemontools-man/setuidgid.8 b/debian/daemontools-man/setuidgid.djb.8
similarity index 100%
rename from debian/daemontools-man/setuidgid.8
rename to debian/daemontools-man/setuidgid.djb.8
diff --git a/debian/daemontools-man/softlimit.8 b/debian/daemontools-man/softlimit.djb.8
similarity index 100%
rename from debian/daemontools-man/softlimit.8
rename to debian/daemontools-man/softlimit.djb.8
diff --git a/debian/daemontools.alternatives b/debian/daemontools.alternatives
new file mode 100644
index 0000000..9ea64ae
--- /dev/null
+++ b/debian/daemontools.alternatives
@@ -0,0 +1,23 @@
+Name: daemontools
+Link: /usr/bin/envdir
+Alternative: /usr/bin/envdir.djb
+Dependents:
+  /usr/bin/envuidgid envuidgid /usr/bin/envuidgid.djb
+  /usr/bin/pgrphack pgrphack /usr/bin/pgrphack.djb
+  /usr/bin/setlock setlock /usr/bin/setlock.djb
+  /usr/bin/setuidgid setuidgid /usr/bin/setuidgid.djb
+  /usr/bin/softlimit softlimit /usr/bin/softlimit.djb
+  /usr/share/man/man8/envdir.8.gz envdir.8.gz /usr/share/man/man8/envdir.djb.8.gz
+  /usr/share/man/man8/envuidgid.8.gz envuidgid.8.gz /usr/share/man/man8/envuidgid.djb.8.gz
+  /usr/share/man/man8/pgrphack.8.gz pgrphack.8.gz /usr/share/man/man8/pgrphack.djb.8.gz
+  /usr/share/man/man8/setlock.8.gz setlock.8.gz /usr/share/man/man8/setlock.djb.8.gz
+  /usr/share/man/man8/setuidgid.8.gz setuidgid.8.gz /usr/share/man/man8/setuidgid.djb.8.gz
+  /usr/share/man/man8/softlimit.8.gz softlimit.8.gz /usr/share/man/man8/softlimit.djb.8.gz
+Priority: 50
+
+Name: fghack
+Link: /usr/bin/fghack
+Alternative: /usr/bin/fghack.djb
+Dependents:
+  /usr/share/man/man8/fghack.8.gz fghack.8.gz /usr/share/man/man8/fghack.djb.8.gz
+Priority: 50
diff --git a/debian/rules b/debian/rules
index 25ced00..4c4cdd5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,6 +7,8 @@ export DEB_CFLAGS_MAINT_APPEND = -std=gnu11 -Wno-incompatible-pointer-types -Wno
 
 DIR=daemontools-0.76
 
+COMMON_SUPERVISION_TOOLS=envdir envuidgid fghack pgrphack setlock setuidgid softlimit
+
 override_dh_auto_build:
 	# create compile directory
 	mkdir -p '$(DIR)/compile/debian'
@@ -23,6 +25,9 @@ override_dh_auto_build:
 	cd '$(DIR)' && package/compile
 	# print sysdeps
 	cat $(DIR)/compile/sysdeps
+	# rename commands shared by other supervision suites that will be
+	# registered as 'alternatives'
+	cd $(DIR)/command && for f in $(COMMON_SUPERVISION_TOOLS); do mv $$f $$f.djb; done
 
 override_dh_auto_clean:
 	dh_auto_clean
commit 7fe44ff5be728e8f2a023ca9a1bc750bcd1a58ff
Author: Andrew Bower <[email protected]>
Date:   Sat Feb 21 17:22:43 2026 +0000

    add daemontools alternatives

diff --git a/debian/runit.alternatives b/debian/runit.alternatives
new file mode 100644
index 0000000..3af3508
--- /dev/null
+++ b/debian/runit.alternatives
@@ -0,0 +1,16 @@
+Name: daemontools
+Link: /usr/bin/envdir
+Alternative: /usr/bin/chpst
+Dependents:
+  /usr/bin/envuidgid envuidgid /usr/bin/chpst
+  /usr/bin/pgrphack pgrphack /usr/bin/chpst
+  /usr/bin/setlock setlock /usr/bin/chpst
+  /usr/bin/setuidgid setuidgid /usr/bin/chpst
+  /usr/bin/softlimit softlimit /usr/bin/chpst
+  /usr/share/man/man8/envdir.8.gz envdir.8.gz /usr/share/man/man8/chpst.8.gz
+  /usr/share/man/man8/envuidgid.8.gz envuidgid.8.gz /usr/share/man/man8/chpst.8.gz
+  /usr/share/man/man8/pgrphack.8.gz pgrphack.8.gz /usr/share/man/man8/chpst.8.gz
+  /usr/share/man/man8/setlock.8.gz setlock.8.gz /usr/share/man/man8/chpst.8.gz
+  /usr/share/man/man8/setuidgid.8.gz setuidgid.8.gz /usr/share/man/man8/chpst.8.gz
+  /usr/share/man/man8/softlimit.8.gz softlimit.8.gz /usr/share/man/man8/chpst.8.gz
+Priority: 30
diff --git a/debian/xchpst.alternatives b/debian/xchpst.alternatives
new file mode 100644
index 0000000..a721629
--- /dev/null
+++ b/debian/xchpst.alternatives
@@ -0,0 +1,23 @@
+Name: daemontools
+Link: /usr/bin/envdir
+Alternative: /usr/bin/xchpst
+Dependents:
+  /usr/bin/envuidgid envuidgid /usr/bin/xchpst
+  /usr/bin/pgrphack pgrphack /usr/bin/xchpst
+  /usr/bin/setlock setlock /usr/bin/xchpst
+  /usr/bin/setuidgid setuidgid /usr/bin/xchpst
+  /usr/bin/softlimit softlimit /usr/bin/xchpst
+  /usr/share/man/man8/envdir.8.gz envdir.8.gz /usr/share/man/man8/xchpst.8.gz
+  /usr/share/man/man8/envuidgid.8.gz envuidgid.8.gz /usr/share/man/man8/xchpst.8.gz
+  /usr/share/man/man8/pgrphack.8.gz pgrphack.8.gz /usr/share/man/man8/xchpst.8.gz
+  /usr/share/man/man8/setlock.8.gz setlock.8.gz /usr/share/man/man8/xchpst.8.gz
+  /usr/share/man/man8/setuidgid.8.gz setuidgid.8.gz /usr/share/man/man8/xchpst.8.gz
+  /usr/share/man/man8/softlimit.8.gz softlimit.8.gz /usr/share/man/man8/xchpst.8.gz
+Priority: 40
+
+Name: fghack
+Link: /usr/bin/fghack
+Alternative: /usr/bin/xchpst
+Dependents:
+  /usr/share/man/man8/fghack.8.gz fghack.8.gz /usr/share/man/man8/xchpst.8.gz
+Priority: 40

Reply via email to