From 49f81c6936211d6cf1fe398ba5d7edc30468a4e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Wed, 21 May 2014 10:02:46 +0200 Subject: [PATCH] Remove RPMS directory when reseting 'rotate' state There is a new method F::R::Package::reset_rotate() for that. It's called from F::R::Package::reset() automatically. Not pruning RPMS directory with build binary packages caused rewriting the package files content. This broke YUM downloading the package when building a reverse dependency in the same build cycle as the binary package has been rebuilt. This affected dual-lived packages only. --- lib/Fedora/Rebuild/Package.pm | 48 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/lib/Fedora/Rebuild/Package.pm b/lib/Fedora/Rebuild/Package.pm index dd915e3..3288df0 100644 --- a/lib/Fedora/Rebuild/Package.pm +++ b/lib/Fedora/Rebuild/Package.pm @@ -251,10 +251,15 @@ sub reset { 'build', 'rpms', 'providesstore', 'runrequiresstore', 'rotate', 'buildrequires', 'runrequires', 'provides') { $lock->log("Removing state lock $state\n"); - my $state_lock = Fedora::Rebuild::Package::StateLock->new( - package => $self, state => $state); - $state_lock->mark_failed; - $state_lock->remove_log; + + if ($state eq 'rotate') { + $self->reset_rotate; + } else { + my $state_lock = Fedora::Rebuild::Package::StateLock->new( + package => $self, state => $state); + $state_lock->mark_failed; + $state_lock->remove_log; + } } $lock->log("States reset done.\n"); @@ -497,13 +502,26 @@ sub get_srpm_name { return $srpmname; } +# Remove a directory recursively, if it exists. +# First argument is the directory, second argument is lock to log errors into. +# Return true, false in case of error. +# XXX: This is not a method +sub remove_directory { + my ($lock, $directory) = @_; + if (!File::Path::Tiny::rm($directory)) { + $lock->log("Could not remove directory `" . $directory . "': $!\n"); + return 0; + } + return 1; +} + # Create a directory. If it exists, it will remove it before. # First argument is the directory, second argument is lock to log errors into. # Return true, false in case of error. # XXX: This is not a method sub replace_directory { my ($lock, $directory) = @_; - if (-d $directory) { File::Path::Tiny::rm($directory); } + remove_directory($lock, $directory); if (!File::Path::Tiny::mk($directory)) { $lock->log("Could not create directory `" . $directory . "': $!\n"); return 0; @@ -1073,6 +1091,26 @@ sub dowaitforbuildroot { return $lock->mark_done; } + +# Reset 'rotate' state by removing directory with binary packages produced by +# the package. +# TODO: Untag package from koji? +# Return true on success, otherwise false. +sub reset_rotate { + my ($self) = @_; + + my $lock = Fedora::Rebuild::Package::StateLock->new( + package => $self, state => 'rotate'); + $lock->log("Reseting state...\n"); + if (!remove_directory($lock, $self->rpmdir)) { + return $lock->mark_failed; + } + $lock->mark_failed; + $lock->remove_log; + return 1; +} + + # Set hash of build-time dependencies (requires attribute). # First argument is Fedora::Rebuild::Package::Config object. If mode member is: # "local" build SRPM locally using fedpkg, -- 2.11.4.GIT