#!/bin/bash

## Copyright (C) 2012 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

if [ -f /usr/libexec/helper-scripts/pre.bsh ]; then
  source /usr/libexec/helper-scripts/pre.bsh
fi

set -e

true "
#####################################################################
## INFO: BEGIN: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

## Sanity test (best-effort). "sq" panics ("capacity overflow") under qemu-user
## aarch64 emulation, which breaks cross-building arm64 images on a non-arm64
## host (the guest postinst runs under qemu-user during image assembly). That
## is a qemu-user bug, fixed upstream in qemu >= 10.2.0 (Debian trixie ships
## qemu 10.0.8). A keyring lint failure must not abort package configuration,
## so keep it non-fatal.
sq cert lint --cert-file "/usr/share/keyrings/derivative.asc" &>/dev/null || true

true "INFO: debhelper beginning here."

#DEBHELPER#

true "INFO: Done with debhelper."

true "
#####################################################################
## INFO: END  : $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

## Explicitly "exit 0", so eventually trapped errors can be ignored.
exit 0
