Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UPSTREAM_CODENAME for Debian 12+ #519

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 37 additions & 18 deletions deb-get
Original file line number Diff line number Diff line change
Expand Up @@ -2604,31 +2604,50 @@ case "${OS_ID}" in
Pop) OS_ID_PRETTY="Pop!_OS";;
Ubuntu) OS_ID_PRETTY="Ubuntu";;
Zorin) OS_ID_PRETTY="Zorin OS";;
*) fancy_message fatal "${OS_ID} is not supported.";;
*)
OS_ID_PRETTY="${OS_ID}"
fancy_message warn "${OS_ID} is not supported."
;;
esac

OS_CODENAME=$(lsb_release --codename --short)

if [ -e /etc/os-release ]; then
UPSTREAM_ID="$(grep "^ID=" /etc/os-release | cut -d'=' -f2)"
OS_RELEASE=/etc/os-release
elif [ -e /usr/lib/os-release ]; then
OS_RELEASE=/usr/lib/os-release
else
fancy_message fatal "os-release not found. Quitting"
fi

UPSTREAM_ID="$(grep "^ID=" ${OS_RELEASE} | cut -d'=' -f2)"

# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then
UPSTREAM_ID_LIKE="$(grep "^ID_LIKE=" /etc/os-release | cut -d'=' -f2 | sed s/\"//g | cut -d' ' -f1)"
UPSTREAM_ID="${UPSTREAM_ID_LIKE}"
# Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian'
if [ "${UPSTREAM_ID}" != ubuntu ] && [ "${UPSTREAM_ID}" != debian ]; then
UPSTREAM_ID_LIKE="$(grep "^ID_LIKE=" ${OS_RELEASE} | cut -d'=' -f2 | cut -d \" -f 2)"

if [[ " ${UPSTREAM_ID_LIKE} " =~ " ubuntu " ]]; then
UPSTREAM_ID=ubuntu
elif [[ " ${UPSTREAM_ID_LIKE} " =~ " debian " ]]; then
UPSTREAM_ID=debian
else
fancy_message fatal "${OS_ID_PRETTY} ${OS_CODENAME^} is not supported because it is not derived from a supported Debian or Ubuntu release."
fi
fi

case "${UPSTREAM_ID}" in
ubuntu) UPSTREAM_CODENAME=$(grep UBUNTU_CODENAME /etc/os-release | cut -d'=' -f2);;
debian)
UPSTREAM_CODENAME=$(grep DEBIAN_CODENAME /etc/os-release | cut -d'=' -f2)
if [ -z "${UPSTREAM_CODENAME}" ]; then
UPSTREAM_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d'=' -f2)
fi
;;
*) UPSTREAM_CODENAME="";;
esac
else
fancy_message fatal "/etc/os-release not found. Quitting"
UPSTREAM_CODENAME=$(grep "^UBUNTU_CODENAME=" ${OS_RELEASE} | cut -d'=' -f2)

if [ -z "${UPSTREAM_CODENAME}" ]; then
UPSTREAM_CODENAME=$(grep "^DEBIAN_CODENAME=" ${OS_RELEASE} | cut -d'=' -f2)
fi

if [ -z "${UPSTREAM_CODENAME}" ]; then
UPSTREAM_CODENAME=$(grep "^VERSION_CODENAME=" ${OS_RELEASE} | cut -d'=' -f2)
fi

# Debian 12+
if [ -z "${UPSTREAM_CODENAME}" ] && [ -e /etc/debian_version ]; then
UPSTREAM_CODENAME=$(cut -d / -f 1 /etc/debian_version)
fi

case "${UPSTREAM_CODENAME}" in
Expand Down