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