Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse os-release to identify OS by ID_LIKE field (i.e. make install-dependencies.sh work on Amazon Linux 2023) #3155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/Misc/layoutbin/installdependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ function print_rhel6errormessage()
echo "https://github.com/dotnet/core/blob/master/Documentation/build-and-install-rhel6-prerequisites.md"
}

if [ -e /etc/os-release ]
# As per https://www.freedesktop.org/software/systemd/man/latest/os-release.html
# Snippet licensed under:
# # SPDX-License-Identifier: MIT-0
test -e /etc/os-release && os_release='/etc/os-release' || os_release='/usr/lib/os-release'
. "${os_release}"

if [ -e ${os_release} ]
then
echo "--------OS Information--------"
cat /etc/os-release
cat ${os_release}
echo "------------------------------"

if [ -e /etc/debian_version ]
if [ "${ID:-linux}" = "debian" ] || [ "${ID_LIKE#*debian*}" != "${ID_LIKE}" ];
then
echo "The current OS is Debian based"
echo "--------Debian Version--------"
Expand Down Expand Up @@ -117,16 +123,14 @@ then
print_errormessage
exit 1
fi
elif [ -e /etc/redhat-release ]
elif [ "${ID:-linux}" = "fedora" ] || [ "${ID_LIKE#*fedora*}" != "${ID_LIKE}" ];
then
echo "The current OS is Fedora based"
echo "--Fedora/RHEL/CentOS Version--"
cat /etc/redhat-release
echo "------------------------------"
echo "The current OS is: ${PRETTY_NAME}, which is like Fedora"
test -e /etc/redhat-release && (echo "------------------------------"; cat /etc/redhat-release; echo "------------------------------")

# use dnf on fedora
# use yum on centos and rhel
if [ -e /etc/fedora-release ]
if [ "${ID}" != "centos" ] && [ "${ID}" != "rhel" ];
then
command -v dnf
if [ $? -eq 0 ]
Expand Down