Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 include /usr/share/dpkg/architecture.mk
4
5 # Downstreams: add your own certs here. Only Debian binaries will be signed by this key.
6 # You must generate and manage your own key if you (re)build shim, GRUB, or Linux.
7 cert=debian/debian-uefi-ca.der
8 distributor=debian
9
10 deb_version := $(shell dpkg-parsechangelog | sed -ne "s/^Version: \(.*\)/\1/p")
11 upstream_version := $(shell echo $(deb_version) | sed -e "s/-[^-]*$$//")
12 plain_upstream_version := $(shell echo $(upstream_version) | sed -e "s/+dfsg.*//")
13
14 DBX_LIST = dbx.esl
15 DBX_HASHES = debian/$(distributor)-dbx.hashes
16 SBAT_IN = debian/sbat.$(distributor).csv.in
17 SBAT_DATA = data/sbat.$(distributor).csv
18
19 include /usr/share/dpkg/architecture.mk
20
21 ifeq ($(DEB_HOST_ARCH),amd64)
22 export EFI_ARCH := x64
23 endif
24 ifeq ($(DEB_HOST_ARCH),arm64)
25 export EFI_ARCH := aa64
26 endif
27 ifeq ($(DEB_HOST_ARCH),i386)
28 export EFI_ARCH := ia32
29 endif
30
31 COMMON_OPTIONS += \
32 RELEASE=$(plain_upstream_version) \
33 COMMIT_ID=afc49558b34548644c1cd0ad1b6526a9470182ed \
34 MAKELEVEL=0 \
35 ENABLE_HTTPBOOT=true \
36 VENDOR_CERT_FILE=$(cert) \
37 VENDOR_DBX_FILE=$(DBX_LIST) \
38 EFIDIR=$(distributor) \
39 CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)- \
40 CC=gcc \
41 $(NULL)
42
43 # Force shim to use the latest revocations by default to block some
44 # older grub / peimage issues. This is:
45 # "shim,4\ngrub,5"
46 COMMON_OPTIONS += SBAT_AUTOMATIC_DATE=2025021800
47
48 # Enable NX for this build
49 COMMON_OPTIONS += "POST_PROCESS_PE_FLAGS=-n"
50
51 $(DBX_LIST): $(DBX_HASHES)
52 ./debian/generate_dbx_list $(EFI_ARCH) $< $@
53
54 $(SBAT_DATA): $(SBAT_IN)
55 rm -f $@
56 set -e; \
57 sed -e "s/@DEB_VERSION@/$(deb_version)/g" \
58 -e "s/@UPSTREAM_VERSION@/$(plain_upstream_version)/g" \
59 < $(SBAT_IN) > $(SBAT_DATA)
60 # If we have an empty $(SBAT_DATA), delete
61 if [ ! -s $(SBAT_DATA) ]; then rm -f $(SBAT_DATA); fi
62
63 %:
64 dh $@
65
66 override_dh_auto_clean:
67 dh_auto_clean -- MAKELEVEL=0
68 rm -f $(DBX_LIST) $(SBAT_DATA) sbat.*.csv BOOT*.CSV
69 rm -f test-csv test-sbat test-str test-load-options
70 rm -f test-mock-variables test-mok-mirror test-pe-relocate test-pe-util
71
72 override_dh_auto_build: $(DBX_LIST) $(SBAT_DATA)
73 dh_auto_build -- INSTALL=install $(COMMON_OPTIONS)
74
75 override_dh_auto_test: $(DBX_LIST) $(SBAT_DATA)
76 dh_auto_test -- INSTALL=install $(COMMON_OPTIONS)
77
78 override_dh_auto_install:
79 dh_auto_install --destdir=debian/tmp -- INSTALL=install $(COMMON_OPTIONS)
80 # Remove the copy of the source that's installed - we have git
81 # already...
82 rm -rf debian/tmp/usr
83 # And remove the extra removable-media copy of shim too, it's
84 # not needed for our build and causes debhelper to complain
85 rm -f debian/tmp/boot/efi/EFI/BOOT/BOOT*.EFI
86
87 install -m 644 $(cert) debian/shim-unsigned/usr/share/shim
88
89 # Generate the template packages that we'll use for SB signing later
90 ./debian/signing-template.generate
91
92 # Log some useful things about the build here
93 ./debian/check_nx shim*.efi
94 sha256sum *.efi
95
96 generate-gnu-efi:
97 git -C gnu-efi archive --prefix=gnu-efi/ HEAD | xz -9 \
98 > ../shim_$(plain_upstream_version).orig-gnu-efi.tar.xz