diff options
author | Pascal Terjan <pterjan@mageia.org> | 2021-01-19 19:34:09 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@mageia.org> | 2021-01-19 19:35:44 +0000 |
commit | 5e57573ce7fc0eb9b276c3ab4a23d483b1d90ef4 (patch) | |
tree | 7462a936d3ef7c6733cf2c22af7cae2ce7978c7a /modules | |
parent | 094e2237c5468e9f8041deeeb5267866b480fbe5 (diff) | |
download | puppet-5e57573ce7fc0eb9b276c3ab4a23d483b1d90ef4.tar puppet-5e57573ce7fc0eb9b276c3ab4a23d483b1d90ef4.tar.gz puppet-5e57573ce7fc0eb9b276c3ab4a23d483b1d90ef4.tar.bz2 puppet-5e57573ce7fc0eb9b276c3ab4a23d483b1d90ef4.tar.xz puppet-5e57573ce7fc0eb9b276c3ab4a23d483b1d90ef4.zip |
Delete leftover noarch without waiting for 7d
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/buildsystem/templates/cleaner.rb | 24 | ||||
-rw-r--r-- | modules/buildsystem/templates/cleaner_test.rb | 12 |
2 files changed, 24 insertions, 12 deletions
diff --git a/modules/buildsystem/templates/cleaner.rb b/modules/buildsystem/templates/cleaner.rb index e9ff8cb6..1bdf393a 100755 --- a/modules/buildsystem/templates/cleaner.rb +++ b/modules/buildsystem/templates/cleaner.rb @@ -121,7 +121,7 @@ end def packages(path) `urpmf --synthesis "#{path}/media_info/synthesis.hdlist.cz" --qf '%sourcerpm:%filename' ":"`.each_line{|l| - yield l + yield *(l.rstrip.split(':')) } end @@ -131,10 +131,8 @@ end def check_binaries(srcs, srcages, path, used_srcs) used_here_srcs = {} - packages(path) {|l| - l2 = l.split(':') - src = l2[0] - filename = l2[1].rstrip + all_versions = {} + packages(path) {|src, filename| used_srcs[src] = true if used_srcs != nil if filename =~ /noarch.rpm$/ then # We need to mark the src.rpm present on this arch only for full noarch packages @@ -142,18 +140,22 @@ def check_binaries(srcs, srcages, path, used_srcs) else used_here_srcs[src] = true end + name = name_from_filename(filename) + if all_versions[name] then + all_versions[name] << src + else + all_versions[name] = [src] + end } old_binaries = [] - packages(path) {|l| - l2 = l.split(':') - src = l2[0] - filename = l2[1].rstrip + packages(path) {|src, filename| if ! srcs[src] then srcname = name_from_filename(src) if srcages[srcname] then # The src.rpm is gone but there is a different version of it - # Only delete old binaries after 7d - next unless srcages[srcname][1] < Time.now.to_i - 24*60*60*7 + # Only delete old binaries after 7d or if there is a new version + name = name_from_filename(filename) + next unless (srcages[srcname][1] < Time.now.to_i - 24*60*60*7 || all_versions[name].include?(src)) # Do not delete if the new version of the package hasn't been built for this arch yet next unless used_here_srcs[srcages[srcname][0]] end diff --git a/modules/buildsystem/templates/cleaner_test.rb b/modules/buildsystem/templates/cleaner_test.rb index b8b9ad84..d1f343e2 100644 --- a/modules/buildsystem/templates/cleaner_test.rb +++ b/modules/buildsystem/templates/cleaner_test.rb @@ -10,7 +10,7 @@ class TestCleaner < Test::Unit::TestCase end def packages(path) - @pkgs.map{|p| yield "#{p}\n"} + @pkgs.map{|p| yield *p.split(":")} end def test_old @@ -43,4 +43,14 @@ class TestCleaner < Test::Unit::TestCase assert_equal([], check_binaries(srcs, srcages, '', nil)) end + def test_multiple_versions + # Old package remains (usually happens to noarch due to youri bug) + $noarch = { 'foo' => true } + setpackages(['foo-42-1.src.rpm:foo-42-1.noarch.rpm', 'foo-42-2.src.rpm:foo-42-2.noarch.rpm']) + srcages = {} + srcages['foo'] = [ 'foo-42-2.src.rpm', Time.now.to_i - 24*3600 ] + srcs = {} + srcs['foo-42-2.src.rpm'] = true + assert_equal(['foo-42-1.noarch.rpm'], check_binaries(srcs, srcages, '', nil)) + end end |