From e0663c12dc0dbe367566ba3544b1afa0ee8c965d Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Sun, 12 Oct 2014 22:31:31 +0000 Subject: behave better when local_spool is out of space --- NEWS | 2 ++ iurt | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 05b9c8b..f0c3dfa 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ - remove old src.rpm before recreating it (mga#14243) +- delete potentially incomplete files when copying to local_spool + fails (like when disk is full) 0.6.22 - don't close stdin if --stop is used (mga#13318) diff --git a/iurt b/iurt index 25ea5f2..1227d29 100755 --- a/iurt +++ b/iurt @@ -929,15 +929,24 @@ retry: system("rm -rf $local_spool/log/$srpm/"); } elsif (!$run{discard_packages}) { plog('OK', "build successful, copying packages to $local_spool."); - - system("cp $chroot_tmp/home/$luser/rpmbuild/RPMS/*/*.rpm $local_spool &>/dev/null") and plog('ERROR', "ERROR: could not copy rpm files from $chroot_tmp/home/$luser/rpmbuild/RPMS/ to $local_spool ($!)"); + if (system("cp $chroot_tmp/home/$luser/rpmbuild/RPMS/*/*.rpm $local_spool &>/dev/null")) { + # If copy fails (like disk full), report a failure and delete partially copied files + for my $package (@packages) { + unlink "$local_spool/$package"; + } + plog('ERROR', "ERROR: could not copy rpm files from $chroot_tmp/home/$luser/rpmbuild/RPMS/ to $local_spool ($!)"); + } } if ($run{copy_srpm}) { # replace the old srpm unlink "$local_spool/$old_srpm"; - system("cp $chroot_tmp/home/$luser/rpmbuild/SRPMS/$srpm $local_spool &>/dev/null") and plog('ERROR', "ERROR: could not copy $srpm from $chroot_tmp/home/$luser/rpmbuild/SRPMS/ to $local_spool ($!)"); + if (system("cp $chroot_tmp/home/$luser/rpmbuild/SRPMS/$srpm $local_spool &>/dev/null")) { + # If copy fails (like disk full), remove partially copied file and report a failure + unlink "$local_spool/$srpm"; + plog('ERROR', "ERROR: could not copy $srpm from $chroot_tmp/home/$luser/rpmbuild/SRPMS/ to $local_spool ($!)"); + } } process_queue($config, \%run, \@wrong_rpm, 1); } -- cgit v1.2.1