diff --git a/lib/train/platforms/detect/helpers/os_linux.rb b/lib/train/platforms/detect/helpers/os_linux.rb index 704c6b7f..47647e96 100644 --- a/lib/train/platforms/detect/helpers/os_linux.rb +++ b/lib/train/platforms/detect/helpers/os_linux.rb @@ -10,8 +10,8 @@ def redhatish_version(conf) case conf when /rawhide/i /((\d+) \(Rawhide\))/i.match(conf)[1].downcase - when /Amazon Linux AMI/i - /release ([\d\.]+)/.match(conf)[1] + when /Amazon Linux/i + /([\d\.]+)/.match(conf)[1] when /derived from .*linux|amazon/i /Linux ((\d+|\.)+)/i.match(conf)[1] else diff --git a/test/unit/platforms/detect/os_linux_test.rb b/test/unit/platforms/detect/os_linux_test.rb index bbe42ba1..4b358612 100644 --- a/test/unit/platforms/detect/os_linux_test.rb +++ b/test/unit/platforms/detect/os_linux_test.rb @@ -28,6 +28,14 @@ class OsDetectLinuxTester it 'normal linux' do detector.redhatish_version('derived from Ubuntu Linux 11').must_equal('11') end + + it 'amazon linux 2 new release naming schema' do + detector.redhatish_version('Amazon Linux release 2 (Karoo)').must_equal('2') + end + + it 'amazon linux 2 old release naming schema' do + detector.redhatish_version('Amazon Linux 2').must_equal('2') + end end describe 'lsb parse' do