#!/bin/sh
# litedrivermanager-remove-broadcom-pool
# -----------------------------------------------------------------------------
# Once broadcom-sta-dkms is installed, the offline Broadcom apt pool seeded by
# seed-broadcom-pool has done its job (DKMS rebuilds `wl` across kernels), so we
# drop it. This keeps `apt-get update` free of the local file:// pool line.
# No-op unless the driver actually installed.
# -----------------------------------------------------------------------------
set -e

# Only remove the pool if the proprietary driver really did install.
if ! dpkg-query -W -f='${Status}' broadcom-sta-dkms 2>/dev/null \
        | grep -q 'install ok installed'; then
    exit 0
fi

rm -f  /etc/apt/sources.list.d/linuxlite-broadcom-pool.sources
rm -f  /usr/share/keyrings/linuxlite-broadcom-pool.gpg
rm -rf /var/lib/linuxlite/broadcom-pool
# Drop the cached apt lists for the now-removed file:// source so the next
# `apt-get update` makes no mention of it.
rm -f /var/lib/apt/lists/*broadcom-pool* 2>/dev/null || true

echo "Removed the offline Broadcom pool (broadcom-sta-dkms is installed)."
