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

Add support for detecting release version on CentOS 5 and CentOS 6 #17

Merged
merged 2 commits into from
Mar 8, 2016
Merged

Add support for detecting release version on CentOS 5 and CentOS 6 #17

merged 2 commits into from
Mar 8, 2016

Conversation

irasnyd
Copy link
Contributor

@irasnyd irasnyd commented Jan 27, 2016

This is implemented by parsing the /etc/redhat-release file, looking for
the first instance of any two numbers separated by a '.' character. This
has held true for all versions of CentOS 5 and 6.

Examples of /etc/redhat-release from both versions:
CentOS release 5.11 (Final)
CentOS release 6.7 (Final)

This is implemented by parsing the /etc/redhat-release file, looking for
the first instance of any two numbers separated by a '.' character. This
has held true for all versions of CentOS 5 and 6.

Examples of /etc/redhat-release from both versions:
CentOS release 5.11 (Final)
CentOS release 6.7 (Final)
@trustin
Copy link
Owner

trustin commented Mar 7, 2016

@irasnyd Sorry for a late reply. Could your modification also be applied for RHEL and Fedora? If so, could you update your PR so that it also detects RHEL, Fedora, and potentially other distributions?

@trustin trustin self-assigned this Mar 7, 2016
This is implemented by parsing the /etc/redhat-release file, and looking for
the first number in the line. This is the release major version.
@irasnyd
Copy link
Contributor Author

irasnyd commented Mar 7, 2016

From my experience with CentOS, just matching the first number in /etc/redhat-release is sufficient to retrieve the distro major version number. The URL below shows that this will work for Fedora also. (I use CentOS exclusively, so I cannot test on RHEL or Fedora.)

http://www.putorius.net/2012/09/how-to-find-which-version-of-red-hat-is.html

I moved the version detection outside of the if statement, as it now applies to all of the older distros which use the /etc/redhat-release file. I also added a new regex which just matches a single number, since the VERSION_REGEX matches two numbers separated by a dot. This is so that Fedora will work (Fedora does not have sub-versions).

@trustin
Copy link
Owner

trustin commented Mar 7, 2016

Thanks for a quick update! LGTM.

@nmittler, wanna take a look as well?

@nmittler
Copy link
Contributor

nmittler commented Mar 7, 2016

LGTM ... thanks @irasnyd :)

trustin added a commit that referenced this pull request Mar 8, 2016
Add support for detecting release version on CentOS 5 and CentOS 6
@trustin trustin merged commit 7a90e2c into trustin:master Mar 8, 2016
@trustin trustin added this to the 1.5.0.Final milestone Mar 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants