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