]> git.proxmox.com Git - mirror_zfs-debian.git/blob - debian/rules
bf0c740a95ebe8d2a03f9455c1195fdfd935fbdd
[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 VERSION := $(shell dpkg-parsechangelog \
8 | awk '$$1 == "Version:" { print $$2; }' | cut -d- -f1)
9
10 DKMSFILES := module include config zfs.release.in autogen.sh META AUTHORS \
11 DISCLAIMER COPYRIGHT OPENSOLARIS.LICENSE README.markdown
12
13 ifndef BUILD_UDEB
14 BUILD_UDEB=false
15 endif
16
17 ifndef DEB_HOST_ARCH
18 DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)
19 endif
20
21 ifndef KVERS
22 KVERS=$(shell uname -r)
23 endif
24
25 ifndef SPL
26 SPL=/usr/src/spl-$(VERSION)
27 endif
28
29 ifndef SPLOBJ
30 SPLOBJ=/var/lib/dkms/spl/$(VERSION)/$(KVERS)/$(shell dpkg-architecture -qDEB_TARGET_GNU_CPU)
31 endif
32
33 non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
34 PACKAGE=zfs
35 pmodules = $(PACKAGE)-modules-$(non_epoch_version)
36
37 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
38
39 %:
40 dh $@ --with autoreconf,dkms,python3,systemd --parallel
41
42 override_dh_auto_configure:
43 @cp debian/control.in debian/control
44 ifeq ($(BUILD_UDEB), true)
45 cat debian/control.udeb.in >> debian/control
46 endif
47
48 @# Embed the downstream version in the module.
49 @sed -e 's/^Version:.*/Version: $(VERSION)/' -i.orig META
50
51 @# Build the userland, but don't build the kernel modules.
52 dh_auto_configure -- \
53 --bindir=/usr/bin \
54 --sbindir=/sbin \
55 --libdir=/lib \
56 --with-udevdir=/lib/udev \
57 --with-systemdunitdir=/lib/systemd/system \
58 --with-systemdpresetdir=/lib/systemd/system-preset \
59 --with-config=user
60
61 override_dh_auto_test:
62 # The dh_auto_test rule is disabled because
63 # `make check` cannot run in an unprivileged build environment.
64
65 override_dh_auto_install:
66 @# Install the utilities.
67 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
68
69
70 # Move from bin_dir to /usr/sbin
71 # Remove suffix (.py) as per policy 10.4 - Scripts
72 # https://www.debian.org/doc/debian-policy/ch-files.html#s-scripts
73 mkdir -p '$(CURDIR)/debian/tmp/usr/sbin/'
74 mv '$(CURDIR)/debian/tmp/usr/bin/arc_summary.py' '$(CURDIR)/debian/tmp/usr/sbin/arc_summary'
75 mv '$(CURDIR)/debian/tmp/usr/bin/arcstat.py' '$(CURDIR)/debian/tmp/usr/sbin/arcstat'
76 mv '$(CURDIR)/debian/tmp/usr/bin/dbufstat.py' '$(CURDIR)/debian/tmp/usr/sbin/dbufstat'
77
78 @# Zed has dependencies outside of the system root.
79 $(INSTALL) -d '$(CURDIR)/debian/tmp/usr/sbin/'
80 mv '$(CURDIR)/debian/tmp/sbin/zed' '$(CURDIR)/debian/tmp/usr/sbin/zed'
81
82 @# Get a bare copy of the source code for DKMS.
83 @# This creates the $(CURDIR)/$(NAME)-$(VERSION)/ tree, which does not
84 @# contain the userland sources. NB: Remove-userland-dist-rules.patch
85 $(MAKE) distdir
86
87 @# Install the DKMS source.
88 @# We only want the files needed to build the modules
89 mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'
90 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(VERSION)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)' || 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)-$(VERSION)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/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)-$(VERSION)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
101 @# Sanity test
102 grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/Makefile.am'
103 @# Run autogen on the stripped source tree
104 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)'; ./autogen.sh
105 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/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)-$(VERSION)/cp'
110 chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(VERSION)/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
121 override_dh_dkms:
122 dh_dkms -V $(VERSION)
123
124 override_dh_makeshlibs:
125 dh_makeshlibs -a
126 ifeq ($(BUILD_UDEB), true)
127 dh_makeshlibs -plibnvpair1linux --add-udeb=libnvpair1-udeb
128 dh_makeshlibs -plibuutil1linux --add-udeb=libuutil1-udeb
129 dh_makeshlibs -plibzfs2linux --add-udeb=libzfs2-udeb
130 dh_makeshlibs -plibzpool2linux --add-udeb=libzpool2-udeb
131 dh_makeshlibs -pzfsutils-linux --add-udeb=zfsutils-udeb
132 endif
133
134 override_dh_strip:
135 dh_strip --dbg-package=zfs-dbg
136 ifeq ($(BUILD_UDEB), true)
137 dh_strip -plibnvpair1-udeb
138 dh_strip -plibuutil1-udeb
139 dh_strip -plibzfs2-udeb
140 dh_strip -plibzpool2-udeb
141 dh_strip -pzfsutils-udeb
142 endif
143
144 override_dh_auto_clean:
145 find . -name .gitignore -delete
146 rm -rf zfs-$(VERSION)
147 dh_auto_clean
148 debconf-updatepo
149 @if test -e META.orig; then mv META.orig META; fi
150 cp debian/control.in debian/control
151 ifeq ($(BUILD_UDEB), true)
152 cat debian/control.udeb.in >> debian/control
153 endif
154
155 override_dh_install:
156 find . -name lib*.la -delete
157 dh_install --fail-missing
158
159 # ------------
160
161 override_dh_prep-deb-files:
162 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
163 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)/' \
164 < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
165 done
166 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' \
167 < debian/control.modules.in > debian/control
168
169 override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp
170 override_dh_configure_modules_udeb_stamp:
171 ./configure \
172 --without-selinux \
173 --with-config=kernel \
174 --with-linux=$(KSRC) \
175 --with-linux-obj=$(KOBJ) \
176 --with-spl=$(SPL) \
177 --with-spl-obj=$(SPLOBJ)
178 touch override_dh_configure_modules_udeb_stamp
179
180 override_dh_configure_modules: override_dh_configure_modules_stamp
181 override_dh_configure_modules_stamp:
182 ./configure \
183 --with-config=kernel \
184 --with-linux=$(KSRC) \
185 --with-linux-obj=$(KOBJ) \
186 --with-spl=$(SPL) \
187 --with-spl-obj=$(SPLOBJ)
188 touch override_dh_configure_modules_stamp
189
190 override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb
191 dh_testdir
192 dh_testroot
193 dh_prep
194
195 $(MAKE) -C $(CURDIR)/module modules
196
197 dh_installdirs -p${pmodules}-di
198 dh_install -p${pmodules}-di
199 dh_gencontrol -p${pmodules}-di
200
201 dh_builddeb -p${pmodules}-di
202
203 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
204 dh_testdir
205 dh_testroot
206 dh_prep
207
208 $(MAKE) -C $(CURDIR)/module modules
209
210 dh_install -p${pmodules}
211 dh_installdocs -p${pmodules}
212 dh_installchangelogs -p${pmodules}
213 dh_compress -p${pmodules}
214 dh_strip -p${pmodules}
215 dh_fixperms -p${pmodules}
216 dh_installdeb -p${pmodules}
217 dh_gencontrol -p${pmodules}
218 dh_md5sums -p${pmodules}
219 dh_builddeb -p${pmodules}
220
221 debian-copyright:
222 cme update dpkg-copyright -file debian/copyright.cme