Skip to content

Commit 6167244

Browse files
author
Akash Satheesan
committed
install.sh: use $ID_LIKE to detect distro
1 parent 1dd7e4b commit 6167244

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

install.sh

+18-16
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,16 +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
436-
#
437-
# Inspired by https://github.com/docker/docker-install/blob/26ff363bcf3b3f5a00498ac43694bf1c7d9ce16c/install.sh#L111-L120.
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
438438
distro() {
439439
if [ "$OS" = "macos" ] || [ "$OS" = "freebsd" ]; then
440440
echo "$OS"
@@ -444,12 +444,14 @@ distro() {
444444
if [ -f /etc/os-release ]; then
445445
(
446446
. /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
447+
if [ "${ID_LIKE-}" ]; then
448+
for id_like in $ID_LIKE; do
449+
case "$id_like" in debian | fedora | opensuse)
450+
echo "$id_like"
451+
return
452+
esac
453+
done
454+
fi
453455

454456
echo "$ID"
455457
)

0 commit comments

Comments
 (0)