From e6df6f10f485e0bf283c428c371fa2606b7faaa5 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Wed, 20 Apr 2016 10:40:25 -0400 Subject: [PATCH] Fixes #12266: Handle last RPM sort for more than 10 bootstrap RPMs Old method of sorting used string based comparisons which after 10 release versions fails to sort properly. This moves to a method of comparing individual releases via integer comparison to derive the latest boostrap RPM. --- .../provider/certs_bootstrap_rpm/katello_ssl_tool.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb b/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb index 3a47922a..56f3d645 100644 --- a/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb +++ b/lib/puppet/provider/certs_bootstrap_rpm/katello_ssl_tool.rb @@ -33,7 +33,17 @@ def run protected def last_rpm - Dir.glob(File.join(resource[:dir], "#{resource[:name]}-*.noarch.rpm")).sort.last + rpms = Dir.glob(File.join(resource[:dir], "#{resource[:name]}-*.noarch.rpm")) + + rpms = rpms.collect do |rpm| + rpm_split = rpm.split("#{resource[:name]}-")[1].split('.noarch.rpm')[0] + version = rpm_split.split('-')[0] + release = rpm_split.split('-')[1] + + {'release' => release, 'rpm' => rpm} + end + + rpms.sort { |a,b| a['release'].to_i <=> b['release'].to_i }.last end def next_release