From 6ea6f086a714ed9157f7e880426a71f46f48c2db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <f.gruenbichler@proxmox.com>
Date: Mon, 6 Feb 2017 11:03:10 +0100
Subject: [PATCH 1/3] remove DKMS, modules and dracut build
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
 debian/control.in |  34 +++---------------
 debian/control    |   1 -
 debian/rules      | 105 ++----------------------------------------------------
 3 files changed, 6 insertions(+), 134 deletions(-)

diff --git a/debian/control.in b/debian/control.in
index 76907e45..235e74c9 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -9,7 +9,6 @@ Build-Depends: dh-autoreconf,
                dh-systemd,
                autotools-dev,
                debhelper (>= 9),
-               dkms (>> 2.1.1.2-5),
                libselinux1-dev,
                libtool,
                lsb-release,
@@ -85,25 +84,11 @@ Description: OpenZFS pool library for Linux
  .
  This zpool library provides support for managing zpools.
 
-Package: zfs-dkms
-Architecture: all
-Pre-Depends: spl-dkms (>= ${source:Upstream-Version})
-Depends: dkms (>> 2.1.1.2-5), lsb-release, ${misc:Depends}
-Recommends: zfsutils-linux, zfs-zed
-Provides: zfs-modules
-Description: OpenZFS filesystem kernel modules for Linux
- The Z file system is a pooled filesystem designed for maximum data
- integrity, supporting data snapshots, multiple copies, and data
- checksums.
- .
- This DKMS package includes the SPA, DMU, ZVOL, and ZPL components of
- OpenZFS.
-
 Package: zfs-initramfs
 Architecture: all
 Depends: initramfs-tools,
  busybox-initramfs | busybox-static | busybox,
- zfs-modules | zfs-dkms, zfsutils-linux,
+ zfsutils-linux,
  ${misc:Depends}
 Description: OpenZFS root filesystem capabilities for Linux - initramfs
  The Z file system is a pooled filesystem designed for maximum data
@@ -113,23 +98,12 @@ Description: OpenZFS root filesystem capabilities for Linux - initramfs
  This package adds OpenZFS to the system initramfs with a hook
  for the initramfs-tools infrastructure.
 
-Package: zfs-dracut
-Architecture: all
-Depends: dracut, zfs-modules | zfs-dkms, zfsutils-linux, ${misc:Depends}
-Description: OpenZFS root filesystem capabilities for Linux - dracut
- The Z file system is a pooled filesystem designed for maximum data
- integrity, supporting data snapshots, multiple copies, and data
- checksums.
- .
- This package adds OpenZFS to the system initramfs with a hook
- for the dracut infrastructure.
-
 Package: zfsutils-linux
 Section: contrib/admin
 Architecture: linux-any
 Depends: ${misc:Depends}, ${shlibs:Depends}, ${python3:Depends}, python3
-Recommends: lsb-base, zfs-modules | zfs-dkms, zfs-zed
-Suggests: nfs-kernel-server, samba-common-bin (>= 3.0.23), zfs-initramfs | zfs-dracut
+Recommends: lsb-base, zfs-zed
+Suggests: nfs-kernel-server, samba-common-bin (>= 3.0.23), zfs-initramfs
 Conflicts: zfs, zfs-fuse, zutils
 Provides: zfsutils
 Description: command-line tools to manage OpenZFS filesystems
@@ -143,7 +117,7 @@ Description: command-line tools to manage OpenZFS filesystems
 Package: zfs-zed
 Section: contrib/admin
 Architecture: linux-any
-Depends: ${misc:Depends}, ${shlibs:Depends}, zfs-modules | zfs-dkms, zfsutils-linux
+Depends: ${misc:Depends}, ${shlibs:Depends}, zfsutils-linux
 Description: OpenZFS Event Daemon
  The Z file system is a pooled filesystem designed for maximum data
  integrity, supporting data snapshots, multiple copies, and data
diff --git a/debian/control b/debian/control
index 76907e45..3bcb9a96 100644
--- a/debian/control
+++ b/debian/control
@@ -9,7 +9,6 @@ Build-Depends: dh-autoreconf,
                dh-systemd,
                autotools-dev,
                debhelper (>= 9),
-               dkms (>> 2.1.1.2-5),
                libselinux1-dev,
                libtool,
                lsb-release,
