Commit f4cfdfa4 authored by Muhammad Herdiansyah's avatar Muhammad Herdiansyah

Linux: Move /etc/os-release directly below lsb_release

We are assuming that people's /etc/os-release are standard, and any distro without it will use the "fallback" methods they have.
parent 9d4855a1
...@@ -877,6 +877,23 @@ get_distro() { ...@@ -877,6 +877,23 @@ get_distro() {
esac esac
distro="$(lsb_release "$lsb_flags")" distro="$(lsb_release "$lsb_flags")"
elif [[ -f "/etc/os-release" || \
-f "/usr/lib/os-release" || \
-f "/etc/openwrt_release" ]]; then
files=("/etc/os-release" "/usr/lib/os-release" "/etc/openwrt_release")
# Source the os-release file
for file in "${files[@]}"; do
source "$file" && break
done
# Format the distro name.
case "$distro_shorthand" in
"on") distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;;
"tiny") distro="${NAME:-${DISTRIB_ID:-${TAILS_PRODUCT_NAME}}}" ;;
"off") distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;;
esac
elif [[ -f "/etc/GoboLinuxVersion" ]]; then elif [[ -f "/etc/GoboLinuxVersion" ]]; then
case "$distro_shorthand" in case "$distro_shorthand" in
"on" | "tiny") distro="GoboLinux" ;; "on" | "tiny") distro="GoboLinux" ;;
...@@ -906,23 +923,6 @@ get_distro() { ...@@ -906,23 +923,6 @@ get_distro() {
elif [[ -f "/etc/lsb-release" && "$(< /etc/lsb-release)" == *CHROMEOS* ]]; then elif [[ -f "/etc/lsb-release" && "$(< /etc/lsb-release)" == *CHROMEOS* ]]; then
distro="$(awk -F '=' '/NAME|VERSION/ {printf $2 " "}' /etc/lsb-release)" distro="$(awk -F '=' '/NAME|VERSION/ {printf $2 " "}' /etc/lsb-release)"
elif [[ -f "/etc/os-release" || \
-f "/usr/lib/os-release" || \
-f "/etc/openwrt_release" ]]; then
files=("/etc/os-release" "/usr/lib/os-release" "/etc/openwrt_release")
# Source the os-release file
for file in "${files[@]}"; do
source "$file" && break
done
# Format the distro name.
case "$distro_shorthand" in
"on") distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;;
"tiny") distro="${NAME:-${DISTRIB_ID:-${TAILS_PRODUCT_NAME}}}" ;;
"off") distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;;
esac
elif type -p guix >/dev/null; then elif type -p guix >/dev/null; then
case "$distro_shorthand" in case "$distro_shorthand" in
"on" | "tiny") distro="GuixSD" ;; "on" | "tiny") distro="GuixSD" ;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment