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