]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - debian/rules.d/2-binary-arch.mk
UBUNTU: [Debian] Don't attempt to sign files if CONFIG_MODULE_SIG=n
[mirror_ubuntu-zesty-kernel.git] / debian / rules.d / 2-binary-arch.mk
1 # We don't want make removing intermediary stamps
2 .SECONDARY :
3
4 # Prepare the out-of-tree build directory
5 ifeq ($(do_full_source),true)
6 build_cd = cd $(builddir)/build-$*; #
7 build_O =
8 else
9 build_cd =
10 build_O = O=$(builddir)/build-$*
11 endif
12
13 # Typically supplied from the arch makefile, e.g., debian.master/control.d/armhf.mk
14 ifneq ($(gcc),)
15 kmake += CC=$(CROSS_COMPILE)$(gcc)
16 endif
17
18 shlibdeps_opts = $(if $(CROSS_COMPILE),-- -l$(CROSS_COMPILE:%-=/usr/%)/lib)
19
20 $(stampdir)/stamp-prepare-%: config-prepare-check-%
21 @echo Debug: $@
22 @touch $@
23 $(stampdir)/stamp-prepare-tree-%: target_flavour = $*
24 $(stampdir)/stamp-prepare-tree-%: $(commonconfdir)/config.common.$(family) $(archconfdir)/config.common.$(arch) $(archconfdir)/config.flavour.%
25 @echo Debug: $@
26 install -d $(builddir)/build-$*
27 touch $(builddir)/build-$*/ubuntu-build
28 [ "$(do_full_source)" != 'true' ] && true || \
29 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) * $(builddir)/build-$*
30 cat $^ | sed -e 's/.*CONFIG_VERSION_SIGNATURE.*/CONFIG_VERSION_SIGNATURE="Ubuntu $(release)-$(revision)-$* $(raw_kernelversion)"/' > $(builddir)/build-$*/.config
31 find $(builddir)/build-$* -name "*.ko" | xargs rm -f
32 $(build_cd) $(kmake) $(build_O) -j1 silentoldconfig prepare scripts
33 touch $@
34
35 # Used by developers as a shortcut to prepare a tree for compilation.
36 prepare-%: $(stampdir)/stamp-prepare-%
37 @echo Debug: $@
38 # Used by developers to allow efficient pre-building without fakeroot.
39 build-%: $(stampdir)/stamp-build-%
40 @echo Debug: $@
41
42 define build_zfs =
43 #
44 # SPL/ZFS wants a fully built kernel before you can configure and build.
45 # It seems to be impossible to tease out the application configuration
46 # from the modules, but at least one can build just the modules.
47 #
48 install -d $(builddir)/build-$*/spl
49 rsync -a --exclude=dkms.conf --delete spl/ $(builddir)/build-$*/spl/
50 cd $(builddir)/build-$*/spl; sh autogen.sh; sh configure $(splopts)
51 $(kmake) -C $(builddir)/build-$*/spl/module $(conc_level)
52
53 install -d $(builddir)/build-$*/zfs
54 rsync -a --exclude=dkms.conf --delete zfs/ $(builddir)/build-$*/zfs/
55 cd $(builddir)/build-$*/zfs; sh autogen.sh; sh configure $(zfsopts)
56 $(kmake) -C $(builddir)/build-$*/zfs/module $(conc_level)
57 endef
58
59 # Do the actual build, including image and modules
60 $(stampdir)/stamp-build-%: target_flavour = $*
61 $(stampdir)/stamp-build-%: splopts = --with-linux=$(CURDIR)
62 $(stampdir)/stamp-build-%: splopts += --with-linux-obj=$(builddir)/build-$*
63 $(stampdir)/stamp-build-%: zfsopts = $(splopts)
64 $(stampdir)/stamp-build-%: zfsopts += --with-spl=$(builddir)/build-$*/spl
65 $(stampdir)/stamp-build-%: zfsopts += --with-spl-obj=$(builddir)/build-$*/spl
66 $(stampdir)/stamp-build-%: zfsopts += --prefix=/usr --with-config=kernel
67 $(stampdir)/stamp-build-%: bldimg = $(call custom_override,build_image,$*)
68 $(stampdir)/stamp-build-%: enable_zfs = $(call custom_override,do_zfs,$*)
69 $(stampdir)/stamp-build-%: $(stampdir)/stamp-prepare-%
70 @echo Debug: $@ build_image $(build_image) bldimg $(bldimg)
71 $(build_cd) $(kmake) $(build_O) $(conc_level) $(bldimg) modules $(if $(filter true,$(do_dtbs)),dtbs)
72
73 $(if $(filter true,$(enable_zfs)),$(call build_zfs))
74
75 @touch $@
76
77 define install_zfs =
78 cd $(builddir)/build-$*/spl/module; \
79 $(kmake) -C $(builddir)/build-$* SUBDIRS=`pwd` modules_install $(splopts)
80 cd $(builddir)/build-$*/zfs/module; \
81 $(kmake) -C $(builddir)/build-$* SUBDIRS=`pwd` modules_install $(zfsopts)
82 endef
83
84 # Install the finished build
85 install-%: pkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*
86 install-%: pkgdir_ex = $(CURDIR)/debian/$(extra_pkg_name)-$*
87 install-%: bindoc = $(pkgdir)/usr/share/doc/$(bin_pkg_name)-$*
88 install-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
89 install-%: signed = $(CURDIR)/debian/$(bin_pkg_name)-signed
90 install-%: toolspkgdir = $(CURDIR)/debian/$(tools_flavour_pkg_name)-$*
91 install-%: cloudpkgdir = $(CURDIR)/debian/$(cloud_flavour_pkg_name)-$*
92 install-%: basepkg = $(hdrs_pkg_name)
93 install-%: indeppkg = $(indep_hdrs_pkg_name)
94 install-%: kernfile = $(call custom_override,kernel_file,$*)
95 install-%: instfile = $(call custom_override,install_file,$*)
96 install-%: hdrdir = $(CURDIR)/debian/$(basepkg)-$*/usr/src/$(basepkg)-$*
97 install-%: target_flavour = $*
98 install-%: MODHASHALGO=sha512
99 install-%: MODSECKEY=$(builddir)/build-$*/certs/signing_key.pem
100 install-%: MODPUBKEY=$(builddir)/build-$*/certs/signing_key.x509
101 install-%: build_dir=$(builddir)/build-$*
102 install-%: enable_zfs = $(call custom_override,do_zfs,$*)
103 install-%: splopts = INSTALL_MOD_STRIP=1
104 install-%: splopts += INSTALL_MOD_PATH=$(pkgdir)/
105 install-%: splopts += INSTALL_MOD_DIR=kernel/zfs
106 install-%: splopts += $(conc_level)
107 install-%: zfsopts = $(splopts)
108 install-%: checks-%
109 @echo Debug: $@ kernel_file $(kernel_file) kernfile $(kernfile) install_file $(install_file) instfile $(instfile)
110 dh_testdir
111 dh_testroot
112 dh_clean -k -p$(bin_pkg_name)-$*
113 dh_clean -k -p$(hdrs_pkg_name)-$*
114 ifneq ($(skipdbg),true)
115 dh_clean -k -p$(dbg_pkg_name)-$*
116 endif
117
118 # The main image
119 # compress_file logic required because not all architectures
120 # generate a zImage automatically out of the box
121 ifeq ($(compress_file),)
122 install -m600 -D $(builddir)/build-$*/$(kernfile) \
123 $(pkgdir)/boot/$(instfile)-$(abi_release)-$*
124 else
125 install -d $(pkgdir)/boot
126 gzip -c9v $(builddir)/build-$*/$(kernfile) > \
127 $(pkgdir)/boot/$(instfile)-$(abi_release)-$*
128 chmod 600 $(pkgdir)/boot/$(instfile)-$(abi_release)-$*
129 endif
130
131 ifeq ($(uefi_signed),true)
132 install -d $(signed)/$(release)-$(revision)
133 # Check to see if this supports handoff, if not do not sign it.
134 # Check the identification area magic and version >= 0x020b
135 handoff=`dd if="$(pkgdir)/boot/$(instfile)-$(abi_release)-$*" bs=1 skip=514 count=6 2>/dev/null | od -s | gawk '($$1 == 0 && $$2 == 25672 && $$3 == 21362 && $$4 >= 523) { print "GOOD" }'`; \
136 if [ "$$handoff" = "GOOD" ]; then \
137 cp -p $(pkgdir)/boot/$(instfile)-$(abi_release)-$* \
138 $(signed)/$(release)-$(revision)/$(instfile)-$(abi_release)-$*.efi; \
139 fi
140 endif
141
142 install -m644 $(builddir)/build-$*/.config \
143 $(pkgdir)/boot/config-$(abi_release)-$*
144 install -m644 $(abidir)/$* \
145 $(pkgdir)/boot/abi-$(abi_release)-$*
146 install -m600 $(builddir)/build-$*/System.map \
147 $(pkgdir)/boot/System.map-$(abi_release)-$*
148 if [ "$(filter true,$(do_dtbs))" ]; then \
149 $(build_cd) $(kmake) $(build_O) $(conc_level) dtbs_install \
150 INSTALL_DTBS_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*/device-tree; \
151 ( cd $(pkgdir)/lib/firmware/$(abi_release)-$*/ && find device-tree -print ) | \
152 while read dtb_file; do \
153 echo "$$dtb_file ?" >> $(DEBIAN)/d-i/firmware/$(arch)/kernel-image; \
154 done; \
155 fi
156 ifeq ($(no_dumpfile),)
157 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
158 -x $(builddir)/build-$*/vmlinux
159 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
160 endif
161
162 $(build_cd) $(kmake) $(build_O) $(conc_level) modules_install $(vdso) \
163 INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(pkgdir)/ \
164 INSTALL_FW_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*
165
166 $(if $(filter true,$(enable_zfs)),$(call install_zfs))
167
168 #
169 # Build module blacklists:
170 # - blacklist all watchdog drivers (LP:1432837)
171 #
172 install -d $(pkgdir)/lib/modprobe.d
173 echo "# Kernel supplied blacklist for $(src_pkg_name) $(abi_release)-$* $(arch)" \
174 >$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
175 for conf in $(arch)-$* $(arch) common.conf; do \
176 if [ -f $(DEBIAN)/modprobe.d/$$conf ]; then \
177 echo "# modprobe.d/$$conf"; \
178 cat $(DEBIAN)/modprobe.d/$$conf; \
179 fi; \
180 done >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
181 echo "# Autogenerated watchdog blacklist" \
182 >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
183 ls -1 $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/watchdog/ | \
184 sed -e 's/^/blacklist /' -e 's/.ko$$//' | \
185 sort -u \
186 >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
187
188 ifeq ($(do_extras_package),true)
189 #
190 # Remove all modules not in the inclusion list.
191 #
192 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
193 /sbin/depmod -v -b $(pkgdir) $(abi_release)-$* | \
194 sed -e "s@$(pkgdir)/lib/modules/$(abi_release)-$*/kernel/@@g" | \
195 awk '{ print $$1 " " $$NF}' >$(build_dir)/module-inclusion.depmap; \
196 mkdir -p $(pkgdir_ex)/lib/modules/$(abi_release)-$*; \
197 mv $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
198 $(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel; \
199 $(SHELL) $(DROOT)/scripts/module-inclusion --master \
200 $(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel \
201 $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
202 $(DEBIAN)/control.d/$(target_flavour).inclusion-list \
203 $(build_dir)/module-inclusion.depmap 2>&1 | \
204 tee $(target_flavour).inclusion-list.log; \
205 /sbin/depmod -b $(pkgdir) -ea -F $(pkgdir)/boot/System.map-$(abi_release)-$* \
206 $(abi_release)-$* 2>&1 |tee $(target_flavour).depmod.log; \
207 if [ `grep -c 'unknown symbol' $(target_flavour).depmod.log` -gt 0 ]; then \
208 echo "EE: Unresolved module dependencies in base package!"; \
209 exit 1; \
210 fi \
211 fi
212 endif
213
214 ifeq ($(no_dumpfile),)
215 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
216 -x $(builddir)/build-$*/vmlinux
217 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
218 endif
219 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/build
220 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/source
221
222 # Some initramfs-tools specific modules
223 install -d $(pkgdir)/lib/modules/$(abi_release)-$*/initrd
224 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko ]; then\
225 $(LN) $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko \
226 $(pkgdir)/lib/modules/$(abi_release)-$*/initrd/; \
227 fi
228
229 # Now the image scripts
230 install -d $(pkgdir)/DEBIAN
231 for script in postinst postrm preinst prerm; do \
232 sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(instfile)/g' \
233 -e 's/=L/$(loader)/g' -e 's@=B@$(build_arch)@g' \
234 $(DROOT)/control-scripts/$$script > $(pkgdir)/DEBIAN/$$script; \
235 chmod 755 $(pkgdir)/DEBIAN/$$script; \
236 done
237 ifeq ($(do_extras_package),true)
238 # Install the postinit/postrm scripts in the extras package.
239 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
240 install -d $(pkgdir_ex)/DEBIAN; \
241 for script in postinst postrm ; do \
242 sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(instfile)/g' \
243 -e 's/=L/$(loader)/g' -e 's@=B@$(build_arch)@g' \
244 debian/control-scripts/extra-post > $(pkgdir_ex)/DEBIAN/$$script; \
245 chmod 755 $(pkgdir_ex)/DEBIAN/$$script; \
246 done; \
247 fi
248 endif
249
250 # Install the full changelog.
251 ifeq ($(do_doc_package),true)
252 install -d $(bindoc)
253 cat $(DEBIAN)/changelog $(DEBIAN)/changelog.historical | \
254 gzip -9 >$(bindoc)/changelog.Debian.old.gz
255 chmod 644 $(bindoc)/changelog.Debian.old.gz
256 endif
257
258 ifneq ($(skipsub),true)
259 for sub in $($(*)_sub); do \
260 if ! (TO=$$sub FROM=$* ABI_RELEASE=$(abi_release) $(SHELL) \
261 $(DROOT)/scripts/sub-flavour); then exit 1; fi; \
262 /sbin/depmod -b debian/$(bin_pkg_name)-$$sub \
263 -ea -F debian/$(bin_pkg_name)-$$sub/boot/System.map-$(abi_release)-$* \
264 $(abi_release)-$*; \
265 install -d debian/$(bin_pkg_name)-$$sub/DEBIAN; \
266 for script in postinst postrm preinst prerm; do \
267 sed -e 's/=V/$(abi_release)-$*/g' \
268 -e 's/=K/$(instfile)/g' \
269 -e 's/=L/$(loader)/g' \
270 -e 's@=B@$(build_arch)@g' \
271 $(DROOT)/control-scripts/$$script > \
272 debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\
273 chmod 755 debian/$(bin_pkg_name)-$$sub/DEBIAN/$$script;\
274 done; \
275 done
276 endif
277
278 ifneq ($(skipdbg),true)
279 # Debug image is simple
280 install -m644 -D $(builddir)/build-$*/vmlinux \
281 $(dbgpkgdir)/usr/lib/debug/boot/vmlinux-$(abi_release)-$*
282 $(build_cd) $(kmake) $(build_O) modules_install $(vdso) \
283 INSTALL_MOD_PATH=$(dbgpkgdir)/usr/lib/debug
284 # Add .gnu_debuglink sections to each stripped .ko
285 # pointing to unstripped verson
286 find $(pkgdir) -name '*.ko' | sed 's|$(pkgdir)||'| while read module ; do \
287 if [[ -f "$(dbgpkgdir)/usr/lib/debug/$$module" ]] ; then \
288 $(CROSS_COMPILE)objcopy \
289 --add-gnu-debuglink=$(dbgpkgdir)/usr/lib/debug/$$module \
290 $(pkgdir)/$$module; \
291 if grep -q CONFIG_MODULE_SIG=y $(builddir)/build-$*/.config; then \
292 $(builddir)/build-$*/scripts/sign-file $(MODHASHALGO) \
293 $(MODSECKEY) \
294 $(MODPUBKEY) \
295 $(pkgdir)/$$module; \
296 fi; \
297 fi; \
298 done
299 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/build
300 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/source
301 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/modules.*
302 rm -fr $(dbgpkgdir)/usr/lib/debug/lib/firmware
303 endif
304
305 # The flavour specific headers image
306 # TODO: Would be nice if we didn't have to dupe the original builddir
307 install -d -m755 $(hdrdir)
308 cat $(builddir)/build-$*/.config | \
309 sed -e 's/.*CONFIG_DEBUG_INFO=.*/# CONFIG_DEBUG_INFO is not set/g' > \
310 $(hdrdir)/.config
311 chmod 644 $(hdrdir)/.config
312 $(kmake) O=$(hdrdir) -j1 silentoldconfig prepare scripts
313 # We'll symlink this stuff
314 rm -f $(hdrdir)/Makefile
315 rm -rf $(hdrdir)/include2 $(hdrdir)/source
316 # Copy over the compilation version.
317 cp "$(builddir)/build-$*/include/generated/compile.h" \
318 "$(hdrdir)/include/generated/compile.h"
319 # Add UTS_UBUNTU_RELEASE_ABI since UTS_RELEASE is difficult to parse.
320 echo "#define UTS_UBUNTU_RELEASE_ABI $(abinum)" >> $(hdrdir)/include/generated/utsrelease.h
321 # powerpc kernel arch seems to need some .o files for external module linking. Add them in.
322 ifeq ($(build_arch),powerpc)
323 mkdir -p $(hdrdir)/arch/powerpc/lib
324 cp $(builddir)/build-$*/arch/powerpc/lib/*.o $(hdrdir)/arch/powerpc/lib
325 endif
326 # Script to symlink everything up
327 $(SHELL) $(DROOT)/scripts/link-headers "$(hdrdir)" "$(indeppkg)" "$*"
328 # The build symlink
329 install -d debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*
330 $(LN) /usr/src/$(basepkg)-$* \
331 debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*/build
332 # And finally the symvers
333 install -m644 $(builddir)/build-$*/Module.symvers \
334 $(hdrdir)/Module.symvers
335
336 # Now the header scripts
337 install -d $(CURDIR)/debian/$(basepkg)-$*/DEBIAN
338 for script in postinst; do \
339 sed -e 's/=V/$(abi_release)-$*/g' -e 's/=K/$(instfile)/g' \
340 $(DROOT)/control-scripts/headers-$$script > \
341 $(CURDIR)/debian/$(basepkg)-$*/DEBIAN/$$script; \
342 chmod 755 $(CURDIR)/debian/$(basepkg)-$*/DEBIAN/$$script; \
343 done
344
345 # At the end of the package prep, call the tests
346 DPKG_ARCH="$(arch)" KERN_ARCH="$(build_arch)" FLAVOUR="$*" \
347 VERSION="$(abi_release)" REVISION="$(revision)" \
348 PREV_REVISION="$(prev_revision)" ABI_NUM="$(abinum)" \
349 PREV_ABI_NUM="$(prev_abinum)" BUILD_DIR="$(builddir)/build-$*" \
350 INSTALL_DIR="$(pkgdir)" SOURCE_DIR="$(CURDIR)" \
351 run-parts -v $(DROOT)/tests-build
352
353 #
354 # Remove files which are generated at installation by postinst,
355 # except for modules.order and modules.builtin
356 #
357 # NOTE: need to keep this list in sync with postrm
358 #
359 mkdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
360 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.order \
361 $(pkgdir)/lib/modules/$(abi_release)-$*/_
362 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin ] ; then \
363 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin \
364 $(pkgdir)/lib/modules/$(abi_release)-$*/_; \
365 fi
366 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.*
367 mv $(pkgdir)/lib/modules/$(abi_release)-$*/_/* \
368 $(pkgdir)/lib/modules/$(abi_release)-$*
369 rmdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
370
371 ifeq ($(do_linux_tools),true)
372 # Create the linux-tools tool links
373 install -d $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
374 ifeq ($(do_tools_usbip),true)
375 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/usbip $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
376 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/usbipd $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
377 endif
378 ifeq ($(do_tools_cpupower),true)
379 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/cpupower $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
380 endif
381 ifeq ($(do_tools_perf),true)
382 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/perf $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
383 endif
384 ifeq ($(do_tools_x86),true)
385 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/x86_energy_perf_policy $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
386 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/turbostat $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
387 endif
388 endif
389 ifeq ($(do_cloud_tools),true)
390 ifeq ($(do_tools_hyperv),true)
391 # Create the linux-hyperv tool links
392 install -d $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
393 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_kvp_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
394 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_vss_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
395 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_fcopy_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
396 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/lsvmbus $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
397 endif
398 endif
399
400 headers_tmp := $(CURDIR)/debian/tmp-headers
401 headers_dir := $(CURDIR)/debian/linux-libc-dev
402
403 hmake := $(MAKE) -C $(CURDIR) O=$(headers_tmp) \
404 KERNELVERSION=$(abi_release) INSTALL_HDR_PATH=$(headers_tmp)/install \
405 SHELL="$(SHELL)" ARCH=$(header_arch)
406
407 install-arch-headers:
408 @echo Debug: $@
409 dh_testdir
410 dh_testroot
411 dh_clean -k -plinux-libc-dev
412
413 rm -rf $(headers_tmp)
414 install -d $(headers_tmp) $(headers_dir)/usr/include/
415
416 $(hmake) $(defconfig)
417 mv $(headers_tmp)/.config $(headers_tmp)/.config.old
418 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
419 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
420 $(headers_tmp)/.config.old > $(headers_tmp)/.config
421 $(hmake) silentoldconfig
422 $(hmake) headers_install
423
424 ( cd $(headers_tmp)/install/include/ && \
425 find . -name '.' -o -name '.*' -prune -o -print | \
426 cpio -pvd --preserve-modification-time \
427 $(headers_dir)/usr/include/ )
428 mkdir $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)
429 mv $(headers_dir)/usr/include/asm $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)/
430
431 rm -rf $(headers_tmp)
432
433 binary-arch-headers: install-arch-headers
434 @echo Debug: $@
435 dh_testdir
436 dh_testroot
437 ifeq ($(do_libc_dev_package),true)
438 ifneq ($(DEBIAN),debian.master)
439 echo "non-master branch building linux-libc-dev, aborting"
440 exit 1
441 endif
442 dh_installchangelogs -plinux-libc-dev
443 dh_installdocs -plinux-libc-dev
444 dh_compress -plinux-libc-dev
445 dh_fixperms -plinux-libc-dev
446 dh_installdeb -plinux-libc-dev
447 $(lockme) dh_gencontrol -plinux-libc-dev -- $(libc_dev_version)
448 dh_md5sums -plinux-libc-dev
449 dh_builddeb -plinux-libc-dev
450 endif
451
452 binary-%: pkgimg = $(bin_pkg_name)-$*
453 binary-%: pkgimg_ex = $(extra_pkg_name)-$*
454 binary-%: pkghdr = $(hdrs_pkg_name)-$*
455 binary-%: dbgpkg = $(bin_pkg_name)-$*-dbgsym
456 binary-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
457 binary-%: pkgtools = $(tools_flavour_pkg_name)-$*
458 binary-%: pkgcloud = $(cloud_flavour_pkg_name)-$*
459 binary-%: rprovides = $(if $(filter true,$(call custom_override,do_zfs,$*)),$(comma) spl-dkms$(comma) zfs-dkms)
460 binary-%: target_flavour = $*
461 binary-%: install-%
462 @echo Debug: $@
463 dh_testdir
464 dh_testroot
465
466 dh_installchangelogs -p$(pkgimg)
467 dh_installdocs -p$(pkgimg)
468 dh_compress -p$(pkgimg)
469 dh_fixperms -p$(pkgimg) -X/boot/
470 dh_installdeb -p$(pkgimg)
471 dh_shlibdeps -p$(pkgimg) $(shlibdeps_opts)
472 $(lockme) dh_gencontrol -p$(pkgimg) -- -Vlinux:rprovides='$(rprovides)'
473 dh_md5sums -p$(pkgimg)
474 dh_builddeb -p$(pkgimg) -- -Zbzip2 -z9
475
476 ifeq ($(do_extras_package),true)
477 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
478 dh_installchangelogs -p$(pkgimg_ex); \
479 dh_installdocs -p$(pkgimg_ex); \
480 dh_compress -p$(pkgimg_ex); \
481 dh_fixperms -p$(pkgimg_ex) -X/boot/; \
482 dh_installdeb -p$(pkgimg_ex); \
483 dh_shlibdeps -p$(pkgimg_ex) $(shlibdeps_opts); \
484 $(lockme) dh_gencontrol -p$(pkgimg_ex); \
485 dh_md5sums -p$(pkgimg_ex); \
486 dh_builddeb -p$(pkgimg_ex) -- -Zbzip2 -z9; \
487 fi
488 endif
489
490 dh_installchangelogs -p$(pkghdr)
491 dh_installdocs -p$(pkghdr)
492 dh_compress -p$(pkghdr)
493 dh_fixperms -p$(pkghdr)
494 dh_shlibdeps -p$(pkghdr) $(shlibdeps_opts)
495 dh_installdeb -p$(pkghdr)
496 $(lockme) dh_gencontrol -p$(pkghdr)
497 dh_md5sums -p$(pkghdr)
498 dh_builddeb -p$(pkghdr)
499
500 ifneq ($(skipsub),true)
501 @set -e; for sub in $($(*)_sub); do \
502 pkg=$(bin_pkg_name)-$$sub; \
503 dh_installchangelogs -p$$pkg; \
504 dh_installdocs -p$$pkg; \
505 dh_compress -p$$pkg; \
506 dh_fixperms -p$$pkg -X/boot/; \
507 dh_shlibdeps -p$$pkg $(shlibdeps_opts); \
508 dh_installdeb -p$$pkg; \
509 $(lockme) dh_gencontrol -p$$pkg; \
510 dh_md5sums -p$$pkg; \
511 dh_builddeb -p$$pkg; \
512 done
513 endif
514
515 ifneq ($(skipdbg),true)
516 dh_installchangelogs -p$(dbgpkg)
517 dh_installdocs -p$(dbgpkg)
518 dh_compress -p$(dbgpkg)
519 dh_fixperms -p$(dbgpkg)
520 dh_installdeb -p$(dbgpkg)
521 $(lockme) dh_gencontrol -p$(dbgpkg)
522 dh_md5sums -p$(dbgpkg)
523 dh_builddeb -p$(dbgpkg)
524
525 # Hokay...here's where we do a little twiddling...
526 # Renaming the debug package prevents it from getting into
527 # the primary archive, and therefore prevents this very large
528 # package from being mirrored. It is instead, through some
529 # archive admin hackery, copied to http://ddebs.ubuntu.com.
530 #
531 mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
532 ../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
533 set -e; \
534 ( \
535 $(lockme_cmd) 9 || exit 1; \
536 if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
537 sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
538 else \
539 grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
540 mv debian/files.new debian/files; \
541 fi; \
542 ) 9>$(lockme_file)
543 # Now, the package wont get into the archive, but it will get put
544 # into the debug system.
545 endif
546
547 ifeq ($(do_linux_tools),true)
548 dh_installchangelogs -p$(pkgtools)
549 dh_installdocs -p$(pkgtools)
550 dh_compress -p$(pkgtools)
551 dh_fixperms -p$(pkgtools)
552 dh_shlibdeps -p$(pkgtools) $(shlibdeps_opts)
553 dh_installdeb -p$(pkgtools)
554 $(lockme) dh_gencontrol -p$(pkgtools)
555 dh_md5sums -p$(pkgtools)
556 dh_builddeb -p$(pkgtools)
557 endif
558 ifeq ($(do_cloud_tools),true)
559 dh_installchangelogs -p$(pkgcloud)
560 dh_installdocs -p$(pkgcloud)
561 dh_compress -p$(pkgcloud)
562 dh_fixperms -p$(pkgcloud)
563 dh_shlibdeps -p$(pkgcloud) $(shlibdeps_opts)
564 dh_installdeb -p$(pkgcloud)
565 $(lockme) dh_gencontrol -p$(pkgcloud)
566 dh_md5sums -p$(pkgcloud)
567 dh_builddeb -p$(pkgcloud)
568 endif
569
570 ifneq ($(full_build),false)
571 # Clean out this flavours build directory.
572 rm -rf $(builddir)/build-$*
573 # Clean out the debugging package source directory.
574 rm -rf $(dbgpkgdir)
575 endif
576
577 #
578 # per-architecture packages
579 #
580 builddirpa = $(builddir)/tools-perarch
581
582 $(stampdir)/stamp-prepare-perarch:
583 @echo Debug: $@
584 ifeq ($(do_any_tools),true)
585 rm -rf $(builddirpa)
586 install -d $(builddirpa)
587 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) --exclude .git -a ./ $(builddirpa)/
588 endif
589 touch $@
590
591 $(stampdir)/stamp-build-perarch: $(stampdir)/stamp-prepare-perarch install-arch-headers
592 @echo Debug: $@
593 ifeq ($(do_linux_tools),true)
594 ifeq ($(do_tools_usbip),true)
595 chmod 755 $(builddirpa)/tools/usb/usbip/autogen.sh
596 cd $(builddirpa)/tools/usb/usbip && ./autogen.sh
597 chmod 755 $(builddirpa)/tools/usb/usbip/configure
598 cd $(builddirpa)/tools/usb/usbip && ./configure --prefix=$(builddirpa)/tools/usb/usbip/bin
599 cd $(builddirpa)/tools/usb/usbip && make install CFLAGS="-g -O2 -static" CROSS_COMPILE=$(CROSS_COMPILE)
600 endif
601 ifeq ($(do_tools_cpupower),true)
602 # Allow for multiple installed versions of cpupower and libcpupower.so:
603 # Override LIB_MIN in order to to generate a versioned .so named
604 # libcpupower.so.$(abi_release) and link cpupower with that.
605 make -C $(builddirpa)/tools/power/cpupower \
606 CROSS_COMPILE=$(CROSS_COMPILE) \
607 CROSS=$(CROSS_COMPILE) \
608 LIB_MIN=$(abi_release) CPUFREQ_BENCH=false
609 endif
610 ifeq ($(do_tools_perf),true)
611 cd $(builddirpa) && $(kmake) $(defconfig)
612 mv $(builddirpa)/.config $(builddirpa)/.config.old
613 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
614 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
615 $(builddirpa)/.config.old > $(builddirpa)/.config
616 cd $(builddirpa) && $(kmake) silentoldconfig
617 cd $(builddirpa) && $(kmake) prepare
618 cd $(builddirpa)/tools/perf && \
619 $(kmake) prefix=/usr HAVE_CPLUS_DEMANGLE=1 CROSS_COMPILE=$(CROSS_COMPILE) NO_LIBPYTHON=1 NO_LIBPERL=1 PYTHON=python2.7
620 endif
621 ifeq ($(do_tools_x86),true)
622 cd $(builddirpa)/tools/power/x86/x86_energy_perf_policy && make CROSS_COMPILE=$(CROSS_COMPILE)
623 cd $(builddirpa)/tools/power/x86/turbostat && make CROSS_COMPILE=$(CROSS_COMPILE)
624 endif
625 endif
626 ifeq ($(do_cloud_tools),true)
627 ifeq ($(do_tools_hyperv),true)
628 cd $(builddirpa)/tools/hv && make CFLAGS="-I$(headers_dir)/usr/include -I$(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)" CROSS_COMPILE=$(CROSS_COMPILE) hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
629 endif
630 endif
631 @touch $@
632
633 install-perarch: toolspkgdir = $(CURDIR)/debian/$(tools_pkg_name)
634 install-perarch: cloudpkgdir = $(CURDIR)/debian/$(cloud_pkg_name)
635 install-perarch: $(stampdir)/stamp-build-perarch
636 @echo Debug: $@
637 # Add the tools.
638 ifeq ($(do_linux_tools),true)
639 install -d $(toolspkgdir)/usr/lib
640 install -d $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
641 ifeq ($(do_tools_usbip),true)
642 install -m755 $(builddirpa)/tools/usb/usbip/bin/sbin/usbip \
643 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
644 install -m755 $(builddirpa)/tools/usb/usbip/bin/sbin/usbipd \
645 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
646 endif
647 ifeq ($(do_tools_cpupower),true)
648 install -m755 $(builddirpa)/tools/power/cpupower/cpupower \
649 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
650 # Install only the full versioned libcpupower.so.$(abi_release), not
651 # the usual symlinks to it.
652 install -m644 $(builddirpa)/tools/power/cpupower/libcpupower.so.$(abi_release) \
653 $(toolspkgdir)/usr/lib/
654 endif
655 ifeq ($(do_tools_perf),true)
656 install -m755 $(builddirpa)/tools/perf/perf $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
657 endif
658 ifeq ($(do_tools_x86),true)
659 install -m755 $(builddirpa)/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy \
660 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
661 install -m755 $(builddirpa)/tools/power/x86/turbostat/turbostat \
662 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
663 endif
664 endif
665 ifeq ($(do_cloud_tools),true)
666 ifeq ($(do_tools_hyperv),true)
667 install -d $(cloudpkgdir)/usr/lib
668 install -d $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
669 install -m755 $(builddirpa)/tools/hv/hv_kvp_daemon \
670 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
671 install -m755 $(builddirpa)/tools/hv/hv_vss_daemon \
672 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
673 install -m755 $(builddirpa)/tools/hv/hv_fcopy_daemon \
674 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
675 install -m755 $(builddirpa)/tools/hv/lsvmbus \
676 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
677 endif
678 endif
679
680 binary-perarch: toolspkg = $(tools_pkg_name)
681 binary-perarch: cloudpkg = $(cloud_pkg_name)
682 binary-perarch: install-perarch
683 @echo Debug: $@
684 ifeq ($(do_linux_tools),true)
685 dh_strip -p$(toolspkg)
686 dh_installchangelogs -p$(toolspkg)
687 dh_installdocs -p$(toolspkg)
688 dh_compress -p$(toolspkg)
689 dh_fixperms -p$(toolspkg)
690 dh_shlibdeps -p$(toolspkg) $(shlibdeps_opts)
691 dh_installdeb -p$(toolspkg)
692 $(lockme) dh_gencontrol -p$(toolspkg)
693 dh_md5sums -p$(toolspkg)
694 dh_builddeb -p$(toolspkg)
695 endif
696 ifeq ($(do_cloud_tools),true)
697 dh_strip -p$(cloudpkg)
698 dh_installchangelogs -p$(cloudpkg)
699 dh_installdocs -p$(cloudpkg)
700 dh_compress -p$(cloudpkg)
701 dh_fixperms -p$(cloudpkg)
702 dh_shlibdeps -p$(cloudpkg) $(shlibdeps_opts)
703 dh_installdeb -p$(cloudpkg)
704 $(lockme) dh_gencontrol -p$(cloudpkg)
705 dh_md5sums -p$(cloudpkg)
706 dh_builddeb -p$(cloudpkg)
707 endif
708
709 binary-debs: signed = $(CURDIR)/debian/$(bin_pkg_name)-signed
710 binary-debs: signedv = $(CURDIR)/debian/$(bin_pkg_name)-signed/$(release)-$(revision)
711 binary-debs: signed_tar = $(src_pkg_name)_$(release)-$(revision)_$(arch).tar.gz
712 binary-debs: binary-perarch $(addprefix binary-,$(flavours))
713 @echo Debug: $@
714 ifeq ($(uefi_signed),true)
715 echo $(release)-$(revision) > $(signedv)/version
716 cd $(signedv) && ls *.efi >flavours
717 cd $(signed) && tar czvf ../../../$(signed_tar) .
718 dpkg-distaddfile $(signed_tar) raw-uefi -
719 endif
720
721 build-arch-deps-$(do_flavour_image_package) += $(addprefix $(stampdir)/stamp-build-,$(flavours))
722 build-arch: $(build-arch-deps-true)
723 @echo Debug: $@
724
725 ifeq ($(AUTOBUILD),)
726 binary-arch-deps-$(do_flavour_image_package) += binary-udebs
727 else
728 binary-arch-deps-$(do_flavour_image_package) = binary-debs
729 endif
730 binary-arch-deps-$(do_libc_dev_package) += binary-arch-headers
731 ifneq ($(do_common_headers_indep),true)
732 binary-arch-deps-$(do_flavour_header_package) += binary-headers
733 endif
734 binary-arch: $(binary-arch-deps-true)
735 @echo Debug: $@
736