#!/usr/bin/make -f
# Copyright 2025 Collabora Ltd.
# SPDX-License-Identifier: MIT

export LC_ALL=C.UTF-8

include /usr/share/dpkg/default.mk

# Ideally we'd use /usr/lib/os-release here, but scout doesn't have that
suite := $(shell . /etc/os-release; echo $$VERSION_CODENAME)
required_apt := 1.1
use_trusted_gpg_d :=

ifeq ($(suite),scout)
export DH_COMPAT := 8
endif

ifneq ($(filter scout soldier sniper steamrt3c,$(suite)),)
# For backwards compatibility with released suites, we mark the keys
# as trusted for all apt repositories, rather than relying on Signed-By
required_apt := 1.0
use_trusted_gpg_d := yes
endif

DESTDIR := $(CURDIR)/debian/tmp

%:
	dh $@

override_dh_auto_install:
	dh_auto_install --destdir=$(DESTDIR)

override_dh_link:
ifeq ($(use_trusted_gpg_d),yes)
	dh_link usr/share/keyrings/steamrt-archive-keyring.gpg etc/apt/trusted.gpg.d/steamrt-archive-keyring.gpg
endif
	dh_link

override_dh_gencontrol:
	dh_gencontrol \
		-- \
		-Vlocal:Depends='apt (>= $(required_apt))' \
		${NULL}
