]> git.proxmox.com Git - mirror_zfs-debian.git/blob - debian/rules
Replace get_next.sh with one-liner awk script in rules.
[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
66 # Move from bin_dir to /usr/sbin
67 # Remove suffix (.py) as per policy 10.4 - Scripts
68 # https://www.debian.org/doc/debian-policy/ch-files.html#s-scripts
69 mkdir -p '$(CURDIR)/debian/tmp/usr/sbin/'
70 mv '$(CURDIR)/debian/tmp/usr/bin/arc_summary.py' '$(CURDIR)/debian/tmp/usr/sbin/arc_summary'
71 mv '$(CURDIR)/debian/tmp/usr/bin/arcstat.py' '$(CURDIR)/debian/tmp/usr/sbin/arcstat'
72 mv '$(CURDIR)/debian/tmp/usr/bin/dbufstat.py' '$(CURDIR)/debian/tmp/usr/sbin/dbufstat'
73
74 @# Zed has dependencies outside of the system root.
75 $(INSTALL) -d '$(CURDIR)/debian/tmp/usr/sbin/'
76 mv '$(CURDIR)/debian/tmp/sbin/zed' '$(CURDIR)/debian/tmp/usr/sbin/zed'
77
78 @# Get a bare copy of the source code for DKMS.
79 @# This creates the $(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/ tree, which does not
80 @# contain the userland sources. NB: Remove-userland-dist-rules.patch
81 $(MAKE) distdir
82
83 @# Install the DKMS source.
84 @# We only want the files needed to build the modules
85 mkdir -p '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/scripts'
86 cp '$(CURDIR)/scripts/enum-extract.pl' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/scripts'
87 $(foreach file,$(DKMSFILES),mv '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/$(file)' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)' || exit 1;)
88 @# Hellish awk line:
89 @# * Deletes from configure.ac the parts not needed for building the kernel module
90 @# * It deletes from inside AC_CONFIG_FILES([]) everything except:
91 @# (Makefile$|include/|module/|*.release$)
92 @# * Takes care of spaces and tabs
93 awk '/^AC_CONFIG_FILES\(\[/,/^\]\)/ { if ($$0 !~ /^(AC_CONFIG_FILES\(\[([ \t]+)?$$|\]\)([ \t]+)?$$|([ \t]+)?(include\/|module\/|Makefile([ \t]+)?$$|zfs\.release([ \t]+)?$$))/){next} } {print}' \
94 '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/configure.ac'
95 @# Set "SUBDIRS = module include" for CONFIG_KERNEL and remove SUBDIRS for all other configs.
96 sed '1,/CONFIG_KERNEL/s/SUBDIRS.*=.*//g;s/SUBDIRS.*=.*/SUBDIRS = module include/g;' \
97 '$(CURDIR)/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am'
98 @# Sanity test
99 grep -q 'SUBDIRS = module include' '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/Makefile.am'
100 @# Run autogen on the stripped source tree
101 cd '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)'; ./autogen.sh
102 rm -fr '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/autom4te.cache'
103
104 @# This shunt allows DKMS to install the Module.symvers and zfs_config.h
105 @# files to the ${dkms_tree} area through the POST_INSTALL directive.
106 printf '#!/bin/sh\ncp "$$@"\n' > '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/cp'
107 chmod 755 '$(CURDIR)/debian/tmp/usr/src/$(NAME)-$(DEB_VERSION_UPSTREAM)/cp'
108
109 mkdir -p $(CURDIR)/debian/tmp/usr/lib
110 for i in `ls $(CURDIR)/debian/tmp/lib/*.so`; do \
111 ln -s /lib/`readlink $${i}` $(CURDIR)/debian/tmp/usr/lib/`basename $${i}`; \
112 rm $${i}; \
113 done
114
115 chmod a-x $(CURDIR)/debian/tmp/etc/zfs/zfs-functions
116 chmod a-x $(CURDIR)/debian/tmp/etc/default/zfs
117
118 override_dh_dkms:
119 dh_dkms -V $(DEB_VERSION_UPSTREAM)
120
121 override_dh_makeshlibs:
122 dh_makeshlibs -a -V
123 ifeq ($(BUILD_UDEB), true)
124 dh_makeshlibs -V -plibnvpair1linux --add-udeb=libnvpair1-udeb
125 dh_makeshlibs -V -plibuutil1linux --add-udeb=libuutil1-udeb
126 dh_makeshlibs -V -plibzfs2linux --add-udeb=libzfs2-udeb
127 dh_makeshlibs -V -plibzpool2linux --add-udeb=libzpool2-udeb
128 dh_makeshlibs -V -pzfsutils-linux --add-udeb=zfsutils-udeb
129 endif
130
131 override_dh_strip:
132 dh_strip --dbg-package=zfs-dbg
133 ifeq ($(BUILD_UDEB), true)
134 dh_strip -plibnvpair1-udeb
135 dh_strip -plibuutil1-udeb
136 dh_strip -plibzfs2-udeb
137 dh_strip -plibzpool2-udeb
138 dh_strip -pzfsutils-udeb
139 endif
140
141 override_dh_auto_clean:
142 find . -name .gitignore -delete
143 rm -rf zfs-$(DEB_VERSION_UPSTREAM)
144 dh_auto_clean
145 debconf-updatepo
146 @if test -e META.orig; then mv META.orig META; fi
147 sed "s/@LINUX_COMPAT@/linux-libc-dev \(<< $(LINUX_NEXT)\)/" debian/control.in > debian/control
148 ifeq ($(BUILD_UDEB), true)
149 cat debian/control.udeb.in >> debian/control
150 endif
151
152 override_dh_install:
153 find . -name lib*.la -delete
154 dh_install --fail-missing
155
156 # ------------
157
158 override_dh_prep-deb-files:
159 for templ in $(wildcard $(CURDIR)/debian/*_KVERS_*.in); do \
160 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)/' \
161 < $$templ > `echo $$templ | sed -e 's/_KVERS_/$(KVERS)/g ; s/_ARCH_/$(DEB_HOST_ARCH)/g ; s/\.in$$//'` ; \
162 done
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)/g' \
164 < debian/control.modules.in > debian/control
165
166 override_dh_configure_modules_udeb: override_dh_configure_modules_udeb_stamp
167 override_dh_configure_modules_udeb_stamp:
168 ./configure \
169 --without-selinux \
170 --with-config=kernel \
171 --with-linux=$(KSRC) \
172 --with-linux-obj=$(KOBJ) \
173 --with-spl=$(SPL) \
174 --with-spl-obj=$(SPLOBJ)
175 touch override_dh_configure_modules_udeb_stamp
176
177 override_dh_configure_modules: override_dh_configure_modules_stamp
178 override_dh_configure_modules_stamp:
179 ./configure \
180 --with-config=kernel \
181 --with-linux=$(KSRC) \
182 --with-linux-obj=$(KOBJ) \
183 --with-spl=$(SPL) \
184 --with-spl-obj=$(SPLOBJ)
185 touch override_dh_configure_modules_stamp
186
187 override_dh_binary-modules-udeb: override_dh_prep-deb-files override_dh_configure_modules_udeb
188 dh_testdir
189 dh_testroot
190 dh_prep
191
192 $(MAKE) -C $(CURDIR)/module modules
193
194 dh_installdirs -p${pmodules}-di
195 dh_install -p${pmodules}-di
196 dh_gencontrol -p${pmodules}-di
197
198 dh_builddeb -p${pmodules}-di
199
200 override_dh_binary-modules: override_dh_prep-deb-files override_dh_configure_modules
201 dh_testdir
202 dh_testroot
203 dh_prep
204
205 $(MAKE) -C $(CURDIR)/module modules
206
207 dh_install -p${pmodules}
208 dh_installdocs -p${pmodules}
209 dh_installchangelogs -p${pmodules}
210 dh_compress -p${pmodules}
211 dh_strip -p${pmodules}
212 dh_fixperms -p${pmodules}
213 dh_installdeb -p${pmodules}
214 dh_gencontrol -p${pmodules}
215 dh_md5sums -p${pmodules}
216 dh_builddeb -p${pmodules}
217
218 debian-copyright:
219 cme update dpkg-copyright -file debian/copyright.cme