From a30f58bdac38b21e989be4fe40decd70da42ee10 Mon Sep 17 00:00:00 2001 From: Benda Xu Date: Thu, 18 Jan 2024 21:57:55 +0800 Subject: [PATCH] OpenRC no longer breaks the ZFS initscripts on Debian. Attempt to upstream the patches for the Debian+OpenRC setup. Reference: https://github.com/openzfs/zfs/pull/15977 Signed-off-by: Benda Xu --- debian/control | 3 +- ...e-which-variant-to-use-at-build-time.patch | 132 ++++++++++++++++++ debian/patches/series | 2 +- .../init-debian-openrc-workaround.patch | 59 -------- 4 files changed, 134 insertions(+), 62 deletions(-) create mode 100644 debian/patches/0016-etc-init.d-decide-which-variant-to-use-at-build-time.patch delete mode 100644 debian/patches/unapplied/init-debian-openrc-workaround.patch diff --git a/debian/control b/debian/control index 6a03be350..152bc65de 100644 --- a/debian/control +++ b/debian/control @@ -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}...) diff --git a/debian/patches/0016-etc-init.d-decide-which-variant-to-use-at-build-time.patch b/debian/patches/0016-etc-init.d-decide-which-variant-to-use-at-build-time.patch new file mode 100644 index 000000000..b7f0407b5 --- /dev/null +++ b/debian/patches/0016-etc-init.d-decide-which-variant-to-use-at-build-time.patch @@ -0,0 +1,132 @@ +From: Benda Xu +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 +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 diff --git a/debian/patches/series b/debian/patches/series index 59c3d69eb..a8a376d25 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -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 diff --git a/debian/patches/unapplied/init-debian-openrc-workaround.patch b/debian/patches/unapplied/init-debian-openrc-workaround.patch deleted file mode 100644 index e97784673..000000000 --- a/debian/patches/unapplied/init-debian-openrc-workaround.patch +++ /dev/null @@ -1,59 +0,0 @@ -Description: Make these scripts work for Debian+OpenRC setup. -Author: Mo Zhou -Last-update: 20181026 -Forward: https://github.com/zfsonlinux/zfs/issues/8063 - -Index: zfs-linux/etc/init.d/zfs-import.in -=================================================================== ---- zfs-linux.orig/etc/init.d/zfs-import.in -+++ zfs-linux/etc/init.d/zfs-import.in -@@ -309,8 +309,7 @@ do_start() - - # ---------------------------------------------------- - --if [ ! -e /sbin/openrc-run ] --then -+if ! (echo @SHELL@ | grep openrc 1>/dev/null 2>/dev/null); then - case "$1" in - start) - do_start -Index: zfs-linux/etc/init.d/zfs-mount.in -=================================================================== ---- zfs-linux.orig/etc/init.d/zfs-mount.in -+++ zfs-linux/etc/init.d/zfs-mount.in -@@ -199,8 +199,7 @@ do_stop() - - # ---------------------------------------------------- - --if [ ! -e /sbin/openrc-run ] --then -+if ! (echo @SHELL@ | grep openrc 1>/dev/null 2>/dev/null); then - case "$1" in - start) - do_start -Index: zfs-linux/etc/init.d/zfs-share.in -=================================================================== ---- zfs-linux.orig/etc/init.d/zfs-share.in -+++ zfs-linux/etc/init.d/zfs-share.in -@@ -58,7 +58,7 @@ do_stop() - - # ---------------------------------------------------- - --if [ ! -e /sbin/openrc-run ]; then -+if ! (echo @SHELL@ | grep openrc 1>/dev/null 2>/dev/null); then - case "$1" in - start) - do_start -Index: zfs-linux/etc/init.d/zfs-zed.in -=================================================================== ---- zfs-linux.orig/etc/init.d/zfs-zed.in -+++ zfs-linux/etc/init.d/zfs-zed.in -@@ -98,7 +98,7 @@ do_reload() - - # ---------------------------------------------------- - --if [ ! -e /sbin/openrc-run ]; then -+if ! (echo @SHELL@ | grep openrc 1>/dev/null 2>/dev/null); then - case "$1" in - start) - do_start