]>
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) |
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 | ||
9c581c9d AX |
15 | ifndef KVERS |
16 | KVERS=$(shell uname -r) | |
17 | endif | |
18 | ||
c2b155ae | 19 | ifndef SPL |
f40b765d | 20 | SPL=/usr/src/spl-$(DEB_VERSION_UPSTREAM) |
c2b155ae TF |
21 | endif |
22 | ||
8aa69748 | 23 | ifndef SPLOBJ |
5bb90f43 | 24 | SPLOBJ=/var/lib/dkms/spl/$(DEB_VERSION_UPSTREAM)/$(KVERS)/$(DEB_TARGET_GNU_CPU) |
8aa69748 AX |
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 | %: |
a52a9356 | 34 | dh $@ --with autoreconf,dkms,python3,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 | 42 | @# Embed the downstream version in the module. |
f40b765d | 43 | @sed -e 's/^Version:.*/Version: $(DEB_VERSION_UPSTREAM)/' -i.orig META |
5cc6dd58 | 44 | |
37316e2f | 45 | @# Build the userland, but don't build the kernel modules. |
4b4a7a4c | 46 | dh_auto_configure -- \ |
5a7b0cb7 | 47 | --bindir=/usr/bin \ |
4b4a7a4c | 48 | --sbindir=/sbin \ |
44bb78ce | 49 | --libdir=/lib \ |
4b4a7a4c | 50 | --with-udevdir=/lib/udev \ |
58907cc6 LW |
51 | --with-systemdunitdir=/lib/systemd/system \ |
52 | --with-systemdpresetdir=/lib/systemd/system-preset \ | |
37316e2f DH |
53 | --with-config=user |
54 | ||
7e4739a2 | 55 | override_dh_auto_test: |
37316e2f | 56 | # The dh_auto_test rule is disabled because |
7e4739a2 DH |
57 | # `make check` cannot run in an unprivileged build environment. |
58 | ||
59 | override_dh_auto_install: | |
37316e2f | 60 | @# Install the utilities. |
661c4a4b | 61 | $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp' |
7e4739a2 | 62 | |
e1c956cc | 63 | |
5a7b0cb7 | 64 | # Move from bin_dir to /usr/sbin |
e1c956cc RL |
65 | # Remove suffix (.py) as per policy 10.4 - Scripts |
66 | # https://www.debian.org/doc/debian-policy/ch-files.html#s-scripts | |
5a7b0cb7 FG |
67 | mkdir -p '$(CURDIR)/debian/tmp/usr/sbin/' |
68 | mv '$(CURDIR)/debian/tmp/usr/bin/arc_summary.py' '$(CURDIR)/debian/tmp/usr/sbin/arc_summary' | |
69 | mv '$(CURDIR)/debian/tmp/usr/bin/arcstat.py' '$(CURDIR)/debian/tmp/usr/sbin/arcstat' | |
70 | mv '$(CURDIR)/debian/tmp/usr/bin/dbufstat.py' '$(CURDIR)/debian/tmp/usr/sbin/dbufstat' | |
e1c956cc | 71 | |
a9e73526 AX |
72 | @# Zed has dependencies outside of the system root. |
73 | $(INSTALL) -d '$(CURDIR)/debian/tmp/usr/sbin/' | |
74 | mv '$(CURDIR)/debian/tmp/sbin/zed' '$(CURDIR)/debian/tmp/usr/sbin/zed' | |
75 | ||
37316e2f | 76 | @# Get a bare copy of the source code for DKMS. |
f40b765d | 77 | @# This creates the $(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/ tree, which does not |
37316e2f | 78 | @# contain the userland sources. NB: Remove-userland-dist-rules.patch |
661c4a4b | 79 | $(MAKE) distdir |
7e4739a2 | 80 | |
e6fd8d0f CALP |
81 | @# Install the DKMS source. |
82 | @# We only want the files needed to build the modules | |
f40b765d FG |
83 | mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' |
84 | $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' || exit 1;) | |
e6fd8d0f CALP |
85 | @# Hellish awk line: |
86 | @# * Deletes from configure.ac the parts not needed for building the kernel module | |
87 | @# * It deletes from inside AC_CONFIG_FILES([]) everything except: | |
66bbd7ad | 88 | @# (Makefile$|include/|module/|*.release$) |
e6fd8d0f | 89 | @# * Takes care of spaces and tabs |
66bbd7ad | 90 | awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \ |
f40b765d | 91 | '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac' |
66bbd7ad CALP |
92 | @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs. |
93 | sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \ | |
f40b765d | 94 | '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' |
66bbd7ad | 95 | @# Sanity test |
f40b765d | 96 | grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' |
66bbd7ad | 97 | @# Run autogen on the stripped source tree |
f40b765d FG |
98 | cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)'; ./autogen.sh |
99 | rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/autom4te.cache' | |
e6fd8d0f | 100 | |
37316e2f DH |
101 | @# This shunt allows DKMS to install the Module.symvers and zfs_config.h |
102 | @# files to the ${dkms_tree} area through the POST_INSTALL directive. | |
f40b765d FG |
103 | printf '#!/bin/sh\ncp "$$@"\n' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/cp' |
104 | chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/cp' | |
7e4739a2 | 105 | |
a0d08c54 | 106 | mkdir -p $(CURDIR)/debian/tmp/usr/lib |
3f2148a9 AX |
107 | for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \ |
108 | ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \ | |
109 | rm $${i}; \ | |
110 | done | |
111 | ||
84dc3e04 LW |
112 | chmod a-x $(CURDIR)/debian/tmp/etc/zfs/zfs-functions |
113 | chmod a-x $(CURDIR)/debian/tmp/etc/default/zfs | |
97487d06 | 114 | |
505714c7 | 115 | override_dh_dkms: |
f40b765d | 116 | dh_dkms -V $(DEB_VERSION_UPSTREAM) |
505714c7 | 117 | |
a81c790e AX |
118 | override_dh_makeshlibs: |
119 | dh_makeshlibs -a | |
042e58d4 | 120 | ifeq ($(BUILD_UDEB), true) |
0b24fb47 AX |
121 | dh_makeshlibs -plibnvpair1linux --add-udeb=libnvpair1-udeb |
122 | dh_makeshlibs -plibuutil1linux --add-udeb=libuutil1-udeb | |
123 | dh_makeshlibs -plibzfs2linux --add-udeb=libzfs2-udeb | |
124 | dh_makeshlibs -plibzpool2linux --add-udeb=libzpool2-udeb | |
3dce9963 | 125 | dh_makeshlibs -pzfsutils-linux --add-udeb=zfsutils-udeb |
0aa4ec8e | 126 | endif |
a81c790e | 127 | |
47ba6fdb | 128 | override_dh_strip: |
4365121d | 129 | dh_strip --dbg-package=zfs-dbg |
042e58d4 | 130 | ifeq ($(BUILD_UDEB), true) |
0b24fb47 AX |
131 | dh_strip -plibnvpair1-udeb |
132 | dh_strip -plibuutil1-udeb | |
133 | dh_strip -plibzfs2-udeb | |
134 | dh_strip -plibzpool2-udeb | |
a81c790e | 135 | dh_strip -pzfsutils-udeb |
042e58d4 | 136 | endif |
a81c790e | 137 | |
5cc6dd58 | 138 | override_dh_auto_clean: |
b3671465 | 139 | find . -name .gitignore -delete |
f40b765d | 140 | rm -rf zfs-$(DEB_VERSION_UPSTREAM) |
5cc6dd58 | 141 | dh_auto_clean |
4c8f5221 | 142 | debconf-updatepo |
5cc6dd58 | 143 | @if test -e META.orig; then mv META.orig META; fi |
98675f09 | 144 | cp debian/control.in debian/control |
042e58d4 AX |
145 | ifeq ($(BUILD_UDEB), true) |
146 | cat debian/control.udeb.in >> debian/control | |
147 | endif | |
5cc6dd58 | 148 | |
9d521a01 AX |
149 | override_dh_install: |
150 | find . -name lib*.la -delete | |
7e332a4c | 151 | dh_install --fail-missing |
a81c790e AX |
152 | |
153 | # ------------ | |
154 | ||
155 | override_dh_prep-deb-files: | |
156 | for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \ | |
a20a40e3 TF |
157 | 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)/' \ |
158 | < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \ | |
a81c790e | 159 | done |
a20a40e3 | 160 | 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 |
161 | < debian/control.modules.in > debian/control |
162 | ||
6766f188 AX |
163 | override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp |
164 | override_dh_configure_modules_udeb_stamp: | |
165 | ./configure \ | |
166 | --without-selinux \ | |
167 | --with-config=kernel \ | |
168 | --with-linux=$(KSRC) \ | |
c2b155ae | 169 | --with-linux-obj=$(KOBJ) \ |
8aa69748 AX |
170 | --with-spl=$(SPL) \ |
171 | --with-spl-obj=$(SPLOBJ) | |
6766f188 AX |
172 | touch override_dh_configure_modules_udeb_stamp |
173 | ||
a81c790e AX |
174 | override_dh_configure_modules: override_dh_configure_modules_stamp |
175 | override_dh_configure_modules_stamp: | |
6766f188 AX |
176 | ./configure \ |
177 | --with-config=kernel \ | |
178 | --with-linux=$(KSRC) \ | |
c2b155ae | 179 | --with-linux-obj=$(KOBJ) \ |
8aa69748 AX |
180 | --with-spl=$(SPL) \ |
181 | --with-spl-obj=$(SPLOBJ) | |
a81c790e AX |
182 | touch override_dh_configure_modules_stamp |
183 | ||
6766f188 | 184 | override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb |
a81c790e AX |
185 | dh_testdir |
186 | dh_testroot | |
1dd633c6 | 187 | dh_prep |
a81c790e AX |
188 | |
189 | $(MAKE) -C $(CURDIR)/module modules | |
190 | ||
a20a40e3 TF |
191 | dh_installdirs -p${pmodules}-di |
192 | dh_install -p${pmodules}-di | |
193 | dh_gencontrol -p${pmodules}-di | |
a81c790e | 194 | |
959e5456 | 195 | dh_builddeb -p${pmodules}-di |
a81c790e AX |
196 | |
197 | override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules | |
198 | dh_testdir | |
199 | dh_testroot | |
1dd633c6 | 200 | dh_prep |
a81c790e AX |
201 | |
202 | $(MAKE) -C $(CURDIR)/module modules | |
203 | ||
204 | dh_install -p${pmodules} | |
205 | dh_installdocs -p${pmodules} | |
206 | dh_installchangelogs -p${pmodules} | |
207 | dh_compress -p${pmodules} | |
208 | dh_strip -p${pmodules} | |
209 | dh_fixperms -p${pmodules} | |
210 | dh_installdeb -p${pmodules} | |
a878da18 | 211 | dh_gencontrol -p${pmodules} |
a81c790e | 212 | dh_md5sums -p${pmodules} |
959e5456 | 213 | dh_builddeb -p${pmodules} |
0fc76429 PR |
214 | |
215 | debian-copyright: | |
216 | cme update dpkg-copyright -file debian/copyright.cme |