From 1a3aea490feaaae4c7f63418c8b460c2408056a8 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Sat, 18 Jan 2014 17:48:35 -0800 Subject: Try to improve cleanup (and not forget a build when another arch fails) --- lib/Iurt/File.pm | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'lib/Iurt/File.pm') diff --git a/lib/Iurt/File.pm b/lib/Iurt/File.pm index 42943de..9eb00f7 100644 --- a/lib/Iurt/File.pm +++ b/lib/Iurt/File.pm @@ -1,22 +1,15 @@ package Iurt::File; use base qw(Exporter); +use File::Copy 'move'; use Iurt::Util qw(plog); use strict; our @EXPORT = qw( check_upload_tree + cleanup_failed_build ); -=head2 config_usage($config_usage, $config) - -Create an instance of a class at runtime. -I<$config_usage> is the configuration help, -I<%config> is the current configuration values -Return true. - -=cut - sub check_upload_tree { my ($todo, $func, $o_post) = @_; @@ -66,3 +59,35 @@ sub check_upload_tree { } } +sub cleanup_failed_build { + my ($todo_dir, $done_dir, $fail_dir, $prefix, $ent) = @_; + + foreach my $rpm (@{$ent->{rpms}}) { + my $file = "$done_dir/${prefix}_$rpm"; + plog('DEBUG', "moving built rpm $file to $fail_dir/"); + move($file, "$fail_dir/${prefix}_$rpm"); + } + delete $ent->{rpms}; + + foreach my $srpm (@{$ent->{srpms}}) { + my $file = "$todo_dir/${prefix}_$srpm"; + plog('DEBUG', "moving $file to $fail_dir/"); + move($file, "$fail_dir/${prefix}_$srpm"); + # If one arch has been generated, we also have a src.rpm in done + $file = "$done_dir/${prefix}_$srpm"; + if (-f $file) { + plog('DEBUG', "deleting $file"); + unlink $file; + } + } + delete $ent->{srpms}; + + if (-d "$done_dir/$prefix") { + make_path("$fail_dir/$prefix"); + for my $file (glob "$done_dir/$prefix/*") { + plog('DEBUG', "moving $file to $fail_dir/$prefix/"); + move($file, "$fail_dir/$prefix/"); + } + } +} + -- cgit v1.2.1