From e650d58583aa48a03f5e9f0ce2621be54cfcee40 Mon Sep 17 00:00:00 2001 From: Joe Ray Date: Fri, 12 Jan 2018 11:53:09 +0000 Subject: [PATCH] featurens: Ensure RHEL is correctly identified When trying to identify various RedHat releases, RHEL was not being picked up as a centos release because the Oracle Linux regex was too permissive: it would match any release name with ' Linux Server release' in the name. By being more restrictive with the Oracle regex, RHEL is now properly identified. I don't know why the Oracle regex used such a permissive matcher for the name but it still passes all the tests by replacing it with the word 'Oracle'. Fixes #436 --- ext/featurens/redhatrelease/redhatrelease.go | 2 +- ext/featurens/redhatrelease/redhatrelease_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/featurens/redhatrelease/redhatrelease.go b/ext/featurens/redhatrelease/redhatrelease.go index 2b15c1e9..0dabc3fa 100644 --- a/ext/featurens/redhatrelease/redhatrelease.go +++ b/ext/featurens/redhatrelease/redhatrelease.go @@ -30,7 +30,7 @@ import ( ) var ( - oracleReleaseRegexp = regexp.MustCompile(`(?P[^\s]*) (Linux Server release) (?P[\d]+)`) + oracleReleaseRegexp = regexp.MustCompile(`(?POracle) (Linux Server release) (?P[\d]+)`) centosReleaseRegexp = regexp.MustCompile(`(?P[^\s]*) (Linux release|release) (?P[\d]+)`) redhatReleaseRegexp = regexp.MustCompile(`(?PRed Hat Enterprise Linux) (Client release|Server release|Workstation release) (?P[\d]+)`) ) diff --git a/ext/featurens/redhatrelease/redhatrelease_test.go b/ext/featurens/redhatrelease/redhatrelease_test.go index 5ee32f18..4a2da907 100644 --- a/ext/featurens/redhatrelease/redhatrelease_test.go +++ b/ext/featurens/redhatrelease/redhatrelease_test.go @@ -42,6 +42,12 @@ func TestDetector(t *testing.T) { "etc/centos-release": []byte(`CentOS release 6.6 (Final)`), }, }, + { + ExpectedNamespace: &database.Namespace{Name: "centos:7"}, + Files: tarutil.FilesMap{ + "etc/redhat-release": []byte(`Red Hat Enterprise Linux Server release 7.2 (Maipo)`), + }, + }, { ExpectedNamespace: &database.Namespace{Name: "centos:7"}, Files: tarutil.FilesMap{