Archived
1
0

install.sh: use $ID_LIKE to detect distro (#2423)

This commit is contained in:
Oxylibrium 2020-12-15 02:48:24 +05:30 committed by GitHub
parent 32c5ed8a33
commit f8dc3fccac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -238,10 +238,10 @@ main() {
macos)
install_macos
;;
ubuntu | debian | raspbian)
debian)
install_deb
;;
centos | fedora | rhel | opensuse)
fedora | opensuse)
install_rpm
;;
arch)
@ -425,14 +425,16 @@ os() {
}
# distro prints the detected operating system including linux distros.
# Also parses ID_LIKE for common distro bases.
#
# Example outputs:
# - macos
# - debian, ubuntu, raspbian
# - centos, fedora, rhel, opensuse
# - alpine
# - arch
# - freebsd
# - macos -> macos
# - freebsd -> freebsd
# - ubuntu, raspbian, debian ... -> debian
# - amzn, centos, rhel, fedora, ... -> fedora
# - opensuse-{leap,tumbleweed} -> opensuse
# - alpine -> alpine
# - arch -> arch
#
# Inspired by https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120.
distro() {
@ -444,12 +446,15 @@ distro() {
if [ -f /etc/os-release ]; then
(
. /etc/os-release
case "$ID" in opensuse-*)
# opensuse's ID's look like opensuse-leap and opensuse-tumbleweed.
echo "opensuse"
if [ "${ID_LIKE-}" ]; then
for id_like in $ID_LIKE; do
case "$id_like" in debian | fedora | opensuse)
echo "$id_like"
return
;;
esac
done
fi
echo "$ID"
)