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