diff options
author | Pascal Terjan <pterjan@mageia.org> | 2012-04-05 20:45:26 +0000 |
---|---|---|
committer | Pascal Terjan <pterjan@mageia.org> | 2012-04-05 20:45:26 +0000 |
commit | 776e7208a833def0b07a02d115a1c9dcf5e1e739 (patch) | |
tree | 9fa696b6e20f9ecad29414e32d97ea12afb896d7 /modules/mirror_cleaner | |
parent | 1bc94be96b1a8b54502aaa708e4634b98919edb5 (diff) | |
download | puppet-776e7208a833def0b07a02d115a1c9dcf5e1e739.tar puppet-776e7208a833def0b07a02d115a1c9dcf5e1e739.tar.gz puppet-776e7208a833def0b07a02d115a1c9dcf5e1e739.tar.bz2 puppet-776e7208a833def0b07a02d115a1c9dcf5e1e739.tar.xz puppet-776e7208a833def0b07a02d115a1c9dcf5e1e739.zip |
Add some extra safety
Diffstat (limited to 'modules/mirror_cleaner')
-rwxr-xr-x | modules/mirror_cleaner/files/orphans_cleaner.pl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/modules/mirror_cleaner/files/orphans_cleaner.pl b/modules/mirror_cleaner/files/orphans_cleaner.pl index ff4f12e5..f1af3dee 100755 --- a/modules/mirror_cleaner/files/orphans_cleaner.pl +++ b/modules/mirror_cleaner/files/orphans_cleaner.pl @@ -23,15 +23,16 @@ my %hash ; my ($filename, $srpm, $dest_rpm); -my ($source_hdlist, $binary_hdlist, $rpm_path); +my ($source_hdlist, $binary_hdlist, $rpm_path, $srpm_path); foreach my $a ( @arches ) { foreach my $s ( @sections ) { foreach my $m ( @medias ) { $rpm_path = "$path/$a/media/$s/$m"; + $srpm_path = "$path/SRPMS/$s/$m"; $binary_hdlist = "$rpm_path/media_info/hdlist.cz"; - $source_hdlist = "$path/SRPMS/$s/$m/media_info/hdlist.cz"; + $source_hdlist = "$srpm_path/media_info/hdlist.cz"; next if not -f $source_hdlist; next if not -f $binary_hdlist; @@ -54,9 +55,11 @@ foreach my $a ( @arches ) { } close($hdfh); - foreach my $v ( values %hash ) + foreach my $s ( keys %hash ) { - foreach my $rpm ( @{$v} ) { + # Be safe, maybe hdlists were not in sync + next if -f "$srpm_path/$s"; + foreach my $rpm ( @{$hash{$s}} ) { $rpm = "$rpm_path/$rpm"; # sometimes, packages are removed without hdlist to be updated next if not -f "$rpm"; @@ -66,7 +69,7 @@ foreach my $a ( @arches ) { make_path $dir if not -d $dir; move($rpm, $dest_rpm) } - } + } } } } |