#!/bin/sh
# piuparts pre-install hook for the salsa-ci pipeline.
#
# OpenColorIO is uploaded to experimental, and a previous version is normally
# already present there. The salsa-ci piuparts job installs the package under
# test with:
#
#     apt-get -t experimental install <pkg>=<version-from-changelog>+salsaci+...
#
# The "-t experimental" flag promotes the version already in experimental to
# apt's "candidate". That conflicts with the strict inter-dependencies of the
# freshly built binaries (e.g. libopencolorio-dev Depends
# libopencolorio2.5 (= ${binary:Version})): apt refuses to pull the matching
# just-built library from the local test repository as a transitive
# dependency and aborts with
#
#     libopencolorio2.5 ... is not going to be installed
#
# The just-built packages are served from a local file:// repository, which
# apt sees with an empty origin. Give everything from that repository the
# highest priority so the packages under test win over the copy that is
# already in experimental. This only affects the throw-away piuparts chroot.
#
# This workaround should be able to disappear once
# https://salsa.debian.org/salsa-ci-team/pipeline/-/work_items/579
# and https://salsa.debian.org/salsa-ci-team/pipeline/-/merge_requests/748
# are closed.
set -e

cat > /etc/apt/preferences.d/salsa-ci-testdebs <<'EOF'
Package: *
Pin: origin ""
Pin-Priority: 1001
EOF
