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