Skip to content

Commit a30f58b

Browse files
author
Benda Xu
committed
OpenRC no longer breaks the ZFS initscripts on Debian.
Attempt to upstream the patches for the Debian+OpenRC setup. Reference: openzfs/zfs#15977 Signed-off-by: Benda Xu <[email protected]>
1 parent eebb775 commit a30f58b

File tree

4 files changed

+134
-62
lines changed

4 files changed

+134
-62
lines changed

debian/control

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ Depends: libnvpair3linux (= ${binary:Version}),
243243
${misc:Depends},
244244
${shlibs:Depends}
245245
Recommends: zfs-modules | zfs-dkms, zfs-zed
246-
Breaks: openrc,
247-
spl (<< 0.7.9-2),
246+
Breaks: spl (<< 0.7.9-2),
248247
spl-dkms (<< 0.8.0~rc1),
249248
zfs-dkms (<< ${source:Version}),
250249
zfs-dkms (>> ${source:Version}...)
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
From: Benda Xu <[email protected]>
2+
Date: Sat, 9 Mar 2024 20:38:19 +0800
3+
Subject: etc/init.d: decide which variant to use at build time.
4+
5+
Let Debian use the sysv-rc variant of the script, even when OpenRC is
6+
installed. Unlike on Gentoo, OpenRC on Debian consumes both the
7+
sysv-rc scripts and OpenRC ones. ZFS initscripts on Debian should be
8+
the sysv-rc version to provide most compatibility and to integrate
9+
with the rest of initscripts for dependency tracking.
10+
11+
Restrict the substitution in the Makefile to the dedicated list.
12+
13+
This construct is inspired by Mo Zhou's detection of the execution
14+
shell and follows the strategy of Peter in 6ef28c526ba7.
15+
16+
Author: Benda Xu <[email protected]>
17+
Forwarded: https://github.com/openzfs/zfs/pull/15977
18+
Reference: https://github.com/openzfs/zfs/issues/8063
19+
Reference: https://github.com/openzfs/zfs/issues/8204
20+
Reference: https://github.com/openzfs/zfs/pull/8359
21+
---
22+
config/Substfiles.am | 1 +
23+
config/zfs-build.m4 | 8 +++++---
24+
etc/init.d/zfs-import.in | 2 +-
25+
etc/init.d/zfs-load-key.in | 2 +-
26+
etc/init.d/zfs-mount.in | 2 +-
27+
etc/init.d/zfs-share.in | 3 ++-
28+
etc/init.d/zfs-zed.in | 3 ++-
29+
7 files changed, 13 insertions(+), 8 deletions(-)
30+
31+
diff --git a/config/Substfiles.am b/config/Substfiles.am
32+
index 38e870b..18422bf 100644
33+
--- a/config/Substfiles.am
34+
+++ b/config/Substfiles.am
35+
@@ -18,6 +18,7 @@ subst_sed_cmd = \
36+
-e 's|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \
37+
-e 's|@DEFAULT_INIT_NFS_SERVER[@]|$(DEFAULT_INIT_NFS_SERVER)|g' \
38+
-e 's|@DEFAULT_INIT_SHELL[@]|$(DEFAULT_INIT_SHELL)|g' \
39+
+ -e 's|@IS_SYSV_RC[@]|$(IS_SYSV_RC)|g' \
40+
-e 's|@LIBFETCH_DYNAMIC[@]|$(LIBFETCH_DYNAMIC)|g' \
41+
-e 's|@LIBFETCH_SONAME[@]|$(LIBFETCH_SONAME)|g' \
42+
-e 's|@PYTHON[@]|$(PYTHON)|g' \
43+
diff --git a/config/zfs-build.m4 b/config/zfs-build.m4
44+
index 5f36569..bb5a85d 100644
45+
--- a/config/zfs-build.m4
46+
+++ b/config/zfs-build.m4
47+
@@ -578,13 +578,15 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
48+
49+
AC_MSG_CHECKING([default shell])
50+
case "$VENDOR" in
51+
- gentoo) DEFAULT_INIT_SHELL="/sbin/openrc-run";;
52+
- alpine) DEFAULT_INIT_SHELL="/sbin/openrc-run";;
53+
- *) DEFAULT_INIT_SHELL="/bin/sh" ;;
54+
+ gentoo|alpine) DEFAULT_INIT_SHELL=/sbin/openrc-run
55+
+ IS_SYSV_RC=false ;;
56+
+ *) DEFAULT_INIT_SHELL=/bin/sh
57+
+ IS_SYSV_RC=true ;;
58+
esac
59+
60+
AC_MSG_RESULT([$DEFAULT_INIT_SHELL])
61+
AC_SUBST(DEFAULT_INIT_SHELL)
62+
+ AC_SUBST(IS_SYSV_RC)
63+
64+
AC_MSG_CHECKING([default nfs server init script])
65+
AS_IF([test "$VENDOR" = "debian"],
66+
diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in
67+
index a9a0604..ff169eb 100755
68+
--- a/etc/init.d/zfs-import.in
69+
+++ b/etc/init.d/zfs-import.in
70+
@@ -307,7 +307,7 @@ do_start()
71+
72+
# ----------------------------------------------------
73+
74+
-if [ ! -e /sbin/openrc-run ]
75+
+if @IS_SYSV_RC@
76+
then
77+
case "$1" in
78+
start)
79+
diff --git a/etc/init.d/zfs-load-key.in b/etc/init.d/zfs-load-key.in
80+
index 53c7766..27dfeeb 100755
81+
--- a/etc/init.d/zfs-load-key.in
82+
+++ b/etc/init.d/zfs-load-key.in
83+
@@ -104,7 +104,7 @@ do_stop()
84+
85+
# ----------------------------------------------------
86+
87+
-if [ ! -e /sbin/openrc-run ]
88+
+if @IS_SYSV_RC@
89+
then
90+
case "$1" in
91+
start)
92+
diff --git a/etc/init.d/zfs-mount.in b/etc/init.d/zfs-mount.in
93+
index a0825f1..6a3ca5f 100755
94+
--- a/etc/init.d/zfs-mount.in
95+
+++ b/etc/init.d/zfs-mount.in
96+
@@ -114,7 +114,7 @@ do_stop()
97+
98+
# ----------------------------------------------------
99+
100+
-if [ ! -e /sbin/openrc-run ]
101+
+if @IS_SYSV_RC@
102+
then
103+
case "$1" in
104+
start)
105+
diff --git a/etc/init.d/zfs-share.in b/etc/init.d/zfs-share.in
106+
index 8897807..06c59c6 100755
107+
--- a/etc/init.d/zfs-share.in
108+
+++ b/etc/init.d/zfs-share.in
109+
@@ -57,7 +57,8 @@ do_stop()
110+
111+
# ----------------------------------------------------
112+
113+
-if [ ! -e /sbin/openrc-run ]; then
114+
+if @IS_SYSV_RC@
115+
+then
116+
case "$1" in
117+
start)
118+
do_start
119+
diff --git a/etc/init.d/zfs-zed.in b/etc/init.d/zfs-zed.in
120+
index e9cf886..3d40600 100755
121+
--- a/etc/init.d/zfs-zed.in
122+
+++ b/etc/init.d/zfs-zed.in
123+
@@ -93,7 +93,8 @@ do_reload()
124+
125+
# ----------------------------------------------------
126+
127+
-if [ ! -e /sbin/openrc-run ]; then
128+
+if @IS_SYSV_RC@
129+
+then
130+
case "$1" in
131+
start)
132+
do_start

debian/patches/series

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#unapplied/init-debian-openrc-workaround.patch # OpenRC users can apply this locally
1+
0016-etc-init.d-decide-which-variant-to-use-at-build-time.patch
22
1000-dont-symlink-zed-scripts.patch
33
1001-Prevent-manual-builds-in-the-DKMS-source.patch
44
1002-Check-for-META-and-DCH-consistency-in-autoconf.patch

debian/patches/unapplied/init-debian-openrc-workaround.patch

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)