Subject: Updated Patches and Debian LSB_Release Check

From: Chris Dos <[email-masked]>
Date: Sun, 3 Jun 2018 08:24:13 -0600

Debian has added a specific lsb_release check to make sure the packages are
running on Debian in the zfs-dkms package when it tries to compile against the
kernel source.

See: https://bugs.debian.org/900089

So the zfs-dkms Debian package will refuse to work on Devuan now.

And it has been few days shy of two years and Debian still won't commit the
sysvinit patch.  :(
https://bugs.debian.org/826994

I've attached patches to remove the lsb_release and install the sysvinit
patches against zfs-0.7.9-3:

	Chris
--- a/debian/zfs-dkms/usr/src/zfs-0.7.9/dkms.conf
+++ b/debian/zfs-dkms/usr/src/zfs-0.7.9/dkms.conf
@@ -6,8 +6,6 @@
   --prefix=/usr
   --with-config=kernel
   --with-linux=$(
-    case `lsb_release -is` in
-      (Debian)
         if [[ -e ${kernel_source_dir/%build/source} ]]
         then
           echo ${kernel_source_dir/%build/source}
@@ -15,11 +13,6 @@
           # A kpkg exception for Proxmox 2.0
           echo ${kernel_source_dir}
         fi
-      ;;
-      (*)
-        echo ${kernel_source_dir}
-      ;;
-    esac
   )
   --with-linux-obj=${kernel_source_dir}
   --with-spl=${source_tree}/spl-${PACKAGE_VERSION}
--- a/debian/zfs-dkms.dkms.debhelper
+++ b/debian/zfs-dkms.dkms.debhelper
@@ -6,8 +6,6 @@
   --prefix=/usr
   --with-config=kernel
   --with-linux=$(
-    case `lsb_release -is` in
-      (Debian)
         if [[ -e ${kernel_source_dir/%build/source} ]]
         then
           echo ${kernel_source_dir/%build/source}
@@ -15,11 +13,6 @@
           # A kpkg exception for Proxmox 2.0
           echo ${kernel_source_dir}
         fi
-      ;;
-      (*)
-        echo ${kernel_source_dir}
-      ;;
-    esac
   )
   --with-linux-obj=${kernel_source_dir}
   --with-spl=${source_tree}/spl-${PACKAGE_VERSION}
--- a/debian/zfs-dkms.dkms
+++ b/debian/zfs-dkms.dkms
@@ -6,8 +6,6 @@
   --prefix=/usr
   --with-config=kernel
   --with-linux=$(
-    case `lsb_release -is` in
-      (Debian)
         if [[ -e ${kernel_source_dir/%build/source} ]]
         then
           echo ${kernel_source_dir/%build/source}
@@ -15,11 +13,6 @@
           # A kpkg exception for Proxmox 2.0
           echo ${kernel_source_dir}
         fi
-      ;;
-      (*)
-        echo ${kernel_source_dir}
-      ;;
-    esac
   )
   --with-linux-obj=${kernel_source_dir}
   --with-spl=${source_tree}/spl-${PACKAGE_VERSION}
diff -Nru zfs-linux-0.7.9/debian/changelog zfs-linux-0.7.9/debian/changelog
--- zfs-linux-0.7.9/debian/changelog	2018-05-28 04:22:02.000000000 -0600
+++ zfs-linux-0.7.9/debian/changelog	2018-06-03 07:12:43.000000000 -0600
@@ -1,3 +1,10 @@
+zfs-linux (0.7.9-3.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Add sysvinit scripts. 
+
+ -- Chris Dos <[email-masked]>  Sun, 03 Jun 2018 07:12:43 -0600
+
 zfs-linux (0.7.9-3) unstable; urgency=medium
 
   [ Antonio Russo ]
diff -Nru zfs-linux-0.7.9/debian/patches/1004-zed-service-bindir.patch zfs-linux-0.7.9/debian/patches/1004-zed-service-bindir.patch
--- zfs-linux-0.7.9/debian/patches/1004-zed-service-bindir.patch	2018-05-16 07:38:12.000000000 -0600
+++ zfs-linux-0.7.9/debian/patches/1004-zed-service-bindir.patch	2018-06-03 07:08:42.000000000 -0600
@@ -1,11 +1,14 @@
-Description: Fix the path to the zed binary on the systemd unit.
+Description: Fix the path to the zed binary on the systemd unit and
+ the sysvinit script.
  We install zed into /usr/sbin manually meanwhile the upstream default
  is installing it into /sbin.
  Ubuntu packages also install zed to /usr/sbin, but they ship their own
  zfs-zed unit.
 Author: Carlos Alberto Lopez <[email-masked]>
 Author: Fabian Grünbichler <[email-masked]>
+Author: Chris Dos <[email-masked]>
 Bug-Debian: https://bugs.debian.org/849813
+Bug-Debian: https://bugs.debian.org/826994
 Forwarded: no
 --- a/etc/systemd/system/zfs-zed.service.in
 +++ b/etc/systemd/system/zfs-zed.service.in
@@ -18,3 +21,13 @@
  Restart=on-abort
  
  [Install]
+--- a/etc/init.d/zfs-functions.in
++++ b/etc/init.d/zfs-functions.in
+@@ -89,7 +89,7 @@
+
+ # Paths to what we need
+ ZFS="@sbindir@/zfs"
+-ZED="@sbindir@/zed"
++ZED="/usr/sbin/zed"
+ ZPOOL="@sbindir@/zpool"
+ ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"
diff -Nru zfs-linux-0.7.9/debian/rules zfs-linux-0.7.9/debian/rules
--- zfs-linux-0.7.9/debian/rules	2018-05-17 10:11:36.000000000 -0600
+++ zfs-linux-0.7.9/debian/rules	2018-06-03 07:10:41.000000000 -0600
@@ -114,6 +114,26 @@
 	chmod a-x $(CURDIR)/debian/tmp/etc/zfs/zfs-functions
 	chmod a-x $(CURDIR)/debian/tmp/etc/default/zfs
 
+override_dh_installinit:
+	@# Install the /etc/init.d/zfs-import script.
+	dh_installinit -pzfsutils-linux --name=zfs-import \
+	--no-restart-on-upgrade --no-start
+
+	@# Install the /etc/init.d/zfs-mount script.
+	dh_installinit -pzfsutils-linux --name=zfs-mount \
+	--no-restart-on-upgrade --no-start
+
+	@# Install the /etc/init.d/zfs-share script.
+	dh_installinit -pzfsutils-linux --name=zfs-share \
+	--no-restart-on-upgrade --no-start
+
+	@# Add a dummy (link to /dev/null) for zfs-import.service
+	ln -s /dev/null $(CURDIR)/debian/zfsutils-linux/lib/systemd/system/zfs-import.service
+
+	@# Install the ZED init file.
+	dh_installinit -pzfs-zed --name=zfs-zed \
+	--no-restart-on-upgrade --no-start
+
 override_dh_dkms:
 	dh_dkms -V $(DEB_VERSION_UPSTREAM)
 
diff -Nru zfs-linux-0.7.9/debian/zfsutils-linux.install zfs-linux-0.7.9/debian/zfsutils-linux.install
--- zfs-linux-0.7.9/debian/zfsutils-linux.install	2018-05-28 04:07:08.000000000 -0600
+++ zfs-linux-0.7.9/debian/zfsutils-linux.install	2018-06-03 07:10:41.000000000 -0600
@@ -1,6 +1,8 @@
 ../tree/zfsutils-linux/* /
 etc/default/zfs
 etc/zfs/zfs-functions
+etc/init.d/zfs-import
+etc/init.d/zfs-mount
 etc/zfs/zpool.d/
 lib/systemd/system-preset/
 lib/systemd/system/zfs-import-cache.service
diff -Nru zfs-linux-0.7.9/debian/zfs-zed.install zfs-linux-0.7.9/debian/zfs-zed.install
--- zfs-linux-0.7.9/debian/zfs-zed.install	2018-05-16 07:38:12.000000000 -0600
+++ zfs-linux-0.7.9/debian/zfs-zed.install	2018-06-03 07:10:41.000000000 -0600
@@ -1,4 +1,6 @@
 etc/zfs/zed.d/*
+etc/init.d/zfs-zed
+etc/init.d/zfs-share
 lib/systemd/system/zfs-zed.service
 usr/lib/*/zfs/zed.d/*
 usr/sbin/zed