#!/usr/bin/env bash
set -uo pipefail
cd /tmp

echo "=== where does libspandsp4 come from ==="
apt-cache policy libspandsp4 | head -6

echo
echo "=== other Debian-only sonames that could bite next ==="
for p in libvpx7 libtiff5 libavcodec59 libjpeg62-turbo; do
  printf '%-16s %s\n' "$p" "$(apt-cache policy "$p" 2>/dev/null | sed -n 's/^  Candidate: //p')"
done

echo
echo "=== fetch Debian bookworm libjpeg62-turbo ==="
BASE=http://deb.debian.org/debian/pool/main/libj/libjpeg-turbo/
F=$(curl -s "$BASE" | grep -oE 'libjpeg62-turbo_[0-9][^"<>]*_amd64\.deb' | sort -u | tail -1)
echo "file: $F"
curl -sfO "$BASE$F" || { echo "download failed"; exit 1; }
dpkg -i "$F" || exit 1

echo
echo "=== re-simulate ==="
apt-get install -y -s freeswitch-meta-vanilla freeswitch-sounds-en-us-callie freeswitch-music-default 2>&1 | tail -20
