]> git.proxmox.com Git - mirror_spl-debian.git/blob - debian/rules
Explicity select what is copied inside the DKMS source tree
[mirror_spl-debian.git] / debian / rules
1 #!/usr/bin/make -f
2
3 NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
4 VERSION := $(shell dpkg-parsechangelog \
5 | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
6
7 DKMSFILES := module include config Makefile.in autogen.sh dkms.conf.in \
8 spl.release.in META spl_config.h AUTHORS DISCLAIMER
9
10 %:
11 dh $@ --with dkms
12
13 override_dh_auto_configure:
14 @# Embed the downstream version in the module.
15 @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META
16
17 @# Create the makefiles and configure script.
18 ./autogen.sh
19
20 @# Build the userland, but don't build the kernel modules.
21 ./configure --prefix=/usr --with-config=user
22
23 override_dh_auto_test:
24 # scripts/check.sh tries insmod and rmmod, so it cannot
25 # run in an unprivileged build environment.
26
27 override_dh_auto_install:
28 @# Install the utilities.
29 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
30
31 @# Create a dummy hostid file for the zfs-initramfs package.
32 @# NB: Commentary in the spl.postinst script.
33 mkdir -p '$(CURDIR)/debian/tmp/etc/'
34 /usr/bin/printf '\xFF\xFF\xFF\xFF' >'$(CURDIR)/debian/tmp/etc/hostid'
35
36 @# Get a bare copy of the source code.
37 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree.
38 $(MAKE) distdir
39
40 # Install the DKMS source.
41 @# We only want the files needed to build the modules
42 mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
43 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)';)
44 @# Hellish awk line:
45 @# * Deletes from configure.ac the parts not needed for building the kernel module
46 @# * It deletes from inside AC_CONFIG_FILES([]) everything except:
47 @# (Makefile$|include/|module/|*.release$|dkms.conf$)
48 @# * Takes care of spaces and tabs
49 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|spl\.release([ \t]+)?$$|dkms\.conf([ \t]+)?$$))/){next} } {print}' \
50 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
51 cp '$(CURDIR)/autogen.sh' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
52 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
53 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
54
55 @# This shunt allows DKMS to install the Module.symvers and spl_config.h
56 @# files to the ${dkms_tree} area through the POST_INSTALL directive.
57 echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
58 echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
59 chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
60
61 override_dh_dkms:
62 dh_dkms -V $(VERSION)
63
64 override_dh_auto_clean:
65 dh_auto_clean
66 @if test -e META.orig; then mv META.orig META; fi