-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path2-binary-arch.mk
More file actions
771 lines (705 loc) · 31.5 KB
/
2-binary-arch.mk
File metadata and controls
771 lines (705 loc) · 31.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
# We don't want make removing intermediary stamps
.SECONDARY :
# TODO this is probably wrong, and should be using $(DEB_HOST_MULTIARCH)
shlibdeps_opts = $(if $(CROSS_COMPILE),-- -l$(CROSS_COMPILE:%-=/usr/%)/lib)
debian/scripts/fix-filenames: debian/scripts/fix-filenames.c
$(HOSTCC) $^ -o $@
$(stampdir)/stamp-prepare-%: $(stampdir)/stamp-prepare-tree-%
@echo Debug: $@
$(stamp)
$(stampdir)/stamp-prepare-tree-%: target_flavour = $*
$(stampdir)/stamp-prepare-tree-%: debian/scripts/fix-filenames
@echo Debug: $@
install -d $(builddir)/build-$*
touch $(builddir)/build-$*/ubuntu-build
python3 debian/scripts/misc/annotations --export --arch $(arch) --flavour $(target_flavour) > $(builddir)/build-$*/.config
sed -i 's/.*CONFIG_VERSION_SIGNATURE.*/CONFIG_VERSION_SIGNATURE="Ubuntu $(release)-$(revision)-$* $(raw_kernelversion)"/' $(builddir)/build-$*/.config
find $(builddir)/build-$* -name "*.ko" | xargs rm -f
$(kmake) O=$(builddir)/build-$* $(conc_level) rustavailable || true
$(kmake) O=$(builddir)/build-$* $(conc_level) olddefconfig
$(stamp)
# Used by developers as a shortcut to prepare a tree for compilation.
prepare-%: $(stampdir)/stamp-prepare-%
@echo Debug: $@
# Used by developers to allow efficient pre-building without fakeroot.
build-%: $(stampdir)/stamp-install-%
@echo Debug: $@
# Do the actual build, including image and modules
$(stampdir)/stamp-build-%: target_flavour = $*
$(stampdir)/stamp-build-%: bldimg = $(call custom_override,build_image,$*)
$(stampdir)/stamp-build-%: $(stampdir)/stamp-prepare-%
@echo Debug: $@ build_image $(build_image) bldimg $(bldimg)
$(kmake) O=$(builddir)/build-$* $(conc_level) $(bldimg) modules $(if $(filter true,$(do_dtbs)),dtbs)
ifeq ($(do_dbgsym_package),true)
# The target scripts_gdb is part of "all", so we need to call it manually
if grep -q CONFIG_GDB_SCRIPTS=y $(builddir)/build-$*/.config; then \
$(kmake) O=$(builddir)/build-$* $(conc_level) scripts_gdb ; \
fi
endif
$(stamp)
define build_dkms_sign =
$(shell set -x; if grep -q CONFIG_MODULE_SIG=y $(1)/.config; then
echo $(1)/scripts/sign-file $(MODHASHALGO) $(MODSECKEY) $(MODPUBKEY);
else
echo "-";
fi
)
endef
define build_dkms =
rc=0; unset MAKEFLAGS; ARCH=$(build_arch) CROSS_COMPILE=$(CROSS_COMPILE) $(SHELL) $(DROOT)/scripts/dkms-build $(dkms_dir) $(abi_release)-$* '$(call build_dkms_sign,$(builddir)/build-$*)' $(1) $(2) $(3) $(4) $(5) || rc=$$?; if [ "$$rc" = "9" -o "$$rc" = "77" ]; then echo do_$(4)_$*=false >> $(builddir)/skipped-dkms.mk; rc=0; fi; if [ "$$rc" != "0" ]; then exit $$rc; fi
endef
define install_control =
for which in $(3); \
do \
template="$(DROOT)/templates/$(2).$$which.in"; \
script="$(DROOT)/$(1).$$which"; \
sed -e 's/@abiname@/$(abi_release)/g' \
-e 's/@localversion@/-$*/g' \
-e 's/@image-stem@/$(instfile)/g' \
<"$$template" >"$$script"; \
done
endef
# Ensure the directory prefix is exactly 140 characters long so pathnames are the
# exact same length in any binary files produced by the builds. These will be
# commonised later.
dkms_20d=....................
dkms_140d=$(dkms_20d)$(dkms_20d)$(dkms_20d)$(dkms_20d)$(dkms_20d)$(dkms_20d)$(dkms_20d)
dkms_140c=$(shell echo '$(dkms_140d)' | sed -e 's/\./_/g')
define dkms_dir_prefix =
$(shell echo $(1)/$(dkms_140c) | \
sed -e 's/\($(dkms_140d)\).*/\1/' -e 's/^\(.*\)....$$/\1dkms/')
endef
# Install the finished build
$(stampdir)/stamp-install-%: pkgdir_bin = $(CURDIR)/debian/$(bin_pkg_name)-$*
$(stampdir)/stamp-install-%: pkgdir = $(CURDIR)/debian/$(mods_pkg_name)-$*
$(stampdir)/stamp-install-%: pkgdir_ex = $(CURDIR)/debian/$(mods_extra_pkg_name)-$*
$(stampdir)/stamp-install-%: pkgdir_bldinfo = $(CURDIR)/debian/$(bldinfo_pkg_name)-$*
$(stampdir)/stamp-install-%: bindoc = $(pkgdir)/usr/share/doc/$(bin_pkg_name)-$*
$(stampdir)/stamp-install-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
$(stampdir)/stamp-install-%: signingv = $(CURDIR)/debian/$(bin_pkg_name)-signing/$(release)-$(revision)
$(stampdir)/stamp-install-%: toolspkgdir = $(CURDIR)/debian/$(tools_flavour_pkg_name)-$*
$(stampdir)/stamp-install-%: cloudpkgdir = $(CURDIR)/debian/$(cloud_flavour_pkg_name)-$*
$(stampdir)/stamp-install-%: basepkg = $(hdrs_pkg_name)
$(stampdir)/stamp-install-%: baserustpkg = $(rust_pkg_name)
$(stampdir)/stamp-install-%: indeppkg = $(indep_hdrs_pkg_name)
$(stampdir)/stamp-install-%: kernfile = $(call custom_override,kernel_file,$*)
$(stampdir)/stamp-install-%: instfile = $(call custom_override,install_file,$*)
$(stampdir)/stamp-install-%: hdrdir = $(CURDIR)/debian/$(basepkg)-$*/usr/src/$(basepkg)-$*
$(stampdir)/stamp-install-%: rustdir = $(CURDIR)/debian/$(baserustpkg)-$*/usr/src/$(baserustpkg)-$*
$(stampdir)/stamp-install-%: target_flavour = $*
$(stampdir)/stamp-install-%: MODHASHALGO=sha512
$(stampdir)/stamp-install-%: MODSECKEY=$(builddir)/build-$*/certs/signing_key.pem
$(stampdir)/stamp-install-%: MODPUBKEY=$(builddir)/build-$*/certs/signing_key.x509
$(stampdir)/stamp-install-%: build_dir=$(builddir)/build-$*
$(stampdir)/stamp-install-%: dkms_dir=$(call dkms_dir_prefix,$(builddir)/build-$*)
$(foreach _m,$(all_dkms_modules), \
$(eval $$(stampdir)/stamp-install-%: enable_$(_m) = $$(filter true,$$(call custom_override,do_$(_m),$$*))) \
$(eval $$(stampdir)/stamp-install-%: dkms_$(_m)_pkgdir = $$(CURDIR)/debian/$(dkms_$(_m)_pkg_name)-$$*) \
)
$(stampdir)/stamp-install-%: dbgpkgdir_dkms = $(if $(filter true,$(do_dbgsym_package)),$(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/kernel,"")
$(stampdir)/stamp-install-%: $(stampdir)/stamp-build-% $(stampdir)/stamp-install-headers
@echo Debug: $@ kernel_file $(kernel_file) kernfile $(kernfile) install_file $(install_file) instfile $(instfile)
dh_testdir
dh_prep -p$(bin_pkg_name)-$*
dh_prep -p$(mods_pkg_name)-$*
dh_prep -p$(hdrs_pkg_name)-$*
ifeq ($(do_lib_rust),true)
dh_prep -p$(rust_pkg_name)-$*
endif
$(foreach _m,$(all_standalone_dkms_modules), \
$(if $(enable_$(_m)),dh_prep -p$(dkms_$(_m)_pkg_name)-$*;)\
)
ifeq ($(do_dbgsym_package),true)
dh_prep -p$(bin_pkg_name)-$*-dbgsym
endif
ifeq ($(do_extras_package),true)
dh_prep -p$(mods_extra_pkg_name)-$*
endif
# The main image
# compress_file logic required because not all architectures
# generate a zImage automatically out of the box
ifeq ($(compress_file),)
install -m600 -D $(builddir)/build-$*/$(kernfile) \
$(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
else
install -d $(pkgdir_bin)/boot
gzip -c9v $(builddir)/build-$*/$(kernfile) > \
$(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
chmod 600 $(pkgdir_bin)/boot/$(instfile)-$(abi_release)-$*
endif
install -d $(pkgdir)/boot
install -m644 $(builddir)/build-$*/.config \
$(pkgdir)/boot/config-$(abi_release)-$*
install -m600 $(builddir)/build-$*/System.map \
$(pkgdir)/boot/System.map-$(abi_release)-$*
ifeq ($(do_dtbs),true)
$(kmake) O=$(builddir)/build-$* $(conc_level) dtbs_install \
INSTALL_DTBS_PATH=$(pkgdir)/lib/firmware/$(abi_release)-$*/device-tree
endif
ifeq ($(no_dumpfile),)
makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
-x $(builddir)/build-$*/vmlinux
chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
endif
$(kmake) O=$(builddir)/build-$* $(conc_level) modules_install $(vdso) \
INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=$(pkgdir)
#
# Build module blacklists:
# - blacklist all watchdog drivers (LP:1432837)
#
install -d $(pkgdir)/lib/modprobe.d
echo "# Kernel supplied blacklist for $(src_pkg_name) $(abi_release)-$* $(arch)" \
>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
for conf in $(arch)-$* $(arch) common.conf; do \
if [ -f $(DEBIAN)/modprobe.d/$$conf ]; then \
echo "# modprobe.d/$$conf"; \
cat $(DEBIAN)/modprobe.d/$$conf; \
fi; \
done >>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
echo "# Autogenerated watchdog blacklist" \
>>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
ls -1 $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/watchdog/ | \
grep -v '^bcm2835_wdt$$' | \
sed -e 's/^/blacklist /' -e 's/.ko$$//' | \
sort -u \
>>$(pkgdir)/lib/modprobe.d/blacklist_$(src_pkg_name)_$(abi_release)-$*.conf
ifeq ($(do_extras_package),true)
#
# Remove all modules not in the inclusion list.
#
if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
/sbin/depmod -v -b $(pkgdir) $(abi_release)-$* | \
sed -e "s@$(pkgdir)/lib/modules/$(abi_release)-$*/kernel/@@g" | \
awk '{ print $$1 " " $$NF}' >$(build_dir)/module-inclusion.depmap; \
mkdir -p $(pkgdir_ex)/lib/modules/$(abi_release)-$*; \
mv $(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
$(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel; \
$(SHELL) $(DROOT)/scripts/module-inclusion --master \
$(pkgdir_ex)/lib/modules/$(abi_release)-$*/kernel \
$(pkgdir)/lib/modules/$(abi_release)-$*/kernel \
$(DEBIAN)/control.d/$(target_flavour).inclusion-list \
$(build_dir)/module-inclusion.depmap 2>&1 | \
tee $(target_flavour).inclusion-list.log; \
/sbin/depmod -b $(pkgdir) -ea -F $(pkgdir)/boot/System.map-$(abi_release)-$* \
$(abi_release)-$* 2>&1 |tee $(target_flavour).depmod.log; \
if [ `grep -c 'unknown symbol' $(target_flavour).depmod.log` -gt 0 ]; then \
echo "EE: Unresolved module dependencies in base package!"; \
exit 1; \
fi \
fi
endif
ifeq ($(no_dumpfile),)
makedumpfile -g $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$* \
-x $(builddir)/build-$*/vmlinux
chmod 0600 $(pkgdir)/boot/vmcoreinfo-$(abi_release)-$*
endif
rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/build
rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/source
# Some initramfs-tools specific modules
install -d $(pkgdir)/lib/modules/$(abi_release)-$*/initrd
if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko ]; then\
$(LN) $(pkgdir)/lib/modules/$(abi_release)-$*/kernel/drivers/video/vesafb.ko \
$(pkgdir)/lib/modules/$(abi_release)-$*/initrd/; \
fi
echo "interest linux-update-$(abi_release)-$*" >"$(DROOT)/$(bin_pkg_name)-$*.triggers"
install -d $(pkgdir_bin)/usr/lib/linux/triggers
$(call install_control,$(bin_pkg_name)-$*,image,postinst postrm preinst prerm)
install -d $(pkgdir)/usr/lib/linux/triggers
$(call install_control,$(mods_pkg_name)-$*,extra,postinst postrm)
ifeq ($(do_extras_package),true)
# Install the postinit/postrm scripts in the extras package.
if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
install -d $(pkgdir_ex)/usr/lib/linux/triggers; \
$(call install_control,$(mods_extra_pkg_name)-$*,extra,postinst postrm); \
fi
endif
$(foreach _m,$(all_standalone_dkms_modules), \
$(if $(enable_$(_m)), \
install -d $(dkms_$(_m)_pkgdir)/usr/lib/linux/triggers; \
$(call install_control,$(dkms_$(_m)_pkg_name)-$*,extra,postinst postrm); \
) \
)
ifeq ($(do_dbgsym_package),true)
# Debug image is simple
install -m644 -D $(builddir)/build-$*/vmlinux \
$(dbgpkgdir)/usr/lib/debug/boot/vmlinux-$(abi_release)-$*
if [ -d $(builddir)/build-$*/scripts/gdb/linux ]; then \
install -m644 -D $(builddir)/build-$*/vmlinux-gdb.py \
$(dbgpkgdir)/usr/share/gdb/auto-load/boot/vmlinux-$(abi_release)-$*/vmlinuz-$(abi_release)-$*-gdb.py; \
install -m644 -D $(builddir)/build-$*/scripts/gdb/linux/* \
--target-directory=$(dbgpkgdir)/usr/share/gdb/auto-load/boot/vmlinux-$(abi_release)-$*/scripts/gdb/linux; \
fi
$(kmake) O=$(builddir)/build-$* modules_install $(vdso) \
INSTALL_MOD_PATH=$(dbgpkgdir)/usr/lib/debug
# Add .gnu_debuglink sections only after all/DKMS modules are built.
rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/build
rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/source
rm -f $(dbgpkgdir)/usr/lib/debug/lib/modules/$(abi_release)-$*/modules.*
rm -fr $(dbgpkgdir)/usr/lib/debug/lib/firmware
endif
ifeq ($(do_tools_bpftool),true)
cp $(builddir)/build-$*/vmlinux tools/bpf/bpftool/
endif
# The flavour specific headers image
# TODO: Would be nice if we didn't have to dupe the original builddir
install -d -m755 $(hdrdir)
cp $(builddir)/build-$*/.config $(hdrdir)
chmod 644 $(hdrdir)/.config
$(kmake) O=$(hdrdir) -j1 syncconfig prepare scripts
# Makefile may need per-arch-flavour CC settings, which are
# normally set via $(kmake) during build
rm -f $(hdrdir)/Makefile
cp -a $(indep_hdrdir)/Makefile $(hdrdir)/Makefile
sed -i 's|\(^HOSTCC = \)gcc$$|\1$(gcc)|' $(hdrdir)/Makefile
sed -i 's|\(^CC = $$(CROSS_COMPILE)\)gcc$$|\1$(gcc)|' $(hdrdir)/Makefile
# Quick check for successful substitutions
grep '^HOSTCC .*$(gcc)$$' $(hdrdir)/Makefile
grep '^CC .*$(gcc)$$' $(hdrdir)/Makefile
rm -rf $(hdrdir)/include2 $(hdrdir)/source
# Copy over the compilation version.
cp "$(builddir)/build-$*/include/generated/compile.h" \
"$(hdrdir)/include/generated/compile.h"
# Add UTS_UBUNTU_RELEASE_ABI since UTS_RELEASE is difficult to parse.
echo "#define UTS_UBUNTU_RELEASE_ABI $(abinum)" >> $(hdrdir)/include/generated/utsrelease.h
# powerpc kernel arch seems to need some .o files for external module linking. Add them in.
ifeq ($(build_arch),powerpc)
mkdir -p $(hdrdir)/arch/powerpc/lib
cp $(builddir)/build-$*/arch/powerpc/lib/*.o $(hdrdir)/arch/powerpc/lib
endif
ifeq ($(build_arch),s390)
if [ -n "$$(find $(builddir)/build-$*/arch/s390/lib/expoline -maxdepth 1 -name '*.o' -print -quit)" ]; then \
mkdir -p $(hdrdir)/arch/s390/lib/expoline/; \
cp $(builddir)/build-$*/arch/s390/lib/expoline/*.o $(hdrdir)/arch/s390/lib/expoline/; \
fi
endif
# Copy over scripts/module.lds for building external modules
cp $(builddir)/build-$*/scripts/module.lds $(hdrdir)/scripts
# Script to symlink everything up
$(SHELL) $(DROOT)/scripts/link-headers "$(hdrdir)" "$(indeppkg)" "$*"
# The build symlink
install -d debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*
$(LN) /usr/src/$(basepkg)-$* \
debian/$(basepkg)-$*/lib/modules/$(abi_release)-$*/build
# And finally the symvers
install -m644 $(builddir)/build-$*/Module.symvers \
$(hdrdir)/Module.symvers
# Now the header scripts
$(call install_control,$(hdrs_pkg_name)-$*,headers,postinst)
# At the end of the package prep, call the tests
DPKG_ARCH="$(arch)" KERN_ARCH="$(build_arch)" FLAVOUR="$*" \
VERSION="$(abi_release)" REVISION="$(revision)" \
PREV_REVISION="$(prev_revision)" ABI_NUM="$(abinum)" \
PREV_ABI_NUM="$(prev_abinum)" BUILD_DIR="$(builddir)/build-$*" \
INSTALL_DIR="$(pkgdir)" SOURCE_DIR="$(CURDIR)" \
run-parts -v $(DROOT)/tests-build
#
# Remove files which are generated at installation by postinst,
# except for modules.order and modules.builtin
#
# NOTE: need to keep this list in sync with postrm
#
mkdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.order \
$(pkgdir)/lib/modules/$(abi_release)-$*/_
if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin ] ; then \
mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin \
$(pkgdir)/lib/modules/$(abi_release)-$*/_; \
fi
if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin.modinfo ] ; then \
mv $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin.modinfo \
$(pkgdir)/lib/modules/$(abi_release)-$*/_; \
fi
rm -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.*
mv $(pkgdir)/lib/modules/$(abi_release)-$*/_/* \
$(pkgdir)/lib/modules/$(abi_release)-$*
rmdir $(pkgdir)/lib/modules/$(abi_release)-$*/_
ifeq ($(do_linux_tools),true)
# Create the linux-tools tool links
install -d $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
ifeq ($(do_tools_usbip),true)
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/usbip $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/usbipd $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
endif
ifeq ($(do_tools_acpidbg),true)
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/acpidbg $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
endif
ifeq ($(do_tools_cpupower),true)
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/cpupower $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
endif
ifeq ($(do_tools_rtla),true)
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/rtla $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
endif
ifeq ($(do_tools_perf),true)
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/perf $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
ifeq ($(do_tools_perf_jvmti),true)
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/libperf-jvmti.so $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
endif
endif
ifeq ($(do_tools_bpftool),true)
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/bpftool $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
endif
ifeq ($(do_tools_x86),true)
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/x86_energy_perf_policy $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/turbostat $(toolspkgdir)/usr/lib/linux-tools/$(abi_release)-$*
endif
endif
ifeq ($(do_cloud_tools),true)
ifeq ($(do_tools_hyperv),true)
# Create the linux-hyperv tool links
install -d $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_kvp_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_vss_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/hv_fcopy_daemon $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
$(LN) ../../$(src_pkg_name)-tools-$(abi_release)/lsvmbus $(cloudpkgdir)/usr/lib/linux-tools/$(abi_release)-$*
endif
endif
# Build a temporary "installed headers" directory.
install -d $(dkms_dir) $(dkms_dir)/headers $(dkms_dir)/build $(dkms_dir)/source
cp -rp "$(hdrdir)" "$(indep_hdrdir)" "$(dkms_dir)/headers"
$(foreach _m,$(all_dkms_modules), \
$(if $(enable_$(_m)), \
$(call build_dkms,$(dkms_$(_m)_pkg_name)-$*,$(dkms_$(_m)_pkgdir)/lib/modules/$(abi_release)-$*/$(dkms_$(_m)_subdir),$(dbgpkgdir_dkms),$(_m),$(dkms_$(_m)_debpath)); \
) \
)
ifeq ($(do_dbgsym_package),true)
# Add .gnu_debuglink sections to each stripped .ko
# pointing to unstripped verson
find $(pkgdir) \
$(if $(filter true,$(do_extras_package)),$(pkgdir_ex)) \
-name '*.ko' | while read path_module ; do \
module="/lib/modules/$${path_module#*/lib/modules/}"; \
if [[ -f "$(dbgpkgdir)/usr/lib/debug/$$module" ]] ; then \
while IFS= read -r -d '' signature < <(tail -c 28 "$$path_module"); do \
break; \
done; \
$(CROSS_COMPILE)objcopy \
--add-gnu-debuglink=$(dbgpkgdir)/usr/lib/debug/$$module \
$$path_module; \
if grep -q CONFIG_MODULE_SIG=y $(builddir)/build-$*/.config && \
[ "$$signature" = $$'~Module signature appended~\n' ]; then \
$(builddir)/build-$*/scripts/sign-file $(MODHASHALGO) \
$(MODSECKEY) \
$(MODPUBKEY) \
$$path_module; \
fi; \
else \
echo "WARNING: Missing debug symbols for module '$$module'."; \
fi; \
done
endif
# Build the final ABI information.
install -d $(abidir)
sed -e 's/^\(.\+\)[[:space:]]\+\(.\+\)[[:space:]]\(.\+\)$$/\3 \2 \1/' \
$(builddir)/build-$*/Module.symvers | sort > $(abidir)/$*
# Build the final ABI modules information.
find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) \( -name '*.ko' -o -name '*.ko.*' \) | \
sed -e 's/.*\/\([^\/]*\)\.ko.*/\1/' | sort > $(abidir)/$*.modules
# Build the final ABI built-in modules information.
if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin ] ; then \
sed -e 's/.*\/\([^\/]*\)\.ko/\1/' $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin | \
sort > $(abidir)/$*.modules.builtin; \
fi
# Build the final ABI firmware information.
find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | \
while read ko; do \
/sbin/modinfo $$ko | grep ^firmware || true; \
done | sort -u >$(abidir)/$*.fwinfo
# Build the final ABI built-in firmware information.
if [ -f $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin.modinfo ] ; then \
cat $(pkgdir)/lib/modules/$(abi_release)-$*/modules.builtin.modinfo | \
tr '\0' '\n' | sed -n 's/^.*firmware=/firmware: /p' | \
sort -u > $(abidir)/$*.fwinfo.builtin; \
fi
# Build the final ABI compiler information.
ko=$$(find $(pkgdir_bin) $(pkgdir) $(pkgdir_ex) -name \*.ko | head -1); \
readelf -p .comment "$$ko" | gawk ' \
($$1 == "[") { \
printf("%s", $$3); \
for (n=4; n<=NF; n++) { \
printf(" %s", $$n); \
} \
print "" \
}' | sort -u >$(abidir)/$*.compiler
# Build the buildinfo package content.
install -d $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*
install -m644 $(builddir)/build-$*/.config \
$(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/config
install -m644 $(abidir)/$* \
$(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/abi
install -m644 $(abidir)/$*.modules \
$(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/modules
install -m644 $(abidir)/$*.fwinfo \
$(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/fwinfo
install -m644 $(abidir)/$*.compiler \
$(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/compiler
if [ -f $(abidir)/$*.modules.builtin ] ; then \
install -m644 $(abidir)/$*.modules.builtin \
$(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/modules.builtin; \
fi
if [ -f $(abidir)/$*.fwinfo.builtin ] ; then \
install -m644 $(abidir)/$*.fwinfo.builtin \
$(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/fwinfo.builtin; \
fi
install -m644 $(DROOT)/canonical-certs.pem $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/canonical-certs.pem
install -m644 $(DROOT)/canonical-revoked-certs.pem $(pkgdir_bldinfo)/usr/lib/linux/$(abi_release)-$*/canonical-revoked-certs.pem
# Get rid of .o and .cmd artifacts in headers
find $(hdrdir) -name \*.o -or -name \*.cmd -exec rm -f {} \;
# Strip .so files (e.g., rust/libmacros.so) to reduce size even more
find $(hdrdir) -name libmacros.so -exec strip -s {} \;
ifeq ($(do_lib_rust),true)
# Generate Rust lib files
install -d -m755 $(rustdir)
mv $(hdrdir)/rust $(rustdir)
# Generate symlink for Rust lib directory in headers
$(SHELL) $(DROOT)/scripts/link-lib-rust "$(hdrdir)" "$(indeppkg)" "$*"
endif
ifneq ($(do_full_build),false)
# Clean out this flavours build directory.
rm -rf $(builddir)/build-$*
endif
$(stamp)
headers_tmp := $(CURDIR)/debian/tmp-headers
headers_dir := $(CURDIR)/debian/linux-libc-dev
.PHONY: install-arch-headers
install-arch-headers:
@echo Debug: $@
dh_testdir
dh_testroot
$(call if_package, linux-libc-dev, dh_prep -plinux-libc-dev)
rm -rf $(headers_tmp) $(headers_dir)
$(kmake) O=$(headers_tmp) INSTALL_HDR_PATH=$(headers_dir)/usr $(conc_level) headers_install
mkdir $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)
mv $(headers_dir)/usr/include/asm $(headers_dir)/usr/include/$(DEB_HOST_MULTIARCH)/
rm -rf $(headers_tmp)
define dh_all
dh_installchangelogs -p$(1)
dh_installdocs -p$(1)
dh_compress -p$(1)
# Compress kernel modules, on mantic+
$(if $(do_zstd_ko),find debian/$(1) -name '*.ko' -print0 | xargs -0 -n1 -P $(CONCURRENCY_LEVEL) -r zstd -19 --quiet --rm, true)
dh_fixperms -p$(1) -X/boot/
dh_shlibdeps -p$(1) $(shlibdeps_opts)
dh_installdeb -p$(1)
dh_installdebconf -p$(1)
$(lockme) dh_gencontrol -p$(1) -- -Vlinux:rprovides='$(rprovides)' $(2)
dh_md5sums -p$(1)
dh_builddeb -p$(1)
endef
define newline
endef
define dh_all_inline
$(subst ${newline},; \${newline},$(call dh_all,$(1),$(2)))
endef
.PHONY: binary-arch-headers
binary-arch-headers: install-arch-headers
@echo Debug: $@
dh_testdir
dh_testroot
$(call if_package, linux-libc-dev, $(call dh_all,linux-libc-dev))
-include $(builddir)/skipped-dkms.mk
binary-%: pkgimg = $(bin_pkg_name)-$*
binary-%: pkgimg_mods = $(mods_pkg_name)-$*
binary-%: pkgimg_ex = $(mods_extra_pkg_name)-$*
binary-%: pkgdir_ex = $(CURDIR)/debian/$(extra_pkg_name)-$*
binary-%: pkgbldinfo = $(bldinfo_pkg_name)-$*
binary-%: pkghdr = $(hdrs_pkg_name)-$*
binary-%: pkgrust = $(rust_pkg_name)-$*
binary-%: dbgpkg = $(bin_pkg_name)-$*-dbgsym
binary-%: dbgpkgdir = $(CURDIR)/debian/$(bin_pkg_name)-$*-dbgsym
binary-%: pkgtools = $(tools_flavour_pkg_name)-$*
binary-%: pkgcloud = $(cloud_flavour_pkg_name)-$*
$(foreach _m,$(all_dkms_modules), \
$(eval binary-%: enable_$(_m) = $$(filter true,$$(call custom_override,do_$(_m),$$*))) \
)
binary-%: rprovides = $(foreach _m,$(all_built-in_dkms_modules),$(if $(enable_$(_m)),$(foreach _r,$(dkms_$(_m)_rprovides),$(_r)$(comma) )))
binary-%: target_flavour = $*
binary-%: checks-%
@echo Debug: $@
dh_testdir
dh_testroot
$(call dh_all,$(pkgimg)) -- -Znone
$(call dh_all,$(pkgimg_mods))$(if $(do_zstd_ko), -- -Znone)
ifeq ($(do_extras_package),true)
ifeq ($(ship_extras_package),false)
# If $(ship_extras_package) is explicitly set to false, then do not
# construct the linux-image-extra package; instead just log all of the
# "extra" modules which were pointlessly built yet won't be shipped.
find $(pkgdir_ex) -name '*.ko' | sort \
| sed 's|^$(pkgdir_ex)/|NOT-SHIPPED |' \
| tee -a $(target_flavour).not-shipped.log;
else
if [ -f $(DEBIAN)/control.d/$(target_flavour).inclusion-list ] ; then \
$(call dh_all_inline,$(pkgimg_ex))$(if $(do_zstd_ko), -- -Znone); \
fi
endif
endif
$(foreach _m,$(all_standalone_dkms_modules), \
$(if $(enable_$(_m)),$(call dh_all,$(dkms_$(_m)_pkg_name)-$*)$(if $(do_zstd_ko), -- -Znone);)\
)
$(call dh_all,$(pkgbldinfo))
$(call dh_all,$(pkghdr))
ifeq ($(do_lib_rust),true)
$(call dh_all,$(pkgrust))
endif
ifeq ($(do_dbgsym_package),true)
$(call dh_all,$(dbgpkg)) -- -Zxz
# Hokay...here's where we do a little twiddling...
# Renaming the debug package prevents it from getting into
# the primary archive, and therefore prevents this very large
# package from being mirrored. It is instead, through some
# archive admin hackery, copied to http://ddebs.ubuntu.com.
#
mv ../$(dbgpkg)_$(release)-$(revision)_$(arch).deb \
../$(dbgpkg)_$(release)-$(revision)_$(arch).ddeb
$(lockme) sed -i '/^$(dbgpkg)_/s/\.deb /.ddeb /' debian/files
# Now, the package wont get into the archive, but it will get put
# into the debug system.
# Clean out the debugging package source directory.
rm -rf $(dbgpkgdir)
endif
ifeq ($(do_linux_tools),true)
$(call dh_all,$(pkgtools))
endif
ifeq ($(do_cloud_tools),true)
$(call dh_all,$(pkgcloud))
endif
#
# per-architecture packages
#
builddirpa = $(builddir)/tools-perarch
$(stampdir)/stamp-prepare-perarch:
@echo Debug: $@
ifeq ($(do_any_tools),true)
rm -rf $(builddirpa)
install -d $(builddirpa)
rsync -a --exclude debian --exclude debian.master --exclude $(DEBIAN) --exclude .git -a ./ $(builddirpa)/
endif
$(stamp)
$(stampdir)/stamp-build-perarch: $(stampdir)/stamp-prepare-perarch install-arch-headers build-arch
@echo Debug: $@
ifeq ($(do_linux_tools),true)
ifeq ($(do_tools_usbip),true)
chmod 755 $(builddirpa)/tools/usb/usbip/autogen.sh
cd $(builddirpa)/tools/usb/usbip && ./autogen.sh
chmod 755 $(builddirpa)/tools/usb/usbip/configure
cd $(builddirpa)/tools/usb/usbip && ./configure --prefix=$(builddirpa)/tools/usb/usbip/bin
cd $(builddirpa)/tools/usb/usbip && make install CFLAGS="-g -O2 -static" CROSS_COMPILE=$(CROSS_COMPILE)
endif
ifeq ($(do_tools_acpidbg),true)
cd $(builddirpa)/tools/power/acpi && make clean && make CFLAGS="-g -O2 -static -I$(builddirpa)/include" CROSS_COMPILE=$(CROSS_COMPILE) acpidbg
endif
ifeq ($(do_tools_rtla),true)
cd $(builddirpa)/tools/tracing/rtla && make clean && make CFLAGS='-g -O -Wall -I/usr/include/tracefs -I/usr/include/traceevent -DVERSION="\"6.8.1\""' static
endif
ifeq ($(do_tools_cpupower),true)
make -C $(builddirpa)/tools/power/cpupower \
CROSS_COMPILE=$(CROSS_COMPILE) \
CROSS=$(CROSS_COMPILE) \
STATIC=true \
CPUFREQ_BENCH=false
endif
ifeq ($(do_tools_perf),true)
cd $(builddirpa) && $(kmake) $(defconfig)
mv $(builddirpa)/.config $(builddirpa)/.config.old
sed -e 's/^# \(CONFIG_MODVERSIONS\) is not set$$/\1=y/' \
-e 's/.*CONFIG_LOCALVERSION_AUTO.*/# CONFIG_LOCALVERSION_AUTO is not set/' \
$(builddirpa)/.config.old > $(builddirpa)/.config
cd $(builddirpa) && $(kmake) syncconfig
cd $(builddirpa) && $(kmake) prepare
cd $(builddirpa)/tools/perf && \
$(kmake) prefix=/usr NO_LIBTRACEEVENT=1 HAVE_CPLUS_DEMANGLE_SUPPORT=1 CROSS_COMPILE=$(CROSS_COMPILE) NO_LIBPERL=1 WERROR=0
endif
ifeq ($(do_tools_bpftool),true)
mv $(builddirpa)/tools/bpf/bpftool/vmlinux $(builddirpa)/vmlinux
$(kmake) NO_LIBTRACEEVENT=1 CROSS_COMPILE=$(CROSS_COMPILE) -C $(builddirpa)/tools/bpf/bpftool
rm -f $(builddirpa)/vmlinux
endif
ifeq ($(do_tools_x86),true)
cd $(builddirpa)/tools/power/x86/x86_energy_perf_policy && make CROSS_COMPILE=$(CROSS_COMPILE)
cd $(builddirpa)/tools/power/x86/turbostat && make CROSS_COMPILE=$(CROSS_COMPILE)
endif
endif
ifeq ($(do_cloud_tools),true)
ifeq ($(do_tools_hyperv),true)
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
endif
endif
$(stamp)
.PHONY: install-perarch
install-perarch: toolspkgdir = $(CURDIR)/debian/$(tools_pkg_name)
install-perarch: cloudpkgdir = $(CURDIR)/debian/$(cloud_pkg_name)
install-perarch: $(stampdir)/stamp-build-perarch
@echo Debug: $@
# Add the tools.
ifeq ($(do_linux_tools),true)
install -d $(toolspkgdir)/usr/lib
install -d $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
ifeq ($(do_tools_usbip),true)
install -m755 $(addprefix $(builddirpa)/tools/usb/usbip/bin/sbin/, usbip usbipd) \
$(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
endif
ifeq ($(do_tools_acpidbg),true)
install -m755 $(builddirpa)/tools/power/acpi/acpidbg \
$(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
endif
ifeq ($(do_tools_cpupower),true)
install -m755 $(builddirpa)/tools/power/cpupower/cpupower \
$(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
endif
ifeq ($(do_tools_rtla),true)
install -m755 $(builddirpa)/tools/tracing/rtla/rtla-static \
$(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)/rtla
endif
ifeq ($(do_tools_perf),true)
install -m755 $(builddirpa)/tools/perf/perf $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
ifeq ($(do_tools_perf_jvmti),true)
install -m755 $(builddirpa)/tools/perf/libperf-jvmti.so $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
endif
ifeq ($(do_tools_perf_python),true)
install -d $(toolspkgdir)/usr/lib/python3/dist-packages/$(src_pkg_name)-tools-$(abi_release)
install -m755 $(builddirpa)/tools/perf/python/perf*.so $(toolspkgdir)/usr/lib/python3/dist-packages/$(src_pkg_name)-tools-$(abi_release)
endif
endif
ifeq ($(do_tools_bpftool),true)
install -m755 $(builddirpa)/tools/bpf/bpftool/bpftool $(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
endif
ifeq ($(do_tools_x86),true)
install -m755 \
$(addprefix $(builddirpa)/tools/power/x86/, x86_energy_perf_policy/x86_energy_perf_policy turbostat/turbostat) \
$(toolspkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
endif
endif
ifeq ($(do_cloud_tools),true)
ifeq ($(do_tools_hyperv),true)
install -d $(cloudpkgdir)/usr/lib
install -d $(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
install -m755 $(addprefix $(builddirpa)/tools/hv/, hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon lsvmbus) \
$(cloudpkgdir)/usr/lib/$(src_pkg_name)-tools-$(abi_release)
endif
endif
.PHONY: binary-perarch
binary-perarch: toolspkg = $(tools_pkg_name)
binary-perarch: cloudpkg = $(cloud_pkg_name)
binary-perarch: install-perarch
@echo Debug: $@
ifeq ($(do_linux_tools),true)
$(call dh_all,$(toolspkg))
endif
ifeq ($(do_cloud_tools),true)
$(call dh_all,$(cloudpkg))
endif
.PHONY: binary-debs
binary-debs: binary-perarch $(addprefix binary-,$(flavours))
@echo Debug: $@
build-arch-deps-$(do_flavour_image_package) += $(addprefix $(stampdir)/stamp-install-,$(flavours))
.PHONY: build-arch
build-arch: $(build-arch-deps-true)
@echo Debug: $@
binary-arch-deps-$(do_flavour_image_package) += binary-debs
binary-arch-deps-true += binary-arch-headers
ifneq ($(do_common_headers_indep),true)
binary-arch-deps-$(do_flavour_header_package) += binary-headers
endif
.PHONY: binary-arch
binary-arch: $(binary-arch-deps-true)
@echo Debug: $@