Skip to content

Commit

Permalink
OpenRC no longer breaks the ZFS initscripts on Debian.
Browse files Browse the repository at this point in the history
Attempt to upstream the patches for the Debian+OpenRC setup.

Reference: openzfs/zfs#15977
Signed-off-by: Benda Xu <orv@debian.org>
  • Loading branch information
Benda Xu committed Mar 9, 2024
1 parent eebb775 commit a30f58b
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 62 deletions.
3 changes: 1 addition & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ Depends: libnvpair3linux (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends}
Recommends: zfs-modules | zfs-dkms, zfs-zed
Breaks: openrc,
spl (<< 0.7.9-2),
Breaks: spl (<< 0.7.9-2),
spl-dkms (<< 0.8.0~rc1),
zfs-dkms (<< ${source:Version}),
zfs-dkms (>> ${source:Version}...)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
From: Benda Xu <orv@debian.org>
Date: Sat, 9 Mar 2024 20:38:19 +0800
Subject: etc/init.d: decide which variant to use at build time.

Let Debian use the sysv-rc variant of the script, even when OpenRC is
installed. Unlike on Gentoo, OpenRC on Debian consumes both the
sysv-rc scripts and OpenRC ones. ZFS initscripts on Debian should be
the sysv-rc version to provide most compatibility and to integrate
with the rest of initscripts for dependency tracking.

Restrict the substitution in the Makefile to the dedicated list.

This construct is inspired by Mo Zhou's detection of the execution
shell and follows the strategy of Peter in 6ef28c526ba7.

Author: Benda Xu <orv@debian.org>
Forwarded: https://github.com/openzfs/zfs/pull/15977
Reference: https://github.com/openzfs/zfs/issues/8063
Reference: https://github.com/openzfs/zfs/issues/8204
Reference: https://github.com/openzfs/zfs/pull/8359
---
config/Substfiles.am | 1 +
config/zfs-build.m4 | 8 +++++---
etc/init.d/zfs-import.in | 2 +-
etc/init.d/zfs-load-key.in | 2 +-
etc/init.d/zfs-mount.in | 2 +-
etc/init.d/zfs-share.in | 3 ++-
etc/init.d/zfs-zed.in | 3 ++-
7 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/config/Substfiles.am b/config/Substfiles.am
index 38e870b..18422bf 100644
--- a/config/Substfiles.am
+++ b/config/Substfiles.am
@@ -18,6 +18,7 @@ subst_sed_cmd = \
-e 's|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \
-e 's|@DEFAULT_INIT_NFS_SERVER[@]|$(DEFAULT_INIT_NFS_SERVER)|g' \
-e 's|@DEFAULT_INIT_SHELL[@]|$(DEFAULT_INIT_SHELL)|g' \
+ -e 's|@IS_SYSV_RC[@]|$(IS_SYSV_RC)|g' \
-e 's|@LIBFETCH_DYNAMIC[@]|$(LIBFETCH_DYNAMIC)|g' \
-e 's|@LIBFETCH_SONAME[@]|$(LIBFETCH_SONAME)|g' \
-e 's|@PYTHON[@]|$(PYTHON)|g' \
diff --git a/config/zfs-build.m4 b/config/zfs-build.m4
index 5f36569..bb5a85d 100644
--- a/config/zfs-build.m4
+++ b/config/zfs-build.m4
@@ -578,13 +578,15 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [

AC_MSG_CHECKING([default shell])
case "$VENDOR" in
- gentoo) DEFAULT_INIT_SHELL="/sbin/openrc-run";;
- alpine) DEFAULT_INIT_SHELL="/sbin/openrc-run";;
- *) DEFAULT_INIT_SHELL="/bin/sh" ;;
+ gentoo|alpine) DEFAULT_INIT_SHELL=/sbin/openrc-run
+ IS_SYSV_RC=false ;;
+ *) DEFAULT_INIT_SHELL=/bin/sh
+ IS_SYSV_RC=true ;;
esac

AC_MSG_RESULT([$DEFAULT_INIT_SHELL])
AC_SUBST(DEFAULT_INIT_SHELL)
+ AC_SUBST(IS_SYSV_RC)

AC_MSG_CHECKING([default nfs server init script])
AS_IF([test "$VENDOR" = "debian"],
diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in
index a9a0604..ff169eb 100755
--- a/etc/init.d/zfs-import.in
+++ b/etc/init.d/zfs-import.in
@@ -307,7 +307,7 @@ do_start()

# ----------------------------------------------------

-if [ ! -e /sbin/openrc-run ]
+if @IS_SYSV_RC@
then
case "$1" in
start)
diff --git a/etc/init.d/zfs-load-key.in b/etc/init.d/zfs-load-key.in
index 53c7766..27dfeeb 100755
--- a/etc/init.d/zfs-load-key.in
+++ b/etc/init.d/zfs-load-key.in
@@ -104,7 +104,7 @@ do_stop()

# ----------------------------------------------------

-if [ ! -e /sbin/openrc-run ]
+if @IS_SYSV_RC@
then
case "$1" in
start)
diff --git a/etc/init.d/zfs-mount.in b/etc/init.d/zfs-mount.in
index a0825f1..6a3ca5f 100755
--- a/etc/init.d/zfs-mount.in
+++ b/etc/init.d/zfs-mount.in
@@ -114,7 +114,7 @@ do_stop()

# ----------------------------------------------------

-if [ ! -e /sbin/openrc-run ]
+if @IS_SYSV_RC@
then
case "$1" in
start)
diff --git a/etc/init.d/zfs-share.in b/etc/init.d/zfs-share.in
index 8897807..06c59c6 100755
--- a/etc/init.d/zfs-share.in
+++ b/etc/init.d/zfs-share.in
@@ -57,7 +57,8 @@ do_stop()

# ----------------------------------------------------

-if [ ! -e /sbin/openrc-run ]; then
+if @IS_SYSV_RC@
+then
case "$1" in
start)
do_start
diff --git a/etc/init.d/zfs-zed.in b/etc/init.d/zfs-zed.in
index e9cf886..3d40600 100755
--- a/etc/init.d/zfs-zed.in
+++ b/etc/init.d/zfs-zed.in
@@ -93,7 +93,8 @@ do_reload()

# ----------------------------------------------------

-if [ ! -e /sbin/openrc-run ]; then
+if @IS_SYSV_RC@
+then
case "$1" in
start)
do_start
2 changes: 1 addition & 1 deletion debian/patches/series
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#unapplied/init-debian-openrc-workaround.patch # OpenRC users can apply this locally
0016-etc-init.d-decide-which-variant-to-use-at-build-time.patch
1000-dont-symlink-zed-scripts.patch
1001-Prevent-manual-builds-in-the-DKMS-source.patch
1002-Check-for-META-and-DCH-consistency-in-autoconf.patch
Expand Down
59 changes: 0 additions & 59 deletions debian/patches/unapplied/init-debian-openrc-workaround.patch

This file was deleted.

0 comments on commit a30f58b

Please sign in to comment.