]> git.proxmox.com Git - mirror_spl-debian.git/blob - debian/rules
Restore control file on clean
[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 spl.release.in autogen.sh \
8 META AUTHORS DISCLAIMER
9
10 ifndef DEB_HOST_ARCH
11 DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
12 endif
13
14 non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
15 PACKAGE=spl
16 pmodules = $(PACKAGE)-modules-$(non_epoch_version)-$(DEB_HOST_ARCH)
17
18 %:
19 dh $@ --with dkms
20
21 override_dh_auto_configure:
22 @cp debian/control.in debian/control
23
24 @# Embed the downstream version in the module.
25 @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META
26
27 @# Create the makefiles and configure script.
28 ./autogen.sh
29
30 @# Build the userland, but don't build the kernel modules.
31 ./configure --prefix=/usr --with-config=user
32
33 override_dh_auto_test:
34 # scripts/check.sh tries insmod and rmmod, so it cannot
35 # run in an unprivileged build environment.
36
37 override_dh_auto_install:
38 @# Install the utilities.
39 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
40
41 @# Get a bare copy of the source code.
42 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree.
43 $(MAKE) distdir
44
45 # Install the DKMS source.
46 @# We only want the files needed to build the modules
47 mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
48 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;)
49 @# Hellish awk line:
50 @# * Deletes from configure.ac the parts not needed for building the kernel module
51 @# * It deletes from inside AC_CONFIG_FILES([]) everything except:
52 @# (Makefile$|include/|module/|*.release$)
53 @# * Takes care of spaces and tabs
54 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|spl\.release([ \t]+)?$$))/){next} } {print}' \
55 '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac'
56 @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
57 sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \
58 '$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
59 @# Sanity test
60 grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
61 @# Run autogen on the stripped source tree
62 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
63 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache'
64
65 @# This shunt allows DKMS to install the Module.symvers and spl_config.h
66 @# files to the ${dkms_tree} area through the POST_INSTALL directive.
67 echo '#!/bin/sh' >'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
68 echo 'cp "$$@"' >>'$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
69 chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp'
70
71 override_dh_dkms:
72 dh_dkms -V $(VERSION)
73
74 override_dh_auto_clean:
75 dh_auto_clean
76 @if test -e META.orig; then mv META.orig META; fi
77 cp debian/control.in debian/control
78
79 # ------------
80
81 override_dh_prep-deb-files:
82 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
83 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' \
84 < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
85 done
86 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' \
87 < debian/control.modules.in > debian/control
88
89 override_dh_configure_modules: override_dh_configure_modules_stamp
90 override_dh_configure_modules_stamp:
91 ./configure --with-config=kernel --with-linux=$(KSRC) \
92 --with-linux-obj=$(KOBJ)
93 touch override_dh_configure_modules_stamp
94
95 override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules
96 dh_testdir
97 dh_testroot
98 dh_prep
99
100 $(MAKE) -C $(CURDIR)/module modules
101
102 dh_installdirs -p${pmodules}-di
103 dh_install -p${pmodules}-di
104 dh_gencontrol -p${pmodules}-di
105
106 dh_builddeb -p${pmodules}-di --destdir=$(DEB_DESTDIR)
107
108 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
109 dh_testdir
110 dh_testroot
111 dh_prep
112
113 $(MAKE) -C $(CURDIR)/module modules
114
115 dh_installdocs -p${pmodules}
116 dh_install -p${pmodules}
117 dh_installchangelogs -p${pmodules}
118 dh_compress -p${pmodules}
119 dh_strip -p${pmodules}
120 dh_fixperms -p${pmodules}
121 dh_installdeb -p${pmodules}
122 dh_gencontrol -p${pmodules} -- -v$(VERSION)
123 dh_md5sums -p${pmodules}
124
125 dh_builddeb -p${pmodules} --destdir=$(DEB_DESTDIR)