]>
Commit | Line | Data |
---|---|---|
7e4739a2 DH |
1 | #!/usr/bin/make -f |
2 | ||
fb579137 | 3 | LSB_DISTRIBUTOR := $(shell lsb_release -is) |
5cc6dd58 DH |
4 | NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META) |
5 | VERSION := $(shell dpkg-parsechangelog \ | |
6 | | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1) | |
7e4739a2 | 7 | |
66bbd7ad CALP |
8 | DKMSFILES := module include config zfs.release.in autogen.sh META AUTHORS \ |
9 | DISCLAIMER COPYRIGHT OPENSOLARIS.LICENSE README.markdown | |
e6fd8d0f | 10 | |
042e58d4 | 11 | ifndef BUILD_UDEB |
6d1b4acf | 12 | BUILD_UDEB=false |
042e58d4 AX |
13 | endif |
14 | ||
a20a40e3 TF |
15 | ifndef DEB_HOST_ARCH |
16 | DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH) | |
17 | endif | |
18 | ||
9c581c9d AX |
19 | ifndef KVERS |
20 | KVERS=$(shell uname -r) | |
21 | endif | |
22 | ||
c2b155ae TF |
23 | ifndef SPL |
24 | SPL=/usr/src/spl-$(VERSION) | |
25 | endif | |
26 | ||
a81c790e AX |
27 | non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://') |
28 | PACKAGE=zfs | |
7640dd28 | 29 | pmodules = $(PACKAGE)-modules-$(non_epoch_version) |
a81c790e | 30 | |
30f59abc RL |
31 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
32 | ||
505714c7 | 33 | %: |
81441311 | 34 | dh $@ --with autoreconf,dkms,python2,systemd --parallel |
505714c7 | 35 | |
7e4739a2 | 36 | override_dh_auto_configure: |
a81c790e | 37 | @cp debian/control.in debian/control |
042e58d4 AX |
38 | ifeq ($(BUILD_UDEB), true) |
39 | cat debian/control.udeb.in >> debian/control | |
40 | endif | |
a81c790e | 41 | |
5cc6dd58 DH |
42 | @# Embed the downstream version in the module. |
43 | @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META | |
44 | ||
37316e2f | 45 | @# Build the userland, but don't build the kernel modules. |
4b4a7a4c DH |
46 | dh_auto_configure -- \ |
47 | --bindir=/bin \ | |
48 | --sbindir=/sbin \ | |
44bb78ce | 49 | --libdir=/lib \ |
4b4a7a4c | 50 | --with-udevdir=/lib/udev \ |
37316e2f DH |
51 | --with-config=user |
52 | ||
7e4739a2 | 53 | override_dh_auto_test: |
37316e2f | 54 | # The dh_auto_test rule is disabled because |
7e4739a2 DH |
55 | # `make check` cannot run in an unprivileged build environment. |
56 | ||
57 | override_dh_auto_install: | |
37316e2f | 58 | @# Install the utilities. |
661c4a4b | 59 | $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp' |
7e4739a2 | 60 | |
37316e2f DH |
61 | @# Get a bare copy of the source code for DKMS. |
62 | @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree, which does not | |
63 | @# contain the userland sources. NB: Remove-userland-dist-rules.patch | |
661c4a4b | 64 | $(MAKE) distdir |
7e4739a2 | 65 | |
e6fd8d0f CALP |
66 | @# Install the DKMS source. |
67 | @# We only want the files needed to build the modules | |
68 | mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' | |
66bbd7ad | 69 | $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || exit 1;) |
e6fd8d0f CALP |
70 | @# Hellish awk line: |
71 | @# * Deletes from configure.ac the parts not needed for building the kernel module | |
72 | @# * It deletes from inside AC_CONFIG_FILES([]) everything except: | |
66bbd7ad | 73 | @# (Makefile$|include/|module/|*.release$) |
e6fd8d0f | 74 | @# * Takes care of spaces and tabs |
66bbd7ad | 75 | awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \ |
e6fd8d0f | 76 | '$(CURDIR)/$(NAME)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/configure.ac' |
66bbd7ad CALP |
77 | @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs. |
78 | sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \ | |
79 | '$(CURDIR)/$(NAME)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am' | |
80 | @# Sanity test | |
81 | grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am' | |
82 | @# Run autogen on the stripped source tree | |
e6fd8d0f CALP |
83 | cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh |
84 | rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/autom4te.cache' | |
85 | ||
37316e2f DH |
86 | @# This shunt allows DKMS to install the Module.symvers and zfs_config.h |
87 | @# files to the ${dkms_tree} area through the POST_INSTALL directive. | |
ea1ac941 | 88 | printf '#!/bin/sh\ncp "$$@"\n' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' |
e6fd8d0f | 89 | chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/cp' |
7e4739a2 | 90 | |
a0d08c54 | 91 | mkdir -p $(CURDIR)/debian/tmp/usr/lib |
3f2148a9 AX |
92 | for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \ |
93 | ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \ | |
94 | rm $${i}; \ | |
95 | done | |
96 | ||
97487d06 AX |
97 | chmod -x $(CURDIR)/debian/tmp/etc/zfs/zfs-functions |
98 | chmod -x $(CURDIR)/debian/tmp/etc/default/zfs | |
99 | ||
505714c7 CALP |
100 | override_dh_dkms: |
101 | dh_dkms -V $(VERSION) | |
102 | ||
a81c790e AX |
103 | override_dh_makeshlibs: |
104 | dh_makeshlibs -a | |
042e58d4 | 105 | ifeq ($(BUILD_UDEB), true) |
0b24fb47 AX |
106 | dh_makeshlibs -plibnvpair1linux --add-udeb=libnvpair1-udeb |
107 | dh_makeshlibs -plibuutil1linux --add-udeb=libuutil1-udeb | |
108 | dh_makeshlibs -plibzfs2linux --add-udeb=libzfs2-udeb | |
109 | dh_makeshlibs -plibzpool2linux --add-udeb=libzpool2-udeb | |
3dce9963 | 110 | dh_makeshlibs -pzfsutils-linux --add-udeb=zfsutils-udeb |
0aa4ec8e | 111 | endif |
a81c790e | 112 | |
47ba6fdb | 113 | override_dh_strip: |
4365121d | 114 | dh_strip --dbg-package=zfs-dbg |
042e58d4 | 115 | ifeq ($(BUILD_UDEB), true) |
0b24fb47 AX |
116 | dh_strip -plibnvpair1-udeb |
117 | dh_strip -plibuutil1-udeb | |
118 | dh_strip -plibzfs2-udeb | |
119 | dh_strip -plibzpool2-udeb | |
a81c790e | 120 | dh_strip -pzfsutils-udeb |
042e58d4 | 121 | endif |
a81c790e | 122 | |
5cc6dd58 DH |
123 | override_dh_auto_clean: |
124 | dh_auto_clean | |
4c8f5221 | 125 | debconf-updatepo |
5cc6dd58 | 126 | @if test -e META.orig; then mv META.orig META; fi |
98675f09 | 127 | cp debian/control.in debian/control |
042e58d4 AX |
128 | ifeq ($(BUILD_UDEB), true) |
129 | cat debian/control.udeb.in >> debian/control | |
130 | endif | |
5cc6dd58 | 131 | |
9d521a01 AX |
132 | override_dh_install: |
133 | find . -name lib*.la -delete | |
2097931f | 134 | dh_install --list-missing |
a81c790e AX |
135 | |
136 | # ------------ | |
137 | ||
138 | override_dh_prep-deb-files: | |
139 | for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \ | |
a20a40e3 TF |
140 | 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)/' \ |
141 | < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \ | |
a81c790e | 142 | done |
a20a40e3 | 143 | 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' \ |
a81c790e AX |
144 | < debian/control.modules.in > debian/control |
145 | ||
6766f188 AX |
146 | override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp |
147 | override_dh_configure_modules_udeb_stamp: | |
148 | ./configure \ | |
149 | --without-selinux \ | |
150 | --with-config=kernel \ | |
151 | --with-linux=$(KSRC) \ | |
c2b155ae TF |
152 | --with-linux-obj=$(KOBJ) \ |
153 | --with-spl=$(SPL) | |
6766f188 AX |
154 | touch override_dh_configure_modules_udeb_stamp |
155 | ||
a81c790e AX |
156 | override_dh_configure_modules: override_dh_configure_modules_stamp |
157 | override_dh_configure_modules_stamp: | |
6766f188 AX |
158 | ./configure \ |
159 | --with-config=kernel \ | |
160 | --with-linux=$(KSRC) \ | |
c2b155ae TF |
161 | --with-linux-obj=$(KOBJ) \ |
162 | --with-spl=$(SPL) | |
a81c790e AX |
163 | touch override_dh_configure_modules_stamp |
164 | ||
6766f188 | 165 | override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb |
a81c790e AX |
166 | dh_testdir |
167 | dh_testroot | |
1dd633c6 | 168 | dh_prep |
a81c790e AX |
169 | |
170 | $(MAKE) -C $(CURDIR)/module modules | |
171 | ||
a20a40e3 TF |
172 | dh_installdirs -p${pmodules}-di |
173 | dh_install -p${pmodules}-di | |
174 | dh_gencontrol -p${pmodules}-di | |
a81c790e | 175 | |
959e5456 | 176 | dh_builddeb -p${pmodules}-di |
a81c790e AX |
177 | |
178 | override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules | |
179 | dh_testdir | |
180 | dh_testroot | |
1dd633c6 | 181 | dh_prep |
a81c790e AX |
182 | |
183 | $(MAKE) -C $(CURDIR)/module modules | |
184 | ||
185 | dh_install -p${pmodules} | |
186 | dh_installdocs -p${pmodules} | |
187 | dh_installchangelogs -p${pmodules} | |
188 | dh_compress -p${pmodules} | |
189 | dh_strip -p${pmodules} | |
190 | dh_fixperms -p${pmodules} | |
191 | dh_installdeb -p${pmodules} | |
a878da18 | 192 | dh_gencontrol -p${pmodules} |
a81c790e | 193 | dh_md5sums -p${pmodules} |
959e5456 | 194 | dh_builddeb -p${pmodules} |