Always validate checksums for Direct I/O reads
[zfs.git] / contrib / debian / rules.in
blob3226d604546cbab6c826253e0a9255f8b62110b8
1 #!/usr/bin/make -f
3 include /usr/share/dpkg/default.mk
5 LSB_DISTRIBUTOR := $(shell lsb_release -is)
6 NAME := $(shell awk '$$1 == "Name:" { print $$2; }' META)
7 LINUX_MIN := $(shell awk '/Linux-Minimum:/{print $$2}' META)
8 LINUX_NEXT := $(shell awk -F'[ .]' '/Linux-Maximum:/{print $$2 "." $$3+1}' META)
10 DKMSFILES := module include config zfs.release.in autogen.sh copy-builtin META AUTHORS \
11 COPYRIGHT LICENSE README.md CODE_OF_CONDUCT.md NEWS NOTICE RELEASES.md
13 ifndef KVERS
14 KVERS=$(shell uname -r)
15 endif
17 non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
18 PACKAGE=openzfs-zfs
19 pmodules = $(PACKAGE)-modules-$(non_epoch_version)
21 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
23 NUM_CPUS = $(shell nproc 2>/dev/null)
24 PARALLEL = $(subst parallel=,,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
25 NJOBS = -j$(or $(PARALLEL),$(NUM_CPUS),1)
28 dh $@ --with autoreconf,dkms,python3,sphinxdoc
30 override_dh_autoreconf:
31 @# Embed the downstream version in the module.
32 @sed -e 's/^Version:.*/Version: $(DEB_VERSION_UPSTREAM)/' -i.orig META
34 dh_autoreconf
36 override_dh_auto_configure:
37 @# Build the userland, but don't build the kernel modules.
38 dh_auto_configure -- @CFGOPTS@ \
39 --bindir=/usr/bin \
40 --sbindir=/sbin \
41 --libdir=/lib/"$(DEB_HOST_MULTIARCH)" \
42 --with-udevdir=/lib/udev \
43 --with-zfsexecdir=/usr/lib/zfs-linux \
44 --enable-systemd \
45 --enable-pyzfs \
46 --with-python=python3 \
47 --with-pammoduledir='/lib/$(DEB_HOST_MULTIARCH)/security' \
48 --with-pkgconfigdir='/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig' \
49 --with-systemdunitdir=/lib/systemd/system \
50 --with-systemdpresetdir=/lib/systemd/system-preset \
51 --with-systemdgeneratordir=/lib/systemd/system-generators \
52 --with-config=user
54 for i in $(wildcard $(CURDIR)/debian/*.install.in) ; do \
55 basename "$$i" | grep _KVERS_ && continue ; \
56 sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' "$$i" > "$${i%%.in}" ; \
57 done
59 ln -s '$(CURDIR)/etc/init.d/zfs-import' '$(CURDIR)/debian/openzfs-zfsutils.zfs-import.init'
60 ln -s '$(CURDIR)/etc/init.d/zfs-load-key' '$(CURDIR)/debian/openzfs-zfsutils.zfs-load-key.init'
61 ln -s '$(CURDIR)/etc/init.d/zfs-mount' '$(CURDIR)/debian/openzfs-zfsutils.zfs-mount.init'
62 ln -s '$(CURDIR)/etc/init.d/zfs-share' '$(CURDIR)/debian/openzfs-zfsutils.zfs-share.init'
63 ln -s '$(CURDIR)/etc/init.d/zfs-zed' '$(CURDIR)/debian/openzfs-zfs-zed.zfs-zed.init'
65 override_dh_gencontrol:
66 dh_gencontrol -- -Vlinux:Recommends="linux-libc-dev (<< $(LINUX_NEXT)~), linux-libc-dev (>= $(LINUX_MIN)~),"
68 override_dh_auto_build:
69 @# Get a bare copy of the source code for DKMS.
70 @# This creates the $(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/ tree, which does not
71 @# contain the userland sources. NB: Remove-userland-dist-rules.patch
72 $(MAKE) distdir
74 dh_auto_build
76 override_dh_auto_install:
77 @# Install the utilities.
78 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
80 # Move from bin_dir to /usr/sbin
81 # Remove suffix (.py) as per policy 10.4 - Scripts
82 # https://www.debian.org/doc/debian-policy/ch-files.html#s-scripts
83 mkdir -p '$(CURDIR)/debian/tmp/usr/sbin/'
84 mv '$(CURDIR)/debian/tmp/usr/bin/arc_summary' '$(CURDIR)/debian/tmp/usr/sbin/arc_summary'
85 mv '$(CURDIR)/debian/tmp/usr/bin/arcstat' '$(CURDIR)/debian/tmp/usr/sbin/arcstat'
86 mv '$(CURDIR)/debian/tmp/usr/bin/dbufstat' '$(CURDIR)/debian/tmp/usr/sbin/dbufstat'
87 mv '$(CURDIR)/debian/tmp/usr/bin/zilstat' '$(CURDIR)/debian/tmp/usr/sbin/zilstat'
89 @# Zed has dependencies outside of the system root.
90 mv '$(CURDIR)/debian/tmp/sbin/zed' '$(CURDIR)/debian/tmp/usr/sbin/zed'
91 sed -i 's|ExecStart=/sbin/|ExecStart=/usr/sbin/|g' '$(CURDIR)/debian/tmp/lib/systemd/system/zfs-zed.service'
93 @# Install the DKMS source.
94 @# We only want the files needed to build the modules
95 install -D -t '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/scripts' \
96 '$(CURDIR)/scripts/dkms.postbuild'
97 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' || exit 1;)
99 @# Only ever build Linux modules
100 echo 'SUBDIRS = linux' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/include/os/Makefile.am'
102 @# Hellish awk line:
103 @# * Deletes from configure.ac the parts not needed for building the kernel module
104 @# * It deletes from inside AC_CONFIG_FILES([]) everything except:
105 @# - Makefile$
106 @# - include/(Makefile|sys|os/(Makefile|linux))
107 @# - module/
108 @# - zfs.release$
109 @# * Takes care of spaces and tabs
110 @# * Remove reference to ZFS_AC_PACKAGE
111 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ {\
112 if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/(Makefile|sys|os\/(Makefile|linux))|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/) \
113 {next} } {print}' \
114 '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac' | sed '/ZFS_AC_PACKAGE/d' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac'
115 @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
116 @# Do not regenerate zfs_gitrev.h during dkms build
117 sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;/make_gitrev.sh/d' \
118 '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am'
119 @# Sanity test
120 grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am'
121 sed -i '/rpm.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
122 sed -i '/cmd.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
123 sed -i '/contrib.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
124 sed -i '/etc.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
125 sed -i '/lib.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
126 sed -i '/man.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
127 sed -i '/scripts.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
128 sed -i '/tests.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
129 sed -i '/udev.Makefile/d' $(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am
130 @# Run autogen on the stripped source tree
131 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)'; ./autogen.sh
132 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/autom4te.cache'
134 for i in `ls $(CURDIR)/debian/tmp/lib/$(DEB_HOST_MULTIARCH)/*.so`; do \
135 ln -s '/lib/$(DEB_HOST_MULTIARCH)/'`readlink $${i}` '$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/'`basename $${i}`; \
136 rm $${i}; \
137 done
139 chmod a-x '$(CURDIR)/debian/tmp/etc/zfs/zfs-functions'
140 chmod a-x '$(CURDIR)/debian/tmp/etc/default/zfs'
142 override_dh_python3:
143 dh_python3 -p openzfs-python3-pyzfs
145 override_dh_dkms:
146 '$(CURDIR)/scripts/dkms.mkconf' -n $(NAME) -v $(DEB_VERSION_UPSTREAM) -f '$(CURDIR)/scripts/zfs-dkms.dkms'
147 dh_dkms
148 rm -f '$(CURDIR)/scripts/zfs-dkms.dkms'
150 override_dh_makeshlibs:
151 dh_makeshlibs -a -V
153 override_dh_strip:
154 dh_strip
156 override_dh_auto_clean:
157 rm -rf zfs-$(DEB_VERSION_UPSTREAM)
158 dh_auto_clean
159 @if test -e META.orig; then mv META.orig META; fi
161 override_dh_install:
162 find debian/tmp/lib -name '*.la' -delete
163 dh_install
165 override_dh_missing:
166 dh_missing --fail-missing
168 override_dh_installinit:
169 dh_installinit -r --no-restart-after-upgrade --name zfs-import
170 dh_installinit -r --no-restart-after-upgrade --name zfs-mount
171 dh_installinit -r --no-restart-after-upgrade --name zfs-load-key
172 dh_installinit -R --name zfs-share
173 dh_installinit -R --name zfs-zed
175 override_dh_installsystemd:
176 mkdir -p debian/openzfs-zfsutils/lib/systemd/system
177 ln -sr /dev/null debian/openzfs-zfsutils/lib/systemd/system/zfs-import.service
178 dh_installsystemd --no-stop-on-upgrade -X zfs-zed.service
179 dh_installsystemd --name zfs-zed
181 override_dh_installdocs:
182 dh_installdocs -A
183 ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
184 http_proxy='127.0.0.1:9' sphinx-build -N -bhtml "$(CURDIR)/contrib/pyzfs/docs/source/" debian/openzfs-pyzfs-doc/usr/share/doc/openzfs-pyzfs-doc/html/
185 endif
187 # ------------
189 override_dh_prep-deb-files:
190 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
191 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)/' \
192 < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
193 done
194 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' \
195 < debian/control.modules.in > debian/control
197 override_dh_configure_modules: override_dh_configure_modules_stamp
198 override_dh_configure_modules_stamp:
199 ./configure @CFGOPTS@ \
200 --with-config=kernel \
201 --with-linux=$(KSRC) \
202 --with-linux-obj=$(KOBJ)
203 touch override_dh_configure_modules_stamp
205 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
206 dh_testdir
207 dh_testroot
208 dh_prep
210 $(MAKE) $(NJOBS) -C $(CURDIR)/module modules
212 dh_install -p${pmodules}
213 dh_installdocs -p${pmodules}
214 dh_installchangelogs -p${pmodules}
215 dh_compress -p${pmodules}
216 dh_strip -p${pmodules}
217 dh_fixperms -p${pmodules}
218 dh_installdeb -p${pmodules}
219 dh_gencontrol -p${pmodules}
220 dh_md5sums -p${pmodules}
221 dh_builddeb -p${pmodules}
223 debian-copyright:
224 cme update dpkg-copyright -file debian/copyright.cme