#!/bin/sh
set -e

# Building curl is required because libauthretry (from "make test") requires
# libcurl.
#
# It might be possible to patch the makefile to have libauthretry link against
# the system's installed libcurl, patches welcome.
#
# Event-based gnutls tests are executed against the built curl and libcurl
# instead of the system-installed versions. This is necessary because the
# shipped curl does not include debug support for any backend.
export DEB_BUILD_PROFILES="pkg.curl.gnutls-only pkg.curl.debug"
export VERBOSE=1

# Don't skip tests which fail on ipv6-only environments for autopkgtests.
# I'm not aware of runners with this configuration for debci, and a retry
# should be easy enough it it happens.
# References:
# https://bugs.debian.org/1032343
# https://github.com/curl/curl/issues/10682
export TESTS_FAILS_ON_IPV6_ONLY_MACHINES=""

# Append V=0 to MAKE_EXTRA_FLAGS in d/rules to reduce build verbosity. This
# helps prevent exceeding the byte limit for logs in salsa ci autopkgtest jobs.
export MAKE_EXTRA_FLAGS="V=0"

echo "dh_update_autotools_config"
dh_update_autotools_config > "${AUTOPKGTEST_ARTIFACTS}/event_based_gnutls_autotools_config.log"

echo "dh_autoreconf"
dh_autoreconf > "${AUTOPKGTEST_ARTIFACTS}/event_based_gnutls_autorefconf.log"

echo "debian/rules override_dh_auto_configure"
debian/rules override_dh_auto_configure > "${AUTOPKGTEST_ARTIFACTS}/event_based_gnutls_auto_configure.log"

echo "debian/rules override_dh_auto_build"
debian/rules override_dh_auto_build > "${AUTOPKGTEST_ARTIFACTS}/event_based_gnutls_auto_build.log"

echo "debian/rules override_dh_auto_test"
debian/rules override_dh_auto_test
