# blacklist.sh -- shared package blacklist for the AM·OS build tree.
#
# Sourced by sync.sh (mirror side) and enter_chroot.sh (install/upgrade
# side) so the two cannot drift apart. Edit the patterns *here only*.
#
# Semantics -- this is a *freeze* list, not a purge list:
#
#   * A blacklisted binary already present in the production tree is
#     never removed as stale and never overwritten by a newer upstream
#     version.
#   * A blacklisted binary that is not present is not added.
#   * A blacklisted source dir already present in the production source
#     tree is not refreshed from the pristine mirror and is not pruned
#     as stale.
#   * A blacklisted source dir that is not present is not copied in.
#   * A blacklisted package that has vanished from the pristine tree
#     entirely does not trigger the "missing source" hard-fail; sync.sh
#     reports it separately.
#
# The `compat` exception: a name that matches a pattern but also
# contains "compat" is treated as allowed. This lets e.g. a
# qt5-compat-* rebuild through while everything else matching qt5- is
# frozen.
#
# Patterns are EREs matched against the *binary* package name (the
# basename with -VERSION-ARCH-BUILD.t?z stripped). Source dirs are
# matched via the binary -> source mapping, not by directory name,
# because the two are not the same in Slackware (PyQt5 -> PyQt5/).

BLACKLIST_PATTERNS=(
    '5\.116'        # KDE5 version 5.116
    '^PyQt5-'       # PyQt5
    '^PyQt5_sip-'   # PyQt5_sip
    'qt5-'          # Qt5 packages (except those with "compat")
    'llvm'
    'rust'
    'nodejs'
)

# is_blacklisted() -- returns 0 if package should be skipped/frozen,
# 1 otherwise. Safe under `set -e` when called as `if is_blacklisted ...`
# or `is_blacklisted ... || ...`.
is_blacklisted() {
    local pkg="$1" pat
    for pat in "${BLACKLIST_PATTERNS[@]}"; do
        if [[ "$pkg" =~ $pat ]]; then
            if [[ "$pkg" =~ compat ]]; then
                return 1   # not blacklisted (allowed)
            else
                return 0   # blacklisted (freeze/skip)
            fi
        fi
    done
    return 1
}
