From aebf7990690d3b37b8f7b6dd3d7170662425d126 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Thu, 16 Jun 2011 14:43:28 +0200 Subject: [PATCH] Cache provides If provides have not been in chache yet, they will be destilled from binary packages automatically. --- lib/Fedora/Rebuild/Package.pm | 69 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 9 deletions(-) diff --git a/lib/Fedora/Rebuild/Package.pm b/lib/Fedora/Rebuild/Package.pm index 65914ea..6c12bd7 100644 --- a/lib/Fedora/Rebuild/Package.pm +++ b/lib/Fedora/Rebuild/Package.pm @@ -34,6 +34,8 @@ has 'rpmdir' => (is => 'ro', isa => 'Str', lazy_build => 1, init_arg => undef); has 'requiresstore' => (is => 'ro', isa => 'Str', lazy_build => 1, init_arg => undef); +has 'providesstore' => (is => 'ro', isa => 'Str', lazy_build => 1, + init_arg => undef); has 'branch' => (is => 'ro', isa => 'Str', lazy_build => 1, init_arg => undef); #has 'srpm' => (is => 'ro', isa => 'RPM2::Header', lazy_build => 1, @@ -97,6 +99,11 @@ sub _build_requiresstore { return File::Spec->catfile($self->packagedir, 'buildrequires.store'); } +sub _build_providesstore { + my $self = shift; + return File::Spec->catfile($self->packagedir, 'provides.store'); +} + sub _build_branch { my $self = shift; if ($self->dist eq 'rawhide') { @@ -286,17 +293,16 @@ sub binaryrpm { return $lock->mark_done; } -# Destile Provides from rebuilt binary packages. Return true on success. +# Destile Provides from rebuilt binary packages and serialize them into file. +# Return true on success. # Needs `rpms'. # FIXME: does not work after cleaning clone or doing update. -sub get_binaryprovides { +sub storebinaryprovides { my $self = shift; my $lock = Fedora::Rebuild::Package::StateLock->new(package => $self, - state => 'provides'); + state => 'providesstore'); if ($lock->is_done) { return 1; } - print "Getting binary provides for `" . $self->name . "'...\n"; - my @rpms = glob(File::Spec->catfile($self->rpmdir, '*.rpm')); if ($#rpms < 0) { $lock->log("No binary RPM packages found in `" . $self->rpmdir @@ -309,17 +315,41 @@ sub get_binaryprovides { my $rpm = Fedora::Rebuild::RPM->new(name => $rpmname); my $provides = $rpm->provides; if (! defined $provides) { - $lock->log("Could not get provides of RPM `" . $rpmname . "': ". + $lock->log("Could not get provides of RPM `" . $rpmname . "': " . $@ ."\n"); return $lock->mark_failed; } Fedora::Rebuild::RPM::adddeps($allprovides, $provides); } - $self->provides(shared_clone($allprovides)); + + if (! $lock->nstorereference($allprovides, $self->providesstore)) { + $lock->log("Could not store provides of RPM `". $self->name . + "' into `" . $self->providesstore . "' file: $@\n"); + return $lock->mark_failed; + } + + $lock->log(Data::Dumper::Dumper($self->provides)); + return $lock->mark_done; +} + +# Load provides of already rebuilt binary packages from file. +# Return true on success. +# Needs `storebinaryprovides'. +sub loadbinaryprovides { + my $self = shift; + my $lock = Fedora::Rebuild::Package::StateLock->new(package => $self, + state => 'provides'); + if ($lock->is_done) { return 1; } + + my $provides = $lock->retrievereference($self->providesstore); + if (! $provides) { + $lock->log("Could not load provides of `". $self->name . + "' package from `" . $self->providesstore . "' file: $@\n"); + return $lock->mark_failed; + } + $self->provides(shared_clone($provides)); $lock->log(Data::Dumper::Dumper($self->provides)); - print "Provides for `" . $self->name . - "' package distilled successfully.\n"; return $lock->mark_done; } @@ -515,6 +545,27 @@ sub get_buildrequires { } } +# Set hash of run-time provides (provides attribute). +# Return true on success, undef in case of failure. +# XXX: Requires `providesstore' +sub get_binaryprovides { + my $self = shift; + my $ok; + print "Getting binary provides for `" . $self->name . "'...\n"; + + $ok = $self->storebinaryprovides; + $ok = $self->loadbinaryprovides if $ok; + + if ($ok) { + print "Provides for `" . $self->name . + "' package distilled successfully.\n"; + return 1; + } else { + print "Could not get Provides for `" . $self->name . "' package.\n"; + return undef; + } +} + # Rebuild a package. # If first argument is true, build locally without pushing commits to server. # Otherwise publish commit and build in Koji. -- 2.11.4.GIT