]>
Commit | Line | Data |
---|---|---|
7e4739a2 DH |
1 | #!/usr/bin/make -f |
2 | ||
63758230 FG |
3 | include /usr/share/dpkg/default.mk |
4 | ||
fb579137 | 5 | LSB_DISTRIBUTOR := $(shell lsb_release -is) |
5cc6dd58 | 6 | NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META) |
c8746aa8 | 7 | LINUX_NEXT := $(shell awk -F. '{print $$1 "." $$2+1}' debian/linux_compat) |
7e4739a2 | 8 | |
66bbd7ad CALP |
9 | DKMSFILES := module include config zfs.release.in autogen.sh META AUTHORS \ |
10 | DISCLAIMER COPYRIGHT OPENSOLARIS.LICENSE README.markdown | |
e6fd8d0f | 11 | |
042e58d4 | 12 | ifndef BUILD_UDEB |
6d1b4acf | 13 | BUILD_UDEB=false |
042e58d4 AX |
14 | endif |
15 | ||
9c581c9d AX |
16 | ifndef KVERS |
17 | KVERS=$(shell uname -r) | |
18 | endif | |
19 | ||
c2b155ae | 20 | ifndef SPL |
f40b765d | 21 | SPL=/usr/src/spl-$(DEB_VERSION_UPSTREAM) |
c2b155ae TF |
22 | endif |
23 | ||
8aa69748 | 24 | ifndef SPLOBJ |
5bb90f43 | 25 | SPLOBJ=/var/lib/dkms/spl/$(DEB_VERSION_UPSTREAM)/$(KVERS)/$(DEB_TARGET_GNU_CPU) |
8aa69748 AX |
26 | endif |
27 | ||
a81c790e AX |
28 | non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://') |
29 | PACKAGE=zfs | |
7640dd28 | 30 | pmodules = $(PACKAGE)-modules-$(non_epoch_version) |
a81c790e | 31 | |
30f59abc RL |
32 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
33 | ||
505714c7 | 34 | %: |
a52a9356 | 35 | dh $@ --with autoreconf,dkms,python3,systemd --parallel |
505714c7 | 36 | |
fd8339ac AR |
37 | override_dh_autoreconf: |
38 | @# Embed the downstream version in the module. | |
39 | @sed -e 's/^Version:.*/Version: $(DEB_VERSION_UPSTREAM)/' -i.orig META | |
40 | ||
41 | dh_autoreconf | |
42 | ||
7e4739a2 | 43 | override_dh_auto_configure: |
0f73afe2 | 44 | sed "s/@LINUX_COMPAT@/linux-libc-dev \(<< $(LINUX_NEXT)~\)/" debian/control.in > debian/control |
042e58d4 AX |
45 | ifeq ($(BUILD_UDEB), true) |
46 | cat debian/control.udeb.in >> debian/control | |
47 | endif | |
a81c790e | 48 | |
37316e2f | 49 | @# Build the userland, but don't build the kernel modules. |
4b4a7a4c | 50 | dh_auto_configure -- \ |
5a7b0cb7 | 51 | --bindir=/usr/bin \ |
4b4a7a4c | 52 | --sbindir=/sbin \ |
44bb78ce | 53 | --libdir=/lib \ |
4b4a7a4c | 54 | --with-udevdir=/lib/udev \ |
7c847cb1 | 55 | --enable-systemd \ |
58907cc6 LW |
56 | --with-systemdunitdir=/lib/systemd/system \ |
57 | --with-systemdpresetdir=/lib/systemd/system-preset \ | |
37316e2f DH |
58 | --with-config=user |
59 | ||
fb0b8605 AR |
60 | override_dh_auto_build: |
61 | @# Get a bare copy of the source code for DKMS. | |
62 | @# This creates the $(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/ tree, which does not | |
63 | @# contain the userland sources. NB: Remove-userland-dist-rules.patch | |
64 | $(MAKE) distdir | |
65 | ||
66 | dh_auto_build | |
67 | ||
7e4739a2 | 68 | override_dh_auto_test: |
37316e2f | 69 | # The dh_auto_test rule is disabled because |
7e4739a2 DH |
70 | # `make check` cannot run in an unprivileged build environment. |
71 | ||
72 | override_dh_auto_install: | |
37316e2f | 73 | @# Install the utilities. |
661c4a4b | 74 | $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp' |
7e4739a2 | 75 | |
b981c8a4 AR |
76 | # Use upstream's bash completion |
77 | install -D -t '$(CURDIR)/debian/tmp/usr/share/bash-completion/completions/' \ | |
78 | '$(CURDIR)/contrib/bash_completion.d/zfs' | |
e1c956cc | 79 | |
5a7b0cb7 | 80 | # Move from bin_dir to /usr/sbin |
e1c956cc RL |
81 | # Remove suffix (.py) as per policy 10.4 - Scripts |
82 | # https://www.debian.org/doc/debian-policy/ch-files.html#s-scripts | |
5a7b0cb7 FG |
83 | mkdir -p '$(CURDIR)/debian/tmp/usr/sbin/' |
84 | mv '$(CURDIR)/debian/tmp/usr/bin/arc_summary.py' '$(CURDIR)/debian/tmp/usr/sbin/arc_summary' | |
85 | mv '$(CURDIR)/debian/tmp/usr/bin/arcstat.py' '$(CURDIR)/debian/tmp/usr/sbin/arcstat' | |
86 | mv '$(CURDIR)/debian/tmp/usr/bin/dbufstat.py' '$(CURDIR)/debian/tmp/usr/sbin/dbufstat' | |
e1c956cc | 87 | |
a9e73526 | 88 | @# Zed has dependencies outside of the system root. |
a9e73526 AX |
89 | mv '$(CURDIR)/debian/tmp/sbin/zed' '$(CURDIR)/debian/tmp/usr/sbin/zed' |
90 | ||
e6fd8d0f CALP |
91 | @# Install the DKMS source. |
92 | @# We only want the files needed to build the modules | |
200661e3 | 93 | install -D -t '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/scripts' \ |
effbedcd AR |
94 | '$(CURDIR)/scripts/enum-extract.pl' \ |
95 | '$(CURDIR)/scripts/dkms.postbuild' | |
f40b765d | 96 | $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' || exit 1;) |
e6fd8d0f CALP |
97 | @# Hellish awk line: |
98 | @# * Deletes from configure.ac the parts not needed for building the kernel module | |
99 | @# * It deletes from inside AC_CONFIG_FILES([]) everything except: | |
66bbd7ad | 100 | @# (Makefile$|include/|module/|*.release$) |
e6fd8d0f | 101 | @# * Takes care of spaces and tabs |
4cbaa787 | 102 | @# * Remove reference to ZFS_AC_PACKAGE |
66bbd7ad | 103 | awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \ |
4cbaa787 | 104 | '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac' | sed '/ZFS_AC_PACKAGE/d' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac' |
66bbd7ad CALP |
105 | @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs. |
106 | sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \ | |
f40b765d | 107 | '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' |
66bbd7ad | 108 | @# Sanity test |
f40b765d | 109 | grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' |
66bbd7ad | 110 | @# Run autogen on the stripped source tree |
f40b765d FG |
111 | cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)'; ./autogen.sh |
112 | rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/autom4te.cache' | |
e6fd8d0f | 113 | |
a0d08c54 | 114 | mkdir -p $(CURDIR)/debian/tmp/usr/lib |
3f2148a9 AX |
115 | for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \ |
116 | ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \ | |
117 | rm $${i}; \ | |
118 | done | |
119 | ||
200661e3 AR |
120 | chmod a-x '$(CURDIR)/debian/tmp/etc/zfs/zfs-functions' |
121 | chmod a-x '$(CURDIR)/debian/tmp/etc/default/zfs' | |
b981c8a4 | 122 | chmod a-x '$(CURDIR)/debian/tmp/usr/share/bash-completion/completions/zfs' |
97487d06 | 123 | |
505714c7 | 124 | override_dh_dkms: |
effbedcd AR |
125 | '$(CURDIR)/scripts/dkms.mkconf' -n $(NAME) -v $(DEB_VERSION_UPSTREAM) -f '$(CURDIR)/scripts/zfs-dkms.dkms' |
126 | dh_dkms | |
127 | rm -f '$(CURDIR)/scripts/zfs-dkms.dkms' | |
505714c7 | 128 | |
a81c790e | 129 | override_dh_makeshlibs: |
40788335 | 130 | dh_makeshlibs -a -V |
042e58d4 | 131 | ifeq ($(BUILD_UDEB), true) |
40788335 FG |
132 | dh_makeshlibs -V -plibnvpair1linux --add-udeb=libnvpair1-udeb |
133 | dh_makeshlibs -V -plibuutil1linux --add-udeb=libuutil1-udeb | |
134 | dh_makeshlibs -V -plibzfs2linux --add-udeb=libzfs2-udeb | |
135 | dh_makeshlibs -V -plibzpool2linux --add-udeb=libzpool2-udeb | |
136 | dh_makeshlibs -V -pzfsutils-linux --add-udeb=zfsutils-udeb | |
0aa4ec8e | 137 | endif |
a81c790e | 138 | |
47ba6fdb | 139 | override_dh_strip: |
4365121d | 140 | dh_strip --dbg-package=zfs-dbg |
042e58d4 | 141 | ifeq ($(BUILD_UDEB), true) |
0b24fb47 AX |
142 | dh_strip -plibnvpair1-udeb |
143 | dh_strip -plibuutil1-udeb | |
144 | dh_strip -plibzfs2-udeb | |
145 | dh_strip -plibzpool2-udeb | |
a81c790e | 146 | dh_strip -pzfsutils-udeb |
042e58d4 | 147 | endif |
a81c790e | 148 | |
5cc6dd58 | 149 | override_dh_auto_clean: |
b3671465 | 150 | find . -name .gitignore -delete |
f40b765d | 151 | rm -rf zfs-$(DEB_VERSION_UPSTREAM) |
5cc6dd58 | 152 | dh_auto_clean |
4c8f5221 | 153 | debconf-updatepo |
5cc6dd58 | 154 | @if test -e META.orig; then mv META.orig META; fi |
0f73afe2 | 155 | sed "s/@LINUX_COMPAT@/linux-libc-dev \(<< $(LINUX_NEXT)~\)/" debian/control.in > debian/control |
042e58d4 AX |
156 | ifeq ($(BUILD_UDEB), true) |
157 | cat debian/control.udeb.in >> debian/control | |
158 | endif | |
5cc6dd58 | 159 | |
9d521a01 AX |
160 | override_dh_install: |
161 | find . -name lib*.la -delete | |
7e332a4c | 162 | dh_install --fail-missing |
a81c790e | 163 | |
2ad6c7f9 MZ |
164 | override_dh_installinit: |
165 | dh_installinit -r --no-start --name zfs-import | |
166 | dh_installinit -r --no-start --name zfs-mount | |
167 | dh_installinit -r --no-start --name zfs-share | |
ff547c29 | 168 | dh_installinit -R --no-start --name zfs-zed |
1c343483 MZ |
169 | mkdir -p debian/zfsutils-linux/lib/systemd/system |
170 | ln -sr /dev/null debian/zfsutils-linux/lib/systemd/system/zfs-import.service | |
2ad6c7f9 | 171 | |
a81c790e AX |
172 | # ------------ |
173 | ||
174 | override_dh_prep-deb-files: | |
175 | for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \ | |
a20a40e3 TF |
176 | 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)/' \ |
177 | < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \ | |
a81c790e | 178 | done |
a20a40e3 | 179 | 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 |
180 | < debian/control.modules.in > debian/control |
181 | ||
6766f188 AX |
182 | override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp |
183 | override_dh_configure_modules_udeb_stamp: | |
184 | ./configure \ | |
185 | --without-selinux \ | |
186 | --with-config=kernel \ | |
187 | --with-linux=$(KSRC) \ | |
c2b155ae | 188 | --with-linux-obj=$(KOBJ) \ |
8aa69748 AX |
189 | --with-spl=$(SPL) \ |
190 | --with-spl-obj=$(SPLOBJ) | |
6766f188 AX |
191 | touch override_dh_configure_modules_udeb_stamp |
192 | ||
a81c790e AX |
193 | override_dh_configure_modules: override_dh_configure_modules_stamp |
194 | override_dh_configure_modules_stamp: | |
6766f188 AX |
195 | ./configure \ |
196 | --with-config=kernel \ | |
197 | --with-linux=$(KSRC) \ | |
c2b155ae | 198 | --with-linux-obj=$(KOBJ) \ |
8aa69748 AX |
199 | --with-spl=$(SPL) \ |
200 | --with-spl-obj=$(SPLOBJ) | |
a81c790e AX |
201 | touch override_dh_configure_modules_stamp |
202 | ||
6766f188 | 203 | override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb |
a81c790e AX |
204 | dh_testdir |
205 | dh_testroot | |
1dd633c6 | 206 | dh_prep |
a81c790e AX |
207 | |
208 | $(MAKE) -C $(CURDIR)/module modules | |
209 | ||
a20a40e3 TF |
210 | dh_installdirs -p${pmodules}-di |
211 | dh_install -p${pmodules}-di | |
212 | dh_gencontrol -p${pmodules}-di | |
a81c790e | 213 | |
959e5456 | 214 | dh_builddeb -p${pmodules}-di |
a81c790e AX |
215 | |
216 | override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules | |
217 | dh_testdir | |
218 | dh_testroot | |
1dd633c6 | 219 | dh_prep |
a81c790e AX |
220 | |
221 | $(MAKE) -C $(CURDIR)/module modules | |
222 | ||
223 | dh_install -p${pmodules} | |
224 | dh_installdocs -p${pmodules} | |
225 | dh_installchangelogs -p${pmodules} | |
226 | dh_compress -p${pmodules} | |
227 | dh_strip -p${pmodules} | |
228 | dh_fixperms -p${pmodules} | |
229 | dh_installdeb -p${pmodules} | |
a878da18 | 230 | dh_gencontrol -p${pmodules} |
a81c790e | 231 | dh_md5sums -p${pmodules} |
959e5456 | 232 | dh_builddeb -p${pmodules} |
0fc76429 PR |
233 | |
234 | debian-copyright: | |
235 | cme update dpkg-copyright -file debian/copyright.cme |