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

Move remap logic from install.sh to omnitruck #259

Merged
merged 2 commits into from
Jul 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/mixlib/install/generator/bourne/scripts/platform_detection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,14 @@ elif test -f "/etc/redhat-release"; then
platform="el"
fi

# detect amazon linux 2013/2014 which lack /etc/os-release
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/etc/system-release is some fedora-ism, though, not just amazon linux.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i think /etc/redhat-release -> /etc/system-release in fedora at some point, but then systemd's /etc/os-release came along. amazon uses /etc/system-release because they're a "fedoraish" distro which has not yet gone to /etc/os-release, but that can't necessarily be relied upon to uniquely detect amazon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or it looks like they do have /etc/os-release... anyway point stands that none of these files are unique to amazon..)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2015+ they switched to os-release. We already had the os-release logic so this way we're just going to continue the same old logic we had, but if we get back amzn from os-release we'll convert it to amazon. That will be a nice future proof way to get the version number without brittle regexing of the release name. For 2013/2014 we'll fall back to that crummy old regex.

elif test -f "/etc/system-release"; then
platform=`sed 's/^\(.\+\) release.\+/\1/' /etc/system-release | tr '[A-Z]' '[a-z]'`
platform_version=`sed 's/^.\+ release \([.0-9]\+\).*/\1/' /etc/system-release | tr '[A-Z]' '[a-z]'`
# amazon is built off of centos, so act like RHEL
# Version 1. Example: Amazon Linux AMI release 2017.09
if test "$platform" = "amazon linux ami"; then
platform="el"
platform_version="6.0"
# Version 2. Example: Amazon Linux release 2.0 (2017.12)
elif test "$platform" = "amazon linux"; then
platform="el"
platform_version="7.0"
platform="amazon"
fi

# Apple OS X
elif test -f "/usr/bin/sw_vers"; then
platform="mac_os_x"
Expand Down Expand Up @@ -110,7 +105,13 @@ elif test -f "/etc/os-release"; then
. $CISCO_RELEASE_INFO
fi

platform=$ID
# return amazon on amazon linux 2015+ systems which have /etc/os-release
if test "$ID" = "amzn"; then
platform="amazon"
else
platform=$ID
fi

platform_version=$VERSION
fi

Expand Down