aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@google.com>2014-01-18 17:48:35 -0800
committerPascal Terjan <pterjan@gmail.com>2014-01-19 05:13:33 +0000
commit1a3aea490feaaae4c7f63418c8b460c2408056a8 (patch)
tree855fdb19389f9334a55fe3a7aab4c01f95838bde /lib
parent21b8a3556aff1c9ac1b0f8defe8e9abb8a9d1b23 (diff)
downloadiurt-1a3aea490feaaae4c7f63418c8b460c2408056a8.tar
iurt-1a3aea490feaaae4c7f63418c8b460c2408056a8.tar.gz
iurt-1a3aea490feaaae4c7f63418c8b460c2408056a8.tar.bz2
iurt-1a3aea490feaaae4c7f63418c8b460c2408056a8.tar.xz
iurt-1a3aea490feaaae4c7f63418c8b460c2408056a8.zip
Try to improve cleanup (and not forget a build when another arch fails)
Diffstat (limited to 'lib')
-rw-r--r--lib/Iurt/File.pm43
1 files changed, 34 insertions, 9 deletions
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/");
+ }
+ }
+}
+