#!/usr/bin/make -fexport DEB_BUILD_MAINT_OPTIONS = hardening=+allDEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)# we need an apparmor profile for >= 4.0; this does not yet exist in Ubuntu 22.04PRE4AA = $(filter $(shell . /etc/os-release; echo $${VERSION_ID:-unstable}),22.04)# Ubuntu 22.04 LTS's node.js version 12 is too old to understand our source.# Also, esbuild/nodejs are not available on all Debian architectures.# Keep the pre-built dist/ for Ubuntu 22.04 and when nodejs is not available.KEEP_DIST = $(filter $(shell . /etc/os-release; echo $${VERSION_ID:-unstable}),22.04)ifeq ($(KEEP_DIST),)ifeq ($(shell command -v nodejs 2>/dev/null),)KEEP_DIST = no-nodejsendifendif# keep the host switcher on in currently supported stable releasesSTABLE = $(filter $(shell . /etc/os-release; echo $${VERSION_CODENAME}),bookworm jammy noble)ifneq ($(STABLE),)CONFIG_OPTIONS := $(CONFIG_OPTIONS) --enable-multihostendif# riscv is an emulated architecture for now, and too slow to run expensive unit tests# hppa's threading is absurdly slow (#981127)SLOW_ARCHES = $(filter $(shell dpkg-architecture -qDEB_BUILD_ARCH),riscv64 hppa)ifneq ($(SLOW_ARCHES),)export COCKPIT_SKIP_SLOW_TESTS=1endifexport deb_systemdsystemunitdir = $(shell pkgconf --variable=systemdsystemunitdir systemd | sed s,^/,,)# pam.pc doesn't yet have a libdir on older releasesexport deb_pamlibdir = $(shell { pkgconf --variable=libdir pam || echo /lib/$(DEB_HOST_MULTIARCH); } | sed s,^/,,)%:dh $@ --buildsystem=autoconf --with=python3override_dh_auto_configure:ifeq ($(KEEP_DIST),)# upstream releases include a pre-built dist/, rebuild itrm -fr dist/# HACK: names for additional tarballs can't contain '_', so we name it just "orig-node"ln -fs node node_modulesendifdh_auto_configure -- \--with-pamdir=/$(deb_pamlibdir)/security \--libexecdir=/usr/lib/cockpit $(CONFIG_OPTIONS)# HACK: Debian's pip breaks --prefix: https://bugs.debian.org/1035546 with# default install layoutoverride_dh_auto_install:DEB_PYTHON_INSTALL_LAYOUT=deb dh_auto_install# avoid trying to start cockpit-issue.service and cockpit-wsinstance-*.socket etc.override_dh_installsystemd:dh_installsystemd -p cockpit-ws cockpit.socketoverride_dh_install:# Debian/Ubuntu PAM configmkdir -p debian/tmp/etc/pam.dinstall -p -m 644 tools/cockpit.debian.pam debian/tmp/etc/pam.d/cockpit# don't ship broken branding symlinksfor d in arch rhel fedora centos opensuse; do rm -r debian/tmp/usr/share/cockpit/branding/$$d; donedpkg-vendor --derives-from ubuntu || rm -r debian/tmp/usr/share/cockpit/branding/ubuntu# handled by package maintainer scriptsrm debian/tmp/etc/motd.d/cockpit debian/tmp/etc/issue.d/cockpit.issue# already processed into debian/copyrightrm -r debian/tmp/usr/share/doc/cockpit/legal# unpackaged modulesrm -r debian/tmp/usr/share/cockpit/kdumprm debian/tmp/usr/share/metainfo/org.cockpit_project.cockpit_kdump.metainfo.xmlrm -r debian/tmp/usr/share/cockpit/selinuxrm debian/tmp/usr/share/metainfo/org.cockpit_project.cockpit_selinux.metainfo.xmldh_install -Xusr/src/debug# we don't need this, it contains full build paths and breaks reproducibilityrm -r debian/tmp/usr/lib/python*/*-packages/*.dist-info# AppArmor profileifeq ($(PRE4AA),)mkdir -p debian/cockpit-ws/etc/apparmor.d/install -p -m 644 tools/apparmor.d/cockpit-desktop debian/cockpit-ws/etc/apparmor.d/endifexecute_after_dh_install-indep:# avoid dh_missing failurerm -r debian/tmp/usr/lib/python*# run pytests *after* installation, so that we can make sure that we installed the right filesifeq (, $(findstring nocheck, $(DEB_BUILD_OPTIONS)))ifeq ($(shell . /etc/os-release; echo $${VERSION_ID:-unstable}),22.04)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'elseNO_QUNIT=1 pytest -vv -k 'not linter and not test_descriptions' -opythonpath=$$(ls -d debian/cockpit-bridge/usr/lib/python3*/dist-packages)endifendif