diff --git a/debian/rules b/debian/rules
index 9efbace6..49da7067 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,9 +5,6 @@ NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
 VERSION := $(shell dpkg-parsechangelog \
   | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
 
-DKMSFILES := module include config zfs.release.in autogen.sh META AUTHORS \
-		DISCLAIMER COPYRIGHT OPENSOLARIS.LICENSE README.markdown
-
 ifndef BUILD_UDEB
 BUILD_UDEB=false
 endif
@@ -21,21 +18,16 @@ KVERS=$(shell uname -r)
 endif
 
 ifndef SPL
-SPL=/usr/src/spl-$(VERSION)
-endif
-
-ifndef SPLOBJ
-SPLOBJ=/var/lib/dkms/spl/$(VERSION)/$(KVERS)/$(shell dpkg-architecture -qDEB_TARGET_GNU_CPU)
+SPL=../pkg-spl
 endif
 
 non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
 PACKAGE=zfs
-pmodules = $(PACKAGE)-modules-$(non_epoch_version)
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 %:
-	dh $@ --with autoreconf,dkms,python3,systemd --parallel
+	dh $@ --with autoreconf,python3,systemd --parallel
 
 override_dh_auto_configure:
 	@cp debian/control.in debian/control
@@ -77,36 +69,6 @@ override_dh_auto_install:
 	$(INSTALL) -d '$(CURDIR)/debian/tmp/usr/sbin/'
 	mv '$(CURDIR)/debian/tmp/sbin/zed' '$(CURDIR)/debian/tmp/usr/sbin/zed'
 
-	@# Get a bare copy of the source code for DKMS.
-	@# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree, which does not
-	@# contain the userland sources. NB: Remove-userland-dist-rules.patch
-	$(MAKE) distdir
-
-	@# Install the DKMS source.
-	@# We only want the files needed to build the modules
-	mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
-	$(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
-	@# Hellish awk line:
-	@#  * Deletes from configure.ac the parts not needed for building the kernel module
-	@#     * It deletes from inside AC_CONFIG_FILES([]) everything except:
-	@#        (Makefile$|include/|module/|*.release$)
-	@#  * Takes care of spaces and tabs
-	awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \
-		'$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
-	@# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
-	sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \
-		'$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
-	@# Sanity test
-	grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
-	@# Run autogen on the stripped source tree
-	cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
-	rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
-
-	@# This shunt allows DKMS to install the Module.symvers and zfs_config.h
-	@# files to the ${dkms_tree} area through the POST_INSTALL directive.
-	printf '#!/bin/sh\ncp "$$@"\n' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
-	chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
-
 	mkdir -p $(CURDIR)/debian/tmp/usr/lib
 	for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \
 		ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \
@@ -116,9 +78,6 @@ override_dh_auto_install:
 	chmod a-x $(CURDIR)/debian/tmp/etc/zfs/zfs-functions
 	chmod a-x $(CURDIR)/debian/tmp/etc/default/zfs
 
-override_dh_dkms:
-	dh_dkms -V $(VERSION)
-
 override_dh_makeshlibs:
 	dh_makeshlibs -a
 ifeq ($(BUILD_UDEB), true)
@@ -156,65 +115,5 @@ override_dh_install:
 
 # ------------
 
-override_dh_prep-deb-files:
-	for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
-		sed -e 's/##KVERS##/$(KVERS)/g ; s/#KVERS#/$(KVERS)/g ; s/_KVERS_/$(KVERS)/g ; s/##KDREV##/$(KDREV)/g ; s/#KDREV#/$(KDREV)/g ; s/_KDREV_/$(KDREV)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/' \
-		< $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
-	done
-	sed -e 's/##KVERS##/$(KVERS)/g ; s/#KVERS#/$(KVERS)/g ; s/_KVERS_/$(KVERS)/g ; s/##KDREV##/$(KDREV)/g ; s/#KDREV#/$(KDREV)/g ; s/_KDREV_/$(KDREV)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g' \
-	< debian/control.modules.in > debian/control
-
-override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp
-override_dh_configure_modules_udeb_stamp:
-	./configure \
-		--without-selinux \
-		--with-config=kernel \
-		--with-linux=$(KSRC) \
-		--with-linux-obj=$(KOBJ) \
-		--with-spl=$(SPL) \
-		--with-spl-obj=$(SPLOBJ)
-	touch override_dh_configure_modules_udeb_stamp
-
-override_dh_configure_modules: override_dh_configure_modules_stamp
-override_dh_configure_modules_stamp:
-	./configure \
-		--with-config=kernel \
-		--with-linux=$(KSRC) \
-		--with-linux-obj=$(KOBJ) \
-		--with-spl=$(SPL) \
-		--with-spl-obj=$(SPLOBJ)
-	touch override_dh_configure_modules_stamp
-
-override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb
-	dh_testdir
-	dh_testroot
-	dh_prep
-
-	$(MAKE) -C $(CURDIR)/module modules
-
-	dh_installdirs -p${pmodules}-di
-	dh_install -p${pmodules}-di
-	dh_gencontrol -p${pmodules}-di
-
-	dh_builddeb -p${pmodules}-di
-
-override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
-	dh_testdir
-	dh_testroot
-	dh_prep
-
-	$(MAKE) -C $(CURDIR)/module modules
-
-	dh_install -p${pmodules}
-	dh_installdocs -p${pmodules}
-	dh_installchangelogs -p${pmodules}
-	dh_compress -p${pmodules}
-	dh_strip -p${pmodules}
-	dh_fixperms -p${pmodules}
-	dh_installdeb -p${pmodules}
-	dh_gencontrol -p${pmodules}
-	dh_md5sums -p${pmodules}
-	dh_builddeb -p${pmodules}
-
 debian-copyright:
 	cme update dpkg-copyright -file debian/copyright.cme
-- 
2.11.0

