#!/bin/sh
# Preserve Alfred Linux 7.77 Kingdom Edition /etc/os-release across Debian base-files updates
if [ -f /etc/alfred-edition ] && grep -qi "Kingdom" /etc/alfred-edition 2>/dev/null; then
    DEB_FULL="13.8"
    if [ -r /usr/lib/os-release ]; then
        D="$(grep -E '^DEBIAN_VERSION_FULL=' /usr/lib/os-release 2>/dev/null | head -n1 | cut -d= -f2 | tr -d '"')"
        [ -n "$D" ] && DEB_FULL="$D"
    fi
    if [ -L /etc/os-release ] || ! grep -qi "Alfred Linux" /etc/os-release 2>/dev/null; then
        rm -f /etc/os-release
        cat <<EOF > /etc/os-release
PRETTY_NAME="Alfred Linux 7.77 Kingdom Edition"
NAME="Alfred Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=omega
DEBIAN_VERSION_FULL=${DEB_FULL}
ID=alfred
HOME_URL="https://alfredlinux.com/"
SUPPORT_URL="https://alfredlinux.com/"
BUG_REPORT_URL="https://alfredlinux.com/"
EOF
        chmod 644 /etc/os-release
    fi
fi
exit 0
