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