Debian Codegraph @

debian/rules

raw
1 #! /usr/bin/make -f
2
3 #export DH_VERBOSE = 1
4 #export DEB_BUILD_OPTIONS = nostrip
5
6 export LC_ALL = C.UTF-8
7
8 include /usr/share/dpkg/default.mk
9 include /usr/share/debhelper/dh_package_notes/package-notes.mk
10
11 ifeq (amd64,$(DEB_HOST_ARCH))
12 export TEMPLATE_EFI_ARCH=x64
13 else ifeq (arm64,$(DEB_HOST_ARCH))
14 export TEMPLATE_EFI_ARCH=aa64
15 endif
16
17 # We are building on OBS? Then it's an upstream build, set the profile and
18 # use the addon for Secure Boot EFI signing
19 ifneq ("$(wildcard /.build/build.dist)","")
20 export DEB_BUILD_PROFILES += pkg.systemd.upstream
21 DH_ADDONS = --with=signobs
22 endif
23
24 ifeq ($(DEB_VENDOR),Ubuntu)
25 DEFAULT_NTP_SERVERS = ntp.ubuntu.com
26 SUPPORT_URL = http://www.ubuntu.com/support
27 CONFFLAGS_DISTRO = \
28 -Duser-path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
29 -Ddefault-llmnr=no \
30 -Ddefault-mdns=no
31
32 else
33 DEFAULT_NTP_SERVERS = 0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
34 SUPPORT_URL = https://www.debian.org/support
35 CONFFLAGS_DISTRO =
36 endif
37
38 TEST_TIMEOUT_MULTIPLIER = "-t 10"
39
40 # Fail on missing files and symbol changes on distro builds, but not if we
41 # build/test upstream master. Also, don't put the debian revision in the version
42 # tag when we build/test upstream as it doesn't have any meaning in that case
43 # and it allows using the current date as the debian revision without causing
44 # unnecessary rebuilds all the time.
45 ifeq (, $(filter pkg.systemd.upstream, $(DEB_BUILD_PROFILES)))
46 DH_MISSING ?= --fail-missing
47 GENSYMBOLS_LEVEL ?= 4
48 VERSION_TAG = $(DEB_VERSION)
49 else
50 DH_MISSING ?= --list-missing
51 GENSYMBOLS_LEVEL ?= 1
52 VERSION_TAG = $(DEB_VERSION_UPSTREAM)
53 endif
54
55 # Make sure that DEB_BUILD_OPTIONS can be used by users to override any options
56 # we set here (By default DEB_BUILD_MAINT_OPTIONS overrides DEB_BUILD_OPTIONS).
57 export DEB_BUILD_MAINT_OPTIONS = optimize=+lto hardening=+pie $(DEB_BUILD_OPTIONS)
58
59 CONFFLAGS = \
60 -Dc_link_args=-Wl,--push-state,--no-as-needed,-lm,--pop-state \
61 -Dstatic-libsystemd=true \
62 -Dversion-tag="$(VERSION_TAG)" \
63 -Dquotaon-path=/usr/sbin/quotaon \
64 -Dquotacheck-path=/usr/sbin/quotacheck \
65 -Dkmod-path=/usr/bin/kmod \
66 -Dkexec-path=/usr/sbin/kexec \
67 -Dsulogin-path=/usr/sbin/sulogin \
68 -Dmount-path=/usr/bin/mount \
69 -Dumount-path=/usr/bin/umount \
70 -Dloadkeys-path=/usr/bin/loadkeys \
71 -Dsetfont-path=/usr/bin/setfont \
72 -Dnologin-path=/usr/sbin/nologin \
73 -Dlocalegen-path=/usr/sbin/locale-gen \
74 -Ddebug-shell=/usr/bin/bash \
75 -Dzshcompletiondir=/usr/share/zsh/vendor-completions \
76 -Ddbuspolicydir=/usr/share/dbus-1/system.d/ \
77 -Dsupport-url=$(SUPPORT_URL) \
78 -Ddefault-kill-user-processes=false \
79 -Ddefault-dnssec=no \
80 -Dpamconfdir=no \
81 -Dpamlibdir=/usr/lib/$(DEB_HOST_MULTIARCH)/security \
82 -Drpmmacrosdir=no \
83 -Dvconsole=false \
84 -Dfirstboot=true \
85 -Dxkbcommon=disabled \
86 -Dwheel-group=false \
87 -Doomd=true \
88 -Durlify=true \
89 -Dgnutls=disabled \
90 -Dntp-servers="$(DEFAULT_NTP_SERVERS)" \
91 -Dsystem-uid-max=999 \
92 -Dsystem-gid-max=999 \
93 -Dnobody-user=nobody \
94 -Dnobody-group=nogroup \
95 -Ddev-kvm-mode=0660 \
96 -Dgroup-render-mode=0660 \
97 -Drepart=enabled \
98 -Dfdisk=enabled \
99 -Dsysext=true \
100 -Dselinux=enabled \
101 -Dhwdb=true \
102 -Dsysusers=true \
103 -Dinstall-tests=$(if $(filter noinsttest,$(DEB_BUILD_PROFILES)),false,true) \
104 -Dman=$(if $(filter nodoc,$(DEB_BUILD_PROFILES)),disabled,enabled) \
105 -Ddbus-interfaces-dir=$(if $(filter nodoc,$(DEB_BUILD_PROFILES)),no,yes) \
106 -Dtranslations=true \
107 -Dnss-myhostname=true \
108 -Dnss-mymachines=enabled \
109 -Dnss-resolve=enabled \
110 -Dnss-systemd=true \
111 -Dresolve=true \
112 -Dstatus-unit-format-default=combined \
113 -Dstandalone-binaries=true \
114 -Dutmp=false \
115 -Dtty-mode=0600 \
116 -Dvmspawn=enabled \
117 -Defi-stub-extra-sections=500 \
118 -Dcompat-sysv-interfaces=false \
119 -Dmode=$(if $(filter pkg.systemd.upstream,$(DEB_BUILD_PROFILES)),developer,release)
120
121 ifeq ($(filter nocheck,$(DEB_BUILD_PROFILES))$(filter noinsttest,$(DEB_BUILD_PROFILES)),nochecknoinsttest)
122 CONFFLAGS += -Dtests=false
123 else
124 CONFFLAGS += -Dtests=true
125 endif
126
127 ifeq (, $(filter stage1, $(DEB_BUILD_PROFILES)))
128 CONFFLAGS += \
129 -Daudit=enabled \
130 -Dlibcryptsetup=enabled \
131 -Dlibcryptsetup-plugins=enabled \
132 -Dcoredump=true \
133 -Delfutils=enabled \
134 -Dapparmor=enabled \
135 -Dlibidn2=enabled \
136 -Dlibiptc=enabled \
137 -Dlibcurl=enabled \
138 -Dimportd=enabled \
139 -Dmicrohttpd=enabled \
140 -Dopenssl=enabled \
141 -Ddns-over-tls=openssl \
142 -Dlibfido2=enabled \
143 -Dtpm2=enabled \
144 -Dp11kit=enabled \
145 -Dqrencode=enabled \
146 -Dpwquality=enabled \
147 -Dhomed=enabled \
148 -Duserdb=true \
149 -Dpcre2=enabled \
150 -Dukify=enabled \
151 -Dbootloader=$(if $(filter amd64 i386 arm64 armhf loong64 riscv64,$(DEB_HOST_ARCH)),enabled,disabled) \
152 -Dsysupdate=enabled
153 else
154 CONFFLAGS += \
155 -Daudit=disabled \
156 -Dlibcryptsetup=disabled \
157 -Dlibcryptsetup-plugins=disabled \
158 -Dcoredump=false \
159 -Delfutils=disabled \
160 -Dapparmor=disabled \
161 -Dlibidn2=disabled \
162 -Dlibiptc=disabled \
163 -Dlibcurl=disabled \
164 -Dimportd=disabled \
165 -Dmicrohttpd=disabled \
166 -Dopenssl=disabled \
167 -Dlibfido2=disabled \
168 -Dtpm2=disabled \
169 -Dp11kit=disabled \
170 -Dqrencode=disabled \
171 -Dpwquality=disabled \
172 -Dhomed=disabled \
173 -Duserdb=false \
174 -Dpcre2=disabled \
175 -Dukify=disabled \
176 -Dbootloader=disabled \
177 -Dbpf-framework=disabled \
178 -Dsysupdate=disabled
179 endif
180
181 # BPF/BTF are only enabled and usable on a few architectures
182 ifeq (, $(filter $(DEB_BUILD_PROFILES), stage1 pkg.systemd.nobpf))
183 ifneq (,$(filter $(DEB_TARGET_ARCH), amd64 arm64 ppc64el riscv64 s390x))
184 CONFFLAGS += \
185 -Dvmlinux-h=provided \
186 -Dvmlinux-h-path=/usr/include/$(DEB_HOST_MULTIARCH)/linux/bpf/vmlinux.h \
187 -Dbpf-framework=enabled \
188 -Dbpf-compiler=clang
189
190 ifeq ($(DEB_VENDOR),Ubuntu)
191 # TODO: drop this and the alternative build dep once support for Noble is dropped
192 #
193 # Source: https://git.launchpad.net/ubuntu/+source/xdp-tools/tree/debian/rules
194 # On Ubuntu, the `bpftool` in path is a shell wrapper pointing at
195 # the binary corresponding to runtime kernel version.
196 #
197 # We do not know the kernel version being used on the system building
198 # this package, and in sbuild/container environments uname might not
199 # even match anything available to the build.
200 # Gladly for the build we only need the tool to generate skeleton code.
201 #
202 # If any /usr/lib/linux-tools/*/bpftool exists, locate the most recent
203 # version and point to that, otherwise `bpftool` from PATH will be
204 # used.
205 #
206 # Newer versions of linux-tools-* ship the binaries in /usr/lib/linux-tools-$(uname -r).
207 # Check there too.
208 bpftool_binary := $(shell find /usr/lib/linux-tools/ /usr/lib/linux-tools-* -name 'bpftool' -perm /u=x 2>/dev/null | sort -r | head -n1)
209 ifneq ($(bpftool_binary),)
210 export PATH := $(shell dirname $(bpftool_binary)):$(PATH)
211 endif
212 endif
213 endif
214 endif
215
216 ifeq (, $(filter pkg.systemd.upstream, $(DEB_BUILD_PROFILES)))
217 CONFFLAGS += -Ddns-servers=''
218 CONFFLAGS += -Dsbat-distro-url=https://tracker.debian.org/pkg/systemd
219 else
220 CONFFLAGS += --buildtype=debugoptimized
221 CONFFLAGS += -Dsbat-distro-url=https://github.com/systemd/systemd
222 CONFFLAGS += -Dsbat-distro=upstream
223 CONFFLAGS += -Dsbat-distro-summary='Upstream build from git'
224 endif
225
226 override_dh_auto_configure:
227 dh_auto_configure \
228 -- $(CONFFLAGS) $(CONFFLAGS_DISTRO) $(CONFFLAGS_UPSTREAM)
229
230 execute_before_dh_auto_build:
231 # blhc false positives: C++ fuzz test program, cc -E flags listing, PE-COFF EFI binaries
232 @echo 'blhc: ignore-line-regexp: .* -o test-bus-vtable-cc.*'
233 @echo 'blhc: ignore-line-regexp: .*cc -E.*'
234 @echo 'blhc: ignore-line-regexp: .* -o src/boot/.*'
235 @echo 'blhc: ignore-line-regexp: .* Compiling C object fuzz.*'
236
237 execute_before_dh_auto_clean:
238 ifneq (, $(filter pkg.systemd.upstream, $(DEB_BUILD_PROFILES)))
239 debian/extra/checkout-upstream
240 endif
241
242 execute_before_dh_install:
243 # remove unnecessary / unused files that are picked up by wildcards/directory listings in dh_install
244 rm -rf debian/tmp/usr/share/doc/systemd/LICENSES/
245 rm -f debian/tmp/usr/share/doc/systemd/LICENSE.*
246 rm -f debian/tmp/usr/lib/udev/*.d/README
247 # replace upstream sysusers.d/basic.conf with proper users for Debian
248 if [ -d debian/tmp/usr/lib/sysusers.d/ ]; then \
249 debian/extra/make-sysusers-basic > debian/tmp/usr/lib/sysusers.d/basic.conf; \
250 fi
251
252 execute_after_dh_install-arch:
253 # Ubuntu specific files
254 ifeq ($(DEB_VENDOR),Ubuntu)
255 install -D --mode=644 debian/extra/udev.py debian/udev/usr/share/apport/package-hooks/udev.py
256 install -D --mode=644 debian/extra/systemd.py debian/systemd/usr/share/apport/package-hooks/systemd.py
257 install --mode=644 debian/extra/rules-ubuntu/*.rules debian/udev/usr/lib/udev/rules.d/
258 install -D --mode=644 debian/extra/resolved.conf.d/cache-no-negative.conf debian/systemd-resolved/usr/lib/systemd/resolved.conf.d/cache-no-negative.conf
259 cp -a debian/extra/units-ubuntu/* debian/systemd/usr/lib/systemd/system/
260 endif
261
262 ifeq (,$(filter stage1, $(DEB_BUILD_PROFILES)))
263 ifeq ($(DEB_VENDOR),Debian)
264 ifneq ($(TEMPLATE_EFI_ARCH),)
265 debian/extra/gen-signing-template $(DEB_VERSION) $(DEB_HOST_ARCH) $(TEMPLATE_EFI_ARCH)
266 endif
267 endif
268 endif
269
270 override_dh_missing:
271 dh_missing $(DH_MISSING)
272
273 override_dh_installsystemd:
274 dh_installsystemd -psystemd-timesyncd
275 dh_installsystemd -psystemd-oomd -X systemd-oomd.socket
276 dh_installsystemd -psystemd-oomd --no-stop-on-upgrade systemd-oomd.socket
277 dh_installsystemd -psystemd-container --no-stop-on-upgrade machines.target
278 dh_installsystemd -psystemd-container -X machines.target --no-enable --no-start --no-stop-on-upgrade --restart-after-upgrade
279 dh_installsystemd -psystemd-userdbd --no-stop-on-upgrade systemd-userdbd.socket
280 # TODO: drop --no-also once https://salsa.debian.org/debian/debhelper/-/merge_requests/144 is available
281 dh_installsystemd -psystemd-userdbd -X systemd-userdbd.socket --no-enable --no-start --no-stop-on-upgrade --restart-after-upgrade --no-also
282 dh_installsystemd -psystemd-homed --no-also systemd-homed.service systemd-homed-activate.service
283 dh_installsystemd -psystemd-repart --restart-after-upgrade systemd-repart.socket
284 dh_installsystemd -psystemd-repart -X systemd-repart.socket --no-start --no-stop-on-upgrade --restart-after-upgrade
285 dh_installsystemd -psystemd-resolved --no-also systemd-resolved.service
286 dh_installsystemd -psystemd-resolved -X systemd-resolved.service --no-stop-on-upgrade
287 dh_installsystemd -pudev systemd-udevd.service
288 dh_installsystemd -pudev -X systemd-udevd.service --no-enable --no-start --no-stop-on-upgrade
289 dh_installsystemd -psystemd-boot --no-start --no-stop-on-upgrade --restart-after-upgrade
290 # do not restart logind
291 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919509
292 dh_installsystemd -psystemd --no-enable --no-start --no-stop-on-upgrade --restart-after-upgrade --no-also systemd-networkd.service systemd-journald.service
293
294 override_dh_installsystemduser:
295
296 execute_after_dh_installsysusers:
297 dh_installsysusers -pudev --name=debian-udev
298
299 PROJECT_VERSION ?= $(shell awk '/(PROJECT|PACKAGE)_VERSION / {print $$3}' obj-$(DEB_HOST_GNU_TYPE)/config.h | tr -d \")
300
301 # The SysV compat tools (which are symlinks to systemctl) are
302 # quasi-essential, so add their dependencies to Pre-Depends
303 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=753589
304 override_dh_shlibdeps:
305 dh_shlibdeps -psystemd -Llibsystemd-shared -- \
306 -dPre-Depends -edebian/systemd/usr/bin/systemctl \
307 -dDepends
308 dh_shlibdeps -plibsystemd-shared -lusr/lib/$(DEB_HOST_MULTIARCH)/systemd
309 dh_shlibdeps --remaining-packages -Llibsystemd-shared
310
311 override_dh_makeshlibs:
312 sed 's/SHARED_LIB_VERSION/$(PROJECT_VERSION)/' debian/shlibs.local.in > debian/shlibs.local
313 dh_makeshlibs -plibsystemd-shared -Xlibsystemd-shared -Xlibsystemd-core -- -c$(GENSYMBOLS_LEVEL)
314 dh_makeshlibs --remaining-packages -- -c$(GENSYMBOLS_LEVEL)
315 # Ensure builds against the udeb package gets a dependency on libudev1-udeb. The last time a symbol
316 # was added was in 247, and the API is pretty much frozen, so we can have a fixed version here.
317 echo 'udeb: libudev 1 libudev1-udeb (>= 247)' >> debian/libudev1/DEBIAN/shlibs
318
319 override_dh_auto_test:
320 ifeq (, $(filter nocheck, $(DEB_BUILD_OPTIONS)))
321 # some tests hang under fakeroot, so disable fakeroot
322 env -u LD_PRELOAD meson test -C obj-$(DEB_HOST_GNU_TYPE) --print-errorlogs $(TEST_TIMEOUT_MULTIPLIER)
323 endif
324
325 ifeq ($(DEB_VENDOR),Ubuntu)
326 ifeq (, $(filter pkg.systemd.upstream, $(DEB_BUILD_PROFILES)))
327 execute_after_dh_link:
328 # Mask systemd-gpt-auto-generator by default on Ubuntu
329 dh_link -psystemd /dev/null /etc/systemd/system-generators/systemd-gpt-auto-generator
330
331 # Enable this example to allow root to ignore inhibitors
332 dh_link -psystemd /usr/share/polkit-1/rules.d/10-systemd-logind-root-ignore-inhibitors.rules.example \
333 /usr/share/polkit-1/rules.d/10-systemd-logind-root-ignore-inhibitors.rules
334 endif
335 endif
336
337 %:
338 dh $@ $(DH_ADDONS)
339
340 # TODO: ideally it should be possible to disable this via an env var or DEB_BUILD_OPTIONS
341 override_dh_strip_nondeterminism:
342 ifeq (, $(filter pkg.systemd.upstream, $(DEB_BUILD_PROFILES)))
343 dh_strip_nondeterminism
344 endif