Debian Codegraph @

tools/debian/rules

raw
1 #!/usr/bin/make -f
2
3 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
4
5 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
6
7 # we need an apparmor profile for >= 4.0; this does not yet exist in Ubuntu 22.04
8 PRE4AA = $(filter $(shell . /etc/os-release; echo $${VERSION_ID:-unstable}),22.04)
9
10 # Ubuntu 22.04 LTS's node.js version 12 is too old to understand our source.
11 # Also, esbuild/nodejs are not available on all Debian architectures.
12 # Keep the pre-built dist/ for Ubuntu 22.04 and when nodejs is not available.
13 KEEP_DIST = $(filter $(shell . /etc/os-release; echo $${VERSION_ID:-unstable}),22.04)
14 ifeq ($(KEEP_DIST),)
15 ifeq ($(shell command -v nodejs 2>/dev/null),)
16 KEEP_DIST = no-nodejs
17 endif
18 endif
19
20 # keep the host switcher on in currently supported stable releases
21 STABLE = $(filter $(shell . /etc/os-release; echo $${VERSION_CODENAME}),bookworm jammy noble)
22 ifneq ($(STABLE),)
23 CONFIG_OPTIONS := $(CONFIG_OPTIONS) --enable-multihost
24 endif
25
26 # riscv is an emulated architecture for now, and too slow to run expensive unit tests
27 # hppa's threading is absurdly slow (#981127)
28 SLOW_ARCHES = $(filter $(shell dpkg-architecture -qDEB_BUILD_ARCH),riscv64 hppa)
29 ifneq ($(SLOW_ARCHES),)
30 export COCKPIT_SKIP_SLOW_TESTS=1
31 endif
32
33 export deb_systemdsystemunitdir = $(shell pkgconf --variable=systemdsystemunitdir systemd | sed s,^/,,)
34 # pam.pc doesn't yet have a libdir on older releases
35 export deb_pamlibdir = $(shell { pkgconf --variable=libdir pam || echo /lib/$(DEB_HOST_MULTIARCH); } | sed s,^/,,)
36
37 %:
38 dh $@ --buildsystem=autoconf --with=python3
39
40 override_dh_auto_configure:
41 ifeq ($(KEEP_DIST),)
42 # upstream releases include a pre-built dist/, rebuild it
43 rm -fr dist/
44 # HACK: names for additional tarballs can't contain '_', so we name it just "orig-node"
45 ln -fs node node_modules
46 endif
47 dh_auto_configure -- \
48 --with-pamdir=/$(deb_pamlibdir)/security \
49 --libexecdir=/usr/lib/cockpit $(CONFIG_OPTIONS)
50
51 # HACK: Debian's pip breaks --prefix: https://bugs.debian.org/1035546 with
52 # default install layout
53 override_dh_auto_install:
54 DEB_PYTHON_INSTALL_LAYOUT=deb dh_auto_install
55
56 # avoid trying to start cockpit-issue.service and cockpit-wsinstance-*.socket etc.
57 override_dh_installsystemd:
58 dh_installsystemd -p cockpit-ws cockpit.socket
59
60 override_dh_install:
61 # Debian/Ubuntu PAM config
62 mkdir -p debian/tmp/etc/pam.d
63 install -p -m 644 tools/cockpit.debian.pam debian/tmp/etc/pam.d/cockpit
64
65 # don't ship broken branding symlinks
66 for d in arch rhel fedora centos opensuse; do rm -r debian/tmp/usr/share/cockpit/branding/$$d; done
67 dpkg-vendor --derives-from ubuntu || rm -r debian/tmp/usr/share/cockpit/branding/ubuntu
68
69 # handled by package maintainer scripts
70 rm debian/tmp/etc/motd.d/cockpit debian/tmp/etc/issue.d/cockpit.issue
71
72 # already processed into debian/copyright
73 rm -r debian/tmp/usr/share/doc/cockpit/legal
74
75 # unpackaged modules
76 rm -r debian/tmp/usr/share/cockpit/kdump
77 rm debian/tmp/usr/share/metainfo/org.cockpit_project.cockpit_kdump.metainfo.xml
78 rm -r debian/tmp/usr/share/cockpit/selinux
79 rm debian/tmp/usr/share/metainfo/org.cockpit_project.cockpit_selinux.metainfo.xml
80
81 dh_install -Xusr/src/debug
82 # we don't need this, it contains full build paths and breaks reproducibility
83 rm -r debian/tmp/usr/lib/python*/*-packages/*.dist-info
84
85 # AppArmor profile
86 ifeq ($(PRE4AA),)
87 mkdir -p debian/cockpit-ws/etc/apparmor.d/
88 install -p -m 644 tools/apparmor.d/cockpit-desktop debian/cockpit-ws/etc/apparmor.d/
89 endif
90
91 execute_after_dh_install-indep:
92 # avoid dh_missing failure
93 rm -r debian/tmp/usr/lib/python*
94
95 # run pytests *after* installation, so that we can make sure that we installed the right files
96 ifeq (, $(findstring nocheck, $(DEB_BUILD_OPTIONS)))
97 ifeq ($(shell . /etc/os-release; echo $${VERSION_ID:-unstable}),22.04)
98 NO_QUNIT=1 PYTHONPATH=$$(ls -d debian/cockpit-bridge/usr/lib/python3*/dist-packages) python3 -m pytest -vv -k 'not linter and not test_descriptions'
99 else
100 NO_QUNIT=1 pytest -vv -k 'not linter and not test_descriptions' -opythonpath=$$(ls -d debian/cockpit-bridge/usr/lib/python3*/dist-packages)
101 endif
102 endif