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
1 changed files with 19 additions and 14 deletions

View File

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