]> git.proxmox.com Git - mirror_zfs-debian.git/blob - debian/rules
e2c5a25f2534b303e9728c520c9786bb52b46da3
[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
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 KVERS
16 KVERS=$(shell uname -r)
17 endif
18
19 ifndef SPL
20 SPL=/usr/src/spl-$(DEB_VERSION_UPSTREAM)
21 endif
22
23 ifndef SPLOBJ
24 SPLOBJ=/var/lib/dkms/spl/$(DEB_VERSION_UPSTREAM)/$(KVERS)/$(DEB_TARGET_GNU_CPU)
25 endif
26
27 non_epoch_version=$(shell echo $(KVERS) | perl -pe 's/^\d+://')
28 PACKAGE=zfs
29 pmodules = $(PACKAGE)-modules-$(non_epoch_version)
30
31 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
32
33 %:
34 dh $@ --with autoreconf,dkms,python3,systemd --parallel
35
36 override_dh_auto_configure:
37 sed "s/@LINUX_COMPAT@/linux-libc-dev \(<< $(shell debian/get_next.sh)\)/" debian/control.in > debian/control
38 ifeq ($(BUILD_UDEB), true)
39 cat debian/control.udeb.in >> debian/control
40 endif
41
42 @# Embed the downstream version in the module.
43 @sed -e 's/^Version:.*/Version: $(DEB_VERSION_UPSTREAM)/' -i.orig META
44
45 @# Build the userland, but don't build the kernel modules.
46 dh_auto_configure -- \
47 --bindir=/usr/bin \
48 --sbindir=/sbin \
49 --libdir=/lib \
50 --with-udevdir=/lib/udev \
51 --enable-systemd \
52 --with-systemdunitdir=/lib/systemd/system \
53 --with-systemdpresetdir=/lib/systemd/system-preset \
54 --with-config=user
55
56 override_dh_auto_test:
57 # The dh_auto_test rule is disabled because
58 # `make check` cannot run in an unprivileged build environment.
59
60 override_dh_auto_install:
61 @# Install the utilities.
62 $(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'
63
64
65 # Move from bin_dir to /usr/sbin
66 # Remove suffix (.py) as per policy 10.4 - Scripts
67 # https://www.debian.org/doc/debian-policy/ch-files.html#s-scripts
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'
72
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
77 @# Get a bare copy of the source code for DKMS.
78 @# This creates the $(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/ tree, which does not
79 @# contain the userland sources. NB: Remove-userland-dist-rules.patch
80 $(MAKE) distdir
81
82 @# Install the DKMS source.
83 @# We only want the files needed to build the modules
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'
86 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' || exit 1;)
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:
90 @# (Makefile$|include/|module/|*.release$)
91 @# * Takes care of spaces and tabs
92 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \
93 '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac'
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;' \
96 '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am'
97 @# Sanity test
98 grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am'
99 @# Run autogen on the stripped source tree
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'
102
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.
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'
107
108 mkdir -p $(CURDIR)/debian/tmp/usr/lib
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
114 chmod a-x $(CURDIR)/debian/tmp/etc/zfs/zfs-functions
115 chmod a-x $(CURDIR)/debian/tmp/etc/default/zfs
116
117 override_dh_dkms:
118 dh_dkms -V $(DEB_VERSION_UPSTREAM)
119
120 override_dh_makeshlibs:
121 dh_makeshlibs -a -V
122 ifeq ($(BUILD_UDEB), true)
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
128 endif
129
130 override_dh_strip:
131 dh_strip --dbg-package=zfs-dbg
132 ifeq ($(BUILD_UDEB), true)
133 dh_strip -plibnvpair1-udeb
134 dh_strip -plibuutil1-udeb
135 dh_strip -plibzfs2-udeb
136 dh_strip -plibzpool2-udeb
137 dh_strip -pzfsutils-udeb
138 endif
139
140 override_dh_auto_clean:
141 find . -name .gitignore -delete
142 rm -rf zfs-$(DEB_VERSION_UPSTREAM)
143 dh_auto_clean
144 debconf-updatepo
145 @if test -e META.orig; then mv META.orig META; fi
146 sed "s/@LINUX_COMPAT@/linux-libc-dev \(<< $(shell debian/get_next.sh)\)/" debian/control.in > debian/control
147 ifeq ($(BUILD_UDEB), true)
148 cat debian/control.udeb.in >> debian/control
149 endif
150
151 override_dh_install:
152 find . -name lib*.la -delete
153 dh_install --fail-missing
154
155 # ------------
156
157 override_dh_prep-deb-files:
158 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
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$$//'` ; \
161 done
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' \
163 < debian/control.modules.in > debian/control
164
165 override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp
166 override_dh_configure_modules_udeb_stamp:
167 ./configure \
168 --without-selinux \
169 --with-config=kernel \
170 --with-linux=$(KSRC) \
171 --with-linux-obj=$(KOBJ) \
172 --with-spl=$(SPL) \
173 --with-spl-obj=$(SPLOBJ)
174 touch override_dh_configure_modules_udeb_stamp
175
176 override_dh_configure_modules: override_dh_configure_modules_stamp
177 override_dh_configure_modules_stamp:
178 ./configure \
179 --with-config=kernel \
180 --with-linux=$(KSRC) \
181 --with-linux-obj=$(KOBJ) \
182 --with-spl=$(SPL) \
183 --with-spl-obj=$(SPLOBJ)
184 touch override_dh_configure_modules_stamp
185
186 override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb
187 dh_testdir
188 dh_testroot
189 dh_prep
190
191 $(MAKE) -C $(CURDIR)/module modules
192
193 dh_installdirs -p${pmodules}-di
194 dh_install -p${pmodules}-di
195 dh_gencontrol -p${pmodules}-di
196
197 dh_builddeb -p${pmodules}-di
198
199 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
200 dh_testdir
201 dh_testroot
202 dh_prep
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}
213 dh_gencontrol -p${pmodules}
214 dh_md5sums -p${pmodules}
215 dh_builddeb -p${pmodules}
216
217 debian-copyright:
218 cme update dpkg-copyright -file debian/copyright.cme