Skip to content

Commit 178c3dc

Browse files
author
Akash Satheesan
committed
install.sh: use $ID_LIKE to detect distro
1 parent 32c5ed8 commit 178c3dc

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

install.sh

+19-14
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ main() {
238238
macos)
239239
install_macos
240240
;;
241-
ubuntu | debian | raspbian)
241+
debian)
242242
install_deb
243243
;;
244-
centos | fedora | rhel | opensuse)
244+
fedora | opensuse)
245245
install_rpm
246246
;;
247247
arch)
@@ -425,14 +425,16 @@ os() {
425425
}
426426

427427
# distro prints the detected operating system including linux distros.
428+
# Also parses ID_LIKE for common distro bases.
428429
#
429430
# Example outputs:
430-
# - macos
431-
# - debian, ubuntu, raspbian
432-
# - centos, fedora, rhel, opensuse
433-
# - alpine
434-
# - arch
435-
# - freebsd
431+
# - macos -> macos
432+
# - freebsd -> freebsd
433+
# - ubuntu, raspbian, debian ... -> debian
434+
# - amzn, centos, rhel, fedora, ... -> fedora
435+
# - opensuse-{leap,tumbleweed} -> opensuse
436+
# - alpine -> alpine
437+
# - arch -> arch
436438
#
437439
# Inspired by https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120.
438440
distro() {
@@ -444,12 +446,15 @@ distro() {
444446
if [ -f /etc/os-release ]; then
445447
(
446448
. /etc/os-release
447-
case "$ID" in opensuse-*)
448-
# opensuse's ID's look like opensuse-leap and opensuse-tumbleweed.
449-
echo "opensuse"
450-
return
451-
;;
452-
esac
449+
if [ "${ID_LIKE-}" ]; then
450+
for id_like in $ID_LIKE; do
451+
case "$id_like" in debian | fedora | opensuse)
452+
echo "$id_like"
453+
return
454+
;;
455+
esac
456+
done
457+
fi
453458

454459
echo "$ID"
455460
)

0 commit comments

Comments
 (0)