]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - debian/rules.d/2-binary-arch.mk
UBUNTU: [Packaging] initial packaging import from linux-unstable-5.12
[mirror_ubuntu-jammy-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 debian/scripts/fix-filenames: debian/scripts/fix-filenames.c
21 $(CC) -o $@ $^
22
23 $(stampdir)/stamp-prepare-%: config-prepare-check-%
24 @echo Debug: $@
25 @touch $@
26 $(stampdir)/stamp-prepare-tree-%: target_flavour = $*
27 $(stampdir)/stamp-prepare-tree-%: $(commonconfdir)/config.common.$(family) $(archconfdir)/config.common.$(arch) $(archconfdir)/config.flavour.% debian/scripts/fix-filenames
28 @echo Debug: $@
29 install -d $(builddir)/build-$*
30 touch $(builddir)/build-$*/ubuntu-build
31 [ "$(do_full_source)" != 'true' ] && true || \
32 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) * $(builddir)/build-$*
33 cat $(wordlist 1,3,$^) | sed -e 's/.*CONFIG_VERSION_SIGNATURE.*/CONFIG_VERSION_SIGNATURE="Ubuntu $(release)-$(revision)-$* $(raw_kernelversion)"/' > $(builddir)/build-$*/.config
34 find $(builddir)/build-$* -name "*.ko" | xargs rm -f
35 $(build_cd) $(kmake) $(build_O) -j1 syncconfig prepare scripts
36 touch $@
37
38 # Used by developers as a shortcut to prepare a tree for compilation.
39 prepare-%: $(stampdir)/stamp-prepare-%
40 @echo Debug: $@
41 # Used by developers to allow efficient pre-building without fakeroot.
42 build-%: $(stampdir)/stamp-build-%
43 @echo Debug: $@
44
45 # Do the actual build, including image and modules
46 $(stampdir)/stamp-build-%: target_flavour = $*
47 $(stampdir)/stamp-build-%: bldimg = $(call custom_override,build_image,$*)
48 $(stampdir)/stamp-build-%: $(stampdir)/stamp-prepare-%
49 @echo Debug: $@ build_image $(build_image) bldimg $(bldimg)
50 $(build_cd) $(kmake) $(build_O) $(conc_level) $(bldimg) modules $(if $(filter true,$(do_dtbs)),dtbs)
51
52 @touch $@
53
54 define build_dkms_sign =
55 $(shell set -x; if grep -q CONFIG_MODULE_SIG=y $(1)/.config; then
56 echo $(1)/scripts/sign-file $(MODHASHALGO) $(MODSECKEY) $(MODPUBKEY);
57 else
58 echo "-";
59 fi
60 )
61 endef
62 define build_dkms =
63 CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5)
64 endef
65
66 # nvidia_build_payload 450 450 450_450.102.04-0ubuntu0.20.04.1
67 # nvidia_build_payload 450-server 450srv 50.102.04-0ubuntu0.20.04.1
68 define nvidia_build_payload =
69 $(call build_dkms, $(bldinfo_pkg_name)-$*, $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/signatures, "", nvidia-$(2), pool/restricted/n/nvidia-graphics-drivers-$(1)/nvidia-kernel-source-$(1)_$(3)_$(arch).deb pool/restricted/n/nvidia-graphics-drivers-$(1)/nvidia-dkms-$(1)_$(3)_$(arch).deb)
70 endef
71 # nvidia_build 450
72 # nvidia_build 450-server
73 define nvidia_build =
74 $(call nvidia_build_payload,$(1),$(shell echo $(1) | sed -e 's/-server/srv/'),$(shell awk '/^nvidia-graphics-drivers-$(1) / {print($$2);}' debian/dkms-versions))
75
76 endef
77
78 define install_control =
79 for which in $(3); \
80 do \
81 template="$(DROOT)/templates/$(2).$$which.in"; \
82 script="$(DROOT)/$(1).$$which"; \
83 sed -e 's/@abiname@/$(abi_release)/g' \
84 -e 's/@localversion@/-$*/g' \
85 -e 's/@image-stem@/$(instfile)/g' \
86 <"$$template" >"$$script"; \
87 done
88 endef
89
90 # Ensure the directory prefix is exactly 100 characters long so pathnames are the
91 # exact same length in any binary files produced by the builds. These will be
92 # commonised later.
93 dkms_20d=....................
94 dkms_100d=$(dkms_20d)$(dkms_20d)$(dkms_20d)$(dkms_20d)$(dkms_20d)
95 dkms_100c=$(shell echo '$(dkms_100d)' | sed -e 's/\./_/g')
96 define dkms_dir_prefix =
97 $(shell echo $(1)/$(dkms_100c) | \
98 sed -e 's/\($(dkms_100d)\).*/\1/' -e 's/^\(.*\)....$$/\1dkms/')
99 endef
100
101 # Install the finished build
102 install-%: pkgdir_bin = $(CURDIR)/debian/$(bin_pkg_name)-$*
103 install-%: pkgdir = $(CURDIR)/debian/$(mods_pkg_name)-$*
104 install-%: pkgdir_ex = $(CURDIR)/debian/$(mods_extra_pkg_name)-$*
105 install-%: pkgdir_bldinfo = $(CURDIR)/debian/$(bldinfo_pkg_name)-$*
106 install-%: bindoc = $(pkgdir)/usr/share/doc/$(bin_pkg_name)-$*
107 install-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
108 install-%: signingv = $(CURDIR)/debian/$(bin_pkg_name)-signing/$(release)-$(revision)
109 install-%: toolspkgdir = $(CURDIR)/debian/$(tools_flavour_pkg_name)-$*
110 install-%: cloudpkgdir = $(CURDIR)/debian/$(cloud_flavour_pkg_name)-$*
111 install-%: basepkg = $(hdrs_pkg_name)
112 install-%: indeppkg = $(indep_hdrs_pkg_name)
113 install-%: kernfile = $(call custom_override,kernel_file,$*)
114 install-%: instfile = $(call custom_override,install_file,$*)
115 install-%: hdrdir = $(CURDIR)/debian/$(basepkg)-$*/usr/src/$(basepkg)-$*
116 install-%: target_flavour = $*
117 install-%: MODHASHALGO=sha512
118 install-%: MODSECKEY=$(builddir)/build-$*/certs/signing_key.pem
119 install-%: MODPUBKEY=$(builddir)/build-$*/certs/signing_key.x509
120 install-%: build_dir=$(builddir)/build-$*
121 install-%: dkms_dir=$(call dkms_dir_prefix,$(builddir)/build-$*)
122 install-%: enable_zfs = $(call custom_override,do_zfs,$*)
123 install-%: dbgpkgdir_zfs = $(if $(filter true,$(skipdbg)),"",$(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/kernel)
124 install-%: $(stampdir)/stamp-build-% install-headers
125 @echo Debug: $@ kernel_file $(kernel_file) kernfile $(kernfile) install_file $(install_file) instfile $(instfile)
126 dh_testdir
127 dh_testroot
128 dh_prep -p$(bin_pkg_name)-$*
129 dh_prep -p$(mods_pkg_name)-$*
130 dh_prep -p$(hdrs_pkg_name)-$*
131 ifneq ($(skipdbg),true)
132 dh_prep -p$(bin_pkg_name)-$*-dbgsym
133 endif
134
135 # The main image
136 # compress_file logic required because not all architectures
137 # generate a zImage automatically out of the box
138 ifeq ($(compress_file),)
139 install -m600 -D $(builddir)/build-$*/$(kernfile) \
140 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
141 else
142 install -d $(pkgdir_bin)/boot
143 gzip -c9v $(builddir)/build-$*/$(kernfile) > \
144 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
145 chmod 600 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
146 endif
147
148 ifeq ($(uefi_signed),true)
149 install -d $(signingv)
150 # gzipped kernel images must be decompressed for signing
151 if [[ "$(kernfile)" =~ \.gz$$ ]]; then \
152 < $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
153 gunzip -cv > $(signingv)/$(instfile)-$(abi_release)-$*.efi; \
154 cp -p --attributes-only $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
155 $(signingv)/$(instfile)-$(abi_release)-$*.efi; \
156 echo "GZIP=1" >> $(signingv)/$(instfile)-$(abi_release)-$*.efi.vars; \
157 else \
158 cp -p $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
159 $(signingv)/$(instfile)-$(abi_release)-$*.efi; \
160 fi
161 endif
162 ifeq ($(opal_signed),true)
163 install -d $(signingv)
164 cp -p $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
165 $(signingv)/$(instfile)-$(abi_release)-$*.opal;
166 endif
167 ifeq ($(sipl_signed),true)
168 install -d $(signingv)
169 cp -p $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$* \
170 $(signingv)/$(instfile)-$(abi_release)-$*.sipl;
171 endif
172
173 install -d $(pkgdir)/boot
174 install -m644 $(builddir)/build-$*/.config \
175 $(pkgdir)/boot/config-$(abi_release)-$*
176 install -m600 $(builddir)/build-$*/System.map \
177 $(pkgdir)/boot/System.map-$(abi_release)-$*
178
179 ifeq ($(do_dtbs),true)
180 $(build_cd) $(kmake) $(build_O) $(conc_level) dtbs_install \
181 INSTALL_DTBS_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*/device-tree
182 ifeq ($(disable_d_i),)
183 ( cd $(pkgdir)/lib/firmware/$(abi_release)-$*/ && find device-tree -print ) | \
184 while read dtb_file; do \
185 echo "$$dtb_file ?" >> $(DEBIAN)/d-i/firmware/$(arch)/kernel-image; \
186 done
187 endif
188 endif
189
190 ifeq ($(no_dumpfile),)
191 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
192 -x $(builddir)/build-$*/vmlinux
193 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
194 endif
195
196 $(build_cd) $(kmake) $(build_O) $(conc_level) modules_install $(vdso) \
197 INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(pkgdir)/ \
198 INSTALL_FW_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*
199
200 #
201 # Build module blacklists:
202 # - blacklist all watchdog drivers (LP:1432837)
203 #
204 install -d $(pkgdir)/lib/modprobe.d
205 echo "# Kernel supplied blacklist for $(src_pkg_name) $(abi_release)-$* $(arch)" \
206 >$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
207 for conf in $(arch)-$* $(arch) common.conf; do \
208 if [ -f $(DEBIAN)/modprobe.d/$$conf ]; then \
209 echo "# modprobe.d/$$conf"; \
210 cat $(DEBIAN)/modprobe.d/$$conf; \
211 fi; \
212 done >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
213 echo "# Autogenerated watchdog blacklist" \
214 >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
215 ls -1 $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/watchdog/ | \
216 grep -v '^bcm2835_wdt$$' | \
217 sed -e 's/^/blacklist /' -e 's/.ko$$//' | \
218 sort -u \
219 >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
220
221 ifeq ($(do_extras_package),true)
222 #
223 # Remove all modules not in the inclusion list.
224 #
225 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
226 /sbin/depmod -v -b $(pkgdir) $(abi_release)-$* | \
227 sed -e "s@$(pkgdir)/lib/modules/$(abi_release)-$*/kernel/@@g" | \
228 awk '{ print $$1 " " $$NF}' >$(build_dir)/module-inclusion.depmap; \
229 mkdir -p $(pkgdir_ex)/lib/modules/$(abi_release)-$*; \
230 mv $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
231 $(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel; \
232 $(SHELL) $(DROOT)/scripts/module-inclusion --master \
233 $(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel \
234 $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
235 $(DEBIAN)/control.d/$(target_flavour).inclusion-list \
236 $(build_dir)/module-inclusion.depmap 2>&1 | \
237 tee $(target_flavour).inclusion-list.log; \
238 /sbin/depmod -b $(pkgdir) -ea -F $(pkgdir)/boot/System.map-$(abi_release)-$* \
239 $(abi_release)-$* 2>&1 |tee $(target_flavour).depmod.log; \
240 if [ `grep -c 'unknown symbol' $(target_flavour).depmod.log` -gt 0 ]; then \
241 echo "EE: Unresolved module dependencies in base package!"; \
242 exit 1; \
243 fi \
244 fi
245 endif
246
247 ifeq ($(no_dumpfile),)
248 makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
249 -x $(builddir)/build-$*/vmlinux
250 chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
251 endif
252 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/build
253 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/source
254
255 # Some initramfs-tools specific modules
256 install -d $(pkgdir)/lib/modules/$(abi_release)-$*/initrd
257 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko ]; then\
258 $(LN) $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko \
259 $(pkgdir)/lib/modules/$(abi_release)-$*/initrd/; \
260 fi
261
262 echo "interest linux-update-$(abi_release)-$*" >"$(DROOT)/$(bin_pkg_name)-$*.triggers"
263 install -d $(pkgdir_bin)/usr/lib/linux/triggers
264 $(call install_control,$(bin_pkg_name)-$*,image,postinst postrm preinst prerm)
265 install -d $(pkgdir)/usr/lib/linux/triggers
266 $(call install_control,$(mods_pkg_name)-$*,extra,postinst postrm)
267 ifeq ($(do_extras_package),true)
268 # Install the postinit/postrm scripts in the extras package.
269 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
270 install -d $(pkgdir_ex)/usr/lib/linux/triggers; \
271 $(call install_control,$(mods_extra_pkg_name)-$*,extra,postinst postrm); \
272 fi
273 endif
274
275 # Install the full changelog.
276 ifeq ($(do_doc_package),true)
277 install -d $(bindoc)
278 cat $(DEBIAN)/changelog $(DEBIAN)/changelog.historical | \
279 gzip -9 >$(bindoc)/changelog.Debian.old.gz
280 chmod 644 $(bindoc)/changelog.Debian.old.gz
281 endif
282
283 ifneq ($(skipsub),true)
284 for sub in $($(*)_sub); do \
285 if ! (TO=$$sub FROM=$* ABI_RELEASE=$(abi_release) $(SHELL) \
286 $(DROOT)/scripts/sub-flavour); then exit 1; fi; \
287 /sbin/depmod -b debian/$(bin_pkg_name)-$$sub \
288 -ea -F debian/$(bin_pkg_name)-$$sub/boot/System.map-$(abi_release)-$* \
289 $(abi_release)-$*; \
290 $(call install_control,$(bin_pkg_name)--$$sub,image,postinst postrm preinst prerm); \
291 done
292 endif
293
294 ifneq ($(skipdbg),true)
295 # Debug image is simple
296 install -m644 -D $(builddir)/build-$*/vmlinux \
297 $(dbgpkgdir)/usr/lib/debug/boot/vmlinux-$(abi_release)-$*
298 $(build_cd) $(kmake) $(build_O) modules_install $(vdso) \
299 INSTALL_MOD_PATH=$(dbgpkgdir)/usr/lib/debug
300 # Add .gnu_debuglink sections only after all/DKMS modules are built.
301 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/build
302 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/source
303 rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/modules.*
304 rm -fr $(dbgpkgdir)/usr/lib/debug/lib/firmware
305 endif
306
307 # The flavour specific headers image
308 # TODO: Would be nice if we didn't have to dupe the original builddir
309 install -d -m755 $(hdrdir)
310 cp $(builddir)/build-$*/.config $(hdrdir)
311 chmod 644 $(hdrdir)/.config
312 $(kmake) O=$(hdrdir) -j1 syncconfig prepare scripts
313 # We'll symlink this stuff
314 rm -f $(hdrdir)/Makefile
315 rm -rf $(hdrdir)/include2 $(hdrdir)/source
316 # We do not need the retpoline information.
317 find $(hdrdir) -name \*.o.ur-\* | xargs rm -f
318 # Copy over the compilation version.
319 cp "$(builddir)/build-$*/include/generated/compile.h" \
320 "$(hdrdir)/include/generated/compile.h"
321 # Add UTS_UBUNTU_RELEASE_ABI since UTS_RELEASE is difficult to parse.
322 echo "#define UTS_UBUNTU_RELEASE_ABI $(abinum)" >> $(hdrdir)/include/generated/utsrelease.h
323 # powerpc kernel arch seems to need some .o files for external module linking. Add them in.
324 ifeq ($(build_arch),powerpc)
325 mkdir -p $(hdrdir)/arch/powerpc/lib
326 cp $(builddir)/build-$*/arch/powerpc/lib/*.o $(hdrdir)/arch/powerpc/lib
327 endif
328 # Copy over scripts/module.lds for building external modules
329 cp $(builddir)/build-$*/scripts/module.lds $(hdrdir)/scripts
330 # Copy over the new retpoline extractor.
331 cp scripts/ubuntu-retpoline-extract-one $(hdrdir)/scripts
332 # Script to symlink everything up
333 $(SHELL) $(DROOT)/scripts/link-headers "$(hdrdir)" "$(indeppkg)" "$*"
334 # The build symlink
335 install -d debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*
336 $(LN) /usr/src/$(basepkg)-$* \
337 debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*/build
338 # And finally the symvers
339 install -m644 $(builddir)/build-$*/Module.symvers \
340 $(hdrdir)/Module.symvers
341
342 # Now the header scripts
343 $(call install_control,$(hdrs_pkg_name)-$*,headers,postinst)
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 if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin.modinfo ] ; then \
367 mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin.modinfo \
368 $(pkgdir)/lib/modules/$(abi_release)-$*/_; \
369 fi
370 rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.*
371 mv $(pkgdir)/lib/modules/$(abi_release)-$*/_/* \
372 $(pkgdir)/lib/modules/$(abi_release)-$*
373 rmdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
374
375 ifeq ($(do_linux_tools),true)
376 # Create the linux-tools tool links
377 install -d $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
378 ifeq ($(do_tools_usbip),true)
379 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/usbip $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
380 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/usbipd $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
381 endif
382 ifeq ($(do_tools_acpidbg),true)
383 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/acpidbg $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
384 endif
385 ifeq ($(do_tools_cpupower),true)
386 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/cpupower $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
387 endif
388 ifeq ($(do_tools_perf),true)
389 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/perf $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
390 ifeq ($(do_tools_perf_jvmti),true)
391 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/libperf-jvmti.so $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
392 endif
393 endif
394 ifeq ($(do_tools_bpftool),true)
395 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/bpftool $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
396 endif
397 ifeq ($(do_tools_x86),true)
398 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/x86_energy_perf_policy $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
399 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/turbostat $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
400 endif
401 endif
402 ifeq ($(do_cloud_tools),true)
403 ifeq ($(do_tools_hyperv),true)
404 # Create the linux-hyperv tool links
405 install -d $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
406 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_kvp_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
407 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_vss_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
408 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_fcopy_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
409 $(LN) ../../$(src_pkg_name)-tools-$(abi_release)/lsvmbus $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
410 endif
411 endif
412
413 # Build a temporary "installed headers" directory.
414 install -d $(dkms_dir) $(dkms_dir)/headers $(dkms_dir)/build $(dkms_dir)/source
415 cp -rp "$(hdrdir)" "$(indep_hdrdir)" "$(dkms_dir)/headers"
416
417 $(if $(filter true,$(enable_zfs)),$(call build_dkms, $(mods_pkg_name)-$*, $(pkgdir)/lib/modules/$(abi_release)-$*/kernel, $(dbgpkgdir_zfs), zfs, pool/universe/z/zfs-linux/zfs-dkms_$(dkms_zfs_linux_version)_all.deb))
418
419 ifeq ($(do_dkms_nvidia),true)
420 $(foreach series,$(nvidia_desktop_series),$(call nvidia_build,$(series)))
421 endif
422 ifeq ($(do_dkms_nvidia_server),true)
423 $(foreach series,$(nvidia_server_series),$(call nvidia_build,$(series)))
424 endif
425
426 ifneq ($(skipdbg),true)
427 # Add .gnu_debuglink sections to each stripped .ko
428 # pointing to unstripped verson
429 find $(pkgdir) \
430 $(if $(filter true,$(do_extras_package)),$(pkgdir_ex)) \
431 -name '*.ko' | while read path_module ; do \
432 module="/lib/modules/$${path_module#*/lib/modules/}"; \
433 if [[ -f "$(dbgpkgdir)/usr/lib/debug/$$module" ]] ; then \
434 while IFS= read -r -d '' signature < <(tail -c 28 "$$path_module"); do \
435 break; \
436 done; \
437 $(CROSS_COMPILE)objcopy \
438 --add-gnu-debuglink=$(dbgpkgdir)/usr/lib/debug/$$module \
439 $$path_module; \
440 if grep -q CONFIG_MODULE_SIG=y $(builddir)/build-$*/.config && \
441 [ "$$signature" = $$'~Module signature appended~\n' ]; then \
442 $(builddir)/build-$*/scripts/sign-file $(MODHASHALGO) \
443 $(MODSECKEY) \
444 $(MODPUBKEY) \
445 $$path_module; \
446 fi; \
447 else \
448 echo "WARNING: Missing debug symbols for module '$$module'."; \
449 fi; \
450 done
451 endif
452
453 # Build the final ABI information.
454 install -d $(abidir)
455 sed -e 's/^\(.\+\)[[:space:]]\+\(.\+\)[[:space:]]\(.\+\)$$/\3 \2 \1/' \
456 $(builddir)/build-$*/Module.symvers | sort > $(abidir)/$*
457
458 # Build the final ABI modules information.
459 find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | \
460 sed -e 's/.*\/\([^\/]*\)\.ko/\1/' | sort > $(abidir)/$*.modules
461
462 # Build the final ABI firmware information.
463 find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | \
464 while read ko; do \
465 /sbin/modinfo $$ko | grep ^firmware || true; \
466 done | sort -u >$(abidir)/$*.fwinfo
467
468 # Build the final ABI compiler information.
469 ko=$$(find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | head -1); \
470 readelf -p .comment "$$ko" | gawk ' \
471 ($$1 == "[") { \
472 printf("%s", $$3); \
473 for (n=4; n<=NF; n++) { \
474 printf(" %s", $$n); \
475 } \
476 print "" \
477 }' | sort -u >$(abidir)/$*.compiler
478
479 # Build the final ABI retpoline information.
480 if grep -q CONFIG_RETPOLINE=y $(builddir)/build-$*/.config; then \
481 echo "# retpoline v1.0" >$(abidir)/$*.retpoline; \
482 $(SHELL) $(DROOT)/scripts/retpoline-extract $(builddir)/build-$* $(CURDIR) | \
483 sort >>$(abidir)/$*.retpoline; \
484 else \
485 echo "# RETPOLINE NOT ENABLED" >$(abidir)/$*.retpoline; \
486 fi
487
488 # Build the buildinfo package content.
489 install -d $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*
490 install -m644 $(builddir)/build-$*/.config \
491 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/config
492 install -m644 $(abidir)/$* \
493 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/abi
494 install -m644 $(abidir)/$*.modules \
495 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/modules
496 install -m644 $(abidir)/$*.fwinfo \
497 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/fwinfo
498 install -m644 $(abidir)/$*.retpoline \
499 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/retpoline
500 install -m644 $(abidir)/$*.compiler \
501 $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/compiler
502
503 ifneq ($(full_build),false)
504 # Clean out this flavours build directory.
505 rm -rf $(builddir)/build-$*
506 endif
507
508 headers_tmp := $(CURDIR)/debian/tmp-headers
509 headers_dir := $(CURDIR)/debian/linux-libc-dev
510
511 hmake := $(MAKE) -C $(CURDIR) O=$(headers_tmp) \
512 KERNELVERSION=$(abi_release) INSTALL_HDR_PATH=$(headers_tmp)/install \
513 SHELL="$(SHELL)" ARCH=$(header_arch)
514
515 install-arch-headers:
516 @echo Debug: $@
517 dh_testdir
518 dh_testroot
519 ifeq ($(do_libc_dev_package),true)
520 dh_prep -plinux-libc-dev
521 endif
522
523 rm -rf $(headers_tmp)
524 install -d $(headers_tmp) $(headers_dir)/usr/include/
525
526 $(hmake) $(defconfig)
527 mv $(headers_tmp)/.config $(headers_tmp)/.config.old
528 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
529 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
530 $(headers_tmp)/.config.old > $(headers_tmp)/.config
531 $(hmake) syncconfig
532 $(hmake) headers_install
533
534 ( cd $(headers_tmp)/install/include/ && \
535 find . -name '.' -o -name '.*' -prune -o -print | \
536 cpio -pvd --preserve-modification-time \
537 $(headers_dir)/usr/include/ )
538 mkdir $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)
539 mv $(headers_dir)/usr/include/asm $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)/
540
541 rm -rf $(headers_tmp)
542
543 define dh_all
544 dh_installchangelogs -p$(1)
545 dh_installdocs -p$(1)
546 dh_compress -p$(1)
547 dh_fixperms -p$(1) -X/boot/
548 dh_shlibdeps -p$(1) $(shlibdeps_opts)
549 dh_installdeb -p$(1)
550 dh_installdebconf -p$(1)
551 $(lockme) dh_gencontrol -p$(1) -- -Vlinux:rprovides='$(rprovides)'
552 dh_md5sums -p$(1)
553 dh_builddeb -p$(1)
554 endef
555 define newline
556
557
558 endef
559 define dh_all_inline
560 $(subst ${newline},; \${newline},$(call dh_all,$(1)))
561 endef
562
563 binary-arch-headers: install-arch-headers
564 @echo Debug: $@
565 dh_testdir
566 dh_testroot
567 ifeq ($(do_libc_dev_package),true)
568 ifeq ($(filter debian.master%,$(DEBIAN)),)
569 echo "non-master branch building linux-libc-dev, aborting"
570 exit 1
571 endif
572 $(call dh_all,linux-libc-dev)
573 endif
574
575 binary-%: pkgimg = $(bin_pkg_name)-$*
576 binary-%: pkgimg_mods = $(mods_pkg_name)-$*
577 binary-%: pkgimg_ex = $(mods_extra_pkg_name)-$*
578 binary-%: pkgdir_ex = $(CURDIR)/debian/$(extra_pkg_name)-$*
579 binary-%: pkgbldinfo = $(bldinfo_pkg_name)-$*
580 binary-%: pkghdr = $(hdrs_pkg_name)-$*
581 binary-%: dbgpkg = $(bin_pkg_name)-$*-dbgsym
582 binary-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
583 binary-%: pkgtools = $(tools_flavour_pkg_name)-$*
584 binary-%: pkgcloud = $(cloud_flavour_pkg_name)-$*
585 binary-%: rprovides = $(if $(filter true,$(call custom_override,do_zfs,$*)),spl-modules$(comma) spl-dkms$(comma) zfs-modules$(comma) zfs-dkms$(comma))
586 binary-%: target_flavour = $*
587 binary-%: checks-%
588 @echo Debug: $@
589 dh_testdir
590 dh_testroot
591
592 $(call dh_all,$(pkgimg))
593 $(call dh_all,$(pkgimg_mods))
594
595 ifeq ($(do_extras_package),true)
596 ifeq ($(ship_extras_package),false)
597 # If $(ship_extras_package) is explicitly set to false, then do not
598 # construct the linux-image-extra package; instead just log all of the
599 # "extra" modules which were pointlessly built yet won't be shipped.
600 find $(pkgdir_ex) -name '*.ko' | sort \
601 | sed 's|^$(pkgdir_ex)/|NOT-SHIPPED |' \
602 | tee -a $(target_flavour).not-shipped.log;
603 else
604 if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
605 $(call dh_all_inline,$(pkgimg_ex)); \
606 fi
607 endif
608 endif
609
610 $(call dh_all,$(pkgbldinfo))
611 $(call dh_all,$(pkghdr))
612
613 ifneq ($(skipsub),true)
614 @set -e; for sub in $($(*)_sub); do \
615 pkg=$(bin_pkg_name)-$$sub; \
616 $(call dh_all_inline,$$pkg); \
617 done
618 endif
619
620 ifneq ($(skipdbg),true)
621 $(call dh_all,$(dbgpkg))
622
623 # Hokay...here's where we do a little twiddling...
624 # Renaming the debug package prevents it from getting into
625 # the primary archive, and therefore prevents this very large
626 # package from being mirrored. It is instead, through some
627 # archive admin hackery, copied to http://ddebs.ubuntu.com.
628 #
629 mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
630 ../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
631 set -e; \
632 ( \
633 $(lockme_cmd) 9 || exit 1; \
634 if grep -qs '^Build-Debug-Symbols: yes$$' /CurrentlyBuilding; then \
635 sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files; \
636 else \
637 grep -v '^$(dbgpkg)_.*$$' debian/files > debian/files.new; \
638 mv debian/files.new debian/files; \
639 fi; \
640 ) 9>$(lockme_file)
641 # Now, the package wont get into the archive, but it will get put
642 # into the debug system.
643 endif
644
645 ifeq ($(do_linux_tools),true)
646 $(call dh_all,$(pkgtools))
647 endif
648 ifeq ($(do_cloud_tools),true)
649 $(call dh_all,$(pkgcloud))
650 endif
651
652 ifneq ($(full_build),false)
653 # Clean out the debugging package source directory.
654 rm -rf $(dbgpkgdir)
655 endif
656
657 #
658 # per-architecture packages
659 #
660 builddirpa = $(builddir)/tools-perarch
661
662 $(stampdir)/stamp-prepare-perarch:
663 @echo Debug: $@
664 ifeq ($(do_any_tools),true)
665 rm -rf $(builddirpa)
666 install -d $(builddirpa)
667 rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) --exclude .git -a ./ $(builddirpa)/
668 endif
669 touch $@
670
671 $(stampdir)/stamp-build-perarch: $(stampdir)/stamp-prepare-perarch install-arch-headers
672 @echo Debug: $@
673 ifeq ($(do_linux_tools),true)
674 ifeq ($(do_tools_usbip),true)
675 chmod 755 $(builddirpa)/tools/usb/usbip/autogen.sh
676 cd $(builddirpa)/tools/usb/usbip && ./autogen.sh
677 chmod 755 $(builddirpa)/tools/usb/usbip/configure
678 cd $(builddirpa)/tools/usb/usbip && ./configure --prefix=$(builddirpa)/tools/usb/usbip/bin
679 cd $(builddirpa)/tools/usb/usbip && make install CFLAGS="-g -O2 -static" CROSS_COMPILE=$(CROSS_COMPILE)
680 endif
681 ifeq ($(do_tools_acpidbg),true)
682 cd $(builddirpa)/tools/power/acpi && make clean && make CFLAGS="-g -O2 -static -I$(builddirpa)/include" CROSS_COMPILE=$(CROSS_COMPILE) acpidbg
683 endif
684 ifeq ($(do_tools_cpupower),true)
685 # Allow for multiple installed versions of cpupower and libcpupower.so:
686 # Override LIB_MIN in order to to generate a versioned .so named
687 # libcpupower.so.$(abi_release) and link cpupower with that.
688 make -C $(builddirpa)/tools/power/cpupower \
689 CROSS_COMPILE=$(CROSS_COMPILE) \
690 CROSS=$(CROSS_COMPILE) \
691 LIB_MIN=$(abi_release) CPUFREQ_BENCH=false
692 endif
693 ifeq ($(do_tools_perf),true)
694 cd $(builddirpa) && $(kmake) $(defconfig)
695 mv $(builddirpa)/.config $(builddirpa)/.config.old
696 sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
697 -e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
698 $(builddirpa)/.config.old > $(builddirpa)/.config
699 cd $(builddirpa) && $(kmake) syncconfig
700 cd $(builddirpa) && $(kmake) prepare
701 cd $(builddirpa)/tools/perf && \
702 $(kmake) prefix=/usr HAVE_NO_LIBBFD=1 HAVE_CPLUS_DEMANGLE_SUPPORT=1 CROSS_COMPILE=$(CROSS_COMPILE) NO_LIBPYTHON=1 NO_LIBPERL=1 WERROR=0
703 endif
704 ifeq ($(do_tools_bpftool),true)
705 $(kmake) CROSS_COMPILE=$(CROSS_COMPILE) -C $(builddirpa)/tools/bpf/bpftool
706 endif
707 ifeq ($(do_tools_x86),true)
708 cd $(builddirpa)/tools/power/x86/x86_energy_perf_policy && make CROSS_COMPILE=$(CROSS_COMPILE)
709 cd $(builddirpa)/tools/power/x86/turbostat && make CROSS_COMPILE=$(CROSS_COMPILE)
710 endif
711 endif
712 ifeq ($(do_cloud_tools),true)
713 ifeq ($(do_tools_hyperv),true)
714 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
715 endif
716 endif
717 @touch $@
718
719 install-perarch: toolspkgdir = $(CURDIR)/debian/$(tools_pkg_name)
720 install-perarch: cloudpkgdir = $(CURDIR)/debian/$(cloud_pkg_name)
721 install-perarch: $(stampdir)/stamp-build-perarch
722 @echo Debug: $@
723 # Add the tools.
724 ifeq ($(do_linux_tools),true)
725 install -d $(toolspkgdir)/usr/lib
726 install -d $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
727 ifeq ($(do_tools_usbip),true)
728 install -m755 $(builddirpa)/tools/usb/usbip/bin/sbin/usbip \
729 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
730 install -m755 $(builddirpa)/tools/usb/usbip/bin/sbin/usbipd \
731 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
732 endif
733 ifeq ($(do_tools_acpidbg),true)
734 install -m755 $(builddirpa)/tools/power/acpi/acpidbg \
735 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
736 endif
737 ifeq ($(do_tools_cpupower),true)
738 install -m755 $(builddirpa)/tools/power/cpupower/cpupower \
739 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
740 # Install only the full versioned libcpupower.so.$(abi_release), not
741 # the usual symlinks to it.
742 install -m644 $(builddirpa)/tools/power/cpupower/libcpupower.so.$(abi_release) \
743 $(toolspkgdir)/usr/lib/
744 endif
745 ifeq ($(do_tools_perf),true)
746 install -m755 $(builddirpa)/tools/perf/perf $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
747 ifeq ($(do_tools_perf_jvmti),true)
748 install -m755 $(builddirpa)/tools/perf/libperf-jvmti.so $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
749 endif
750 endif
751 ifeq ($(do_tools_bpftool),true)
752 install -m755 $(builddirpa)/tools/bpf/bpftool/bpftool $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
753 endif
754 ifeq ($(do_tools_x86),true)
755 install -m755 $(builddirpa)/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy \
756 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
757 install -m755 $(builddirpa)/tools/power/x86/turbostat/turbostat \
758 $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
759 endif
760 endif
761 ifeq ($(do_cloud_tools),true)
762 ifeq ($(do_tools_hyperv),true)
763 install -d $(cloudpkgdir)/usr/lib
764 install -d $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
765 install -m755 $(builddirpa)/tools/hv/hv_kvp_daemon \
766 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
767 install -m755 $(builddirpa)/tools/hv/hv_vss_daemon \
768 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
769 install -m755 $(builddirpa)/tools/hv/hv_fcopy_daemon \
770 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
771 install -m755 $(builddirpa)/tools/hv/lsvmbus \
772 $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
773 endif
774 endif
775
776 binary-perarch: toolspkg = $(tools_pkg_name)
777 binary-perarch: cloudpkg = $(cloud_pkg_name)
778 binary-perarch: install-perarch
779 @echo Debug: $@
780 ifeq ($(do_linux_tools),true)
781 $(call dh_all,$(toolspkg))
782 endif
783 ifeq ($(do_cloud_tools),true)
784 $(call dh_all,$(cloudpkg))
785 endif
786
787 binary-debs: signing = $(CURDIR)/debian/$(bin_pkg_name)-signing
788 binary-debs: signingv = $(CURDIR)/debian/$(bin_pkg_name)-signing/$(release)-$(revision)
789 binary-debs: signing_tar = $(src_pkg_name)_$(release)-$(revision)_$(arch).tar.gz
790 binary-debs: binary-perarch $(addprefix binary-,$(flavours))
791 @echo Debug: $@
792 ifeq ($(any_signed),true)
793 install -d $(signingv)/control
794 { echo "tarball"; } >$(signingv)/control/options
795 cd $(signing) && tar czvf ../../../$(signing_tar) .
796 dpkg-distaddfile $(signing_tar) raw-signing -
797 endif
798
799 build-arch-deps-$(do_flavour_image_package) += $(addprefix $(stampdir)/stamp-build-,$(flavours))
800 build-arch: $(build-arch-deps-true)
801 @echo Debug: $@
802
803 ifeq ($(AUTOBUILD),)
804 binary-arch-deps-$(do_flavour_image_package) += binary-udebs
805 else
806 binary-arch-deps-$(do_flavour_image_package) = binary-debs
807 endif
808 binary-arch-deps-$(do_libc_dev_package) += binary-arch-headers
809 ifneq ($(do_common_headers_indep),true)
810 binary-arch-deps-$(do_flavour_header_package) += binary-headers
811 endif
812 binary-arch: $(binary-arch-deps-true)
813 @echo Debug: $@
814