install.sh: use $ID_LIKE to detect distro (#2423)
This commit is contained in:
parent
32c5ed8a33
commit
f8dc3fccac
27
install.sh
27
install.sh
@ -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"
|
||||
)
|
||||
|
Reference in New Issue
Block a user