From 7eb09b4485a5f0ec265b586d59ea3ef6fcca8af9 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Wed, 16 Oct 2024 15:54:47 +0200 Subject: [PATCH] Add a updatelocalgbininfo RepoMgr method Also drop the builddir parameter, as it is part of the repo data structure. --- PBuild/RepoMgr.pm | 17 +++++++++++++++-- PBuild/Result.pm | 8 ++++++-- pbuild | 9 ++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/PBuild/RepoMgr.pm b/PBuild/RepoMgr.pm index d96f044c8..3783ba3b9 100644 --- a/PBuild/RepoMgr.pm +++ b/PBuild/RepoMgr.pm @@ -23,6 +23,7 @@ package PBuild::RepoMgr; use strict; use PBuild::Util; +use PBuild::LocalRepo; use PBuild::RemoteRepo; use PBuild::RemoteRegistry; use PBuild::Verify; @@ -99,11 +100,11 @@ sub addemptyrepo { # Update the local reposiory with new binary data # sub updatelocalrepo { - my ($repos, $bconf, $myarch, $builddir, $pkgsrc, $pkgs) = @_; + my ($repos, $bconf, $myarch, $pkgsrc, $pkgs) = @_; my $id = "$myarch/local"; my $repo = $repos->{$id}; die("local repo does not exist\n") unless $repo; - my $bins = PBuild::LocalRepo::fetchrepo($bconf, $myarch, $builddir, $pkgsrc, $pkgs); + my $bins = PBuild::LocalRepo::fetchrepo($bconf, $myarch, $repo->{'dir'}, $pkgsrc, $pkgs); $_->{'repoid'} = $id for @$bins; $repo->{'bins'} = $bins; } @@ -263,4 +264,16 @@ sub get_gbininfo { return $gbininfo; } +# +# Update the local reposiory with the artifact information of a succeeded build +# +sub updatelocalgbininfo { + my ($repos, $myarch, $pkg, $bininfo) = @_; + my $id = "$myarch/local"; + my $repo = $repos->{$id}; + die("local repo does not exist\n") unless $repo; + PBuild::LocalRepo::update_gbininfo($repo->{'dir'}, $pkg, $bininfo); + delete $repo->{'gbininfo'}; # flush our cache +} + 1; diff --git a/PBuild/Result.pm b/PBuild/Result.pm index ff29853f9..6a63d5d18 100644 --- a/PBuild/Result.pm +++ b/PBuild/Result.pm @@ -69,12 +69,16 @@ sub print_result { return $found_failures; } +sub has_failed_code { + my ($opts, $code) = @_; + return $code_failures{$code || 'unknown'} ? 1 : 0; +} + sub has_failed { my ($opts, $builddir, $pkg) = @_; my $r = PBuild::Util::retrieve("$builddir/.pbuild/_result", 1); die("pbuild has not run yet for $builddir\n") unless $r; - my $code = $r->{$pkg}->{'code'} || 'unknown'; - return $code_failures{$code} ? 1 : 0; + return has_failed_code($opts, $r->{$pkg}->{'code'}); } 1; diff --git a/pbuild b/pbuild index 5fb3f0443..1ab7f9c7b 100755 --- a/pbuild +++ b/pbuild @@ -518,7 +518,7 @@ while (1) { $details = ": $result->{$pkg}->{'details'}" if $result->{$pkg}->{'details'}; } print "$pkg: $code$details\n"; - exit($code eq 'broken' || $code eq 'failed' || $code eq 'unresolvable' ? 1 : 0); + exit PBuild::Result::has_failed_code($opts, $code); } # mix in old result from other packages if in single package mode @@ -571,14 +571,13 @@ while (1) { # if the build was successful, update artifact information and the local repo if ($bininfo) { - PBuild::LocalRepo::update_gbininfo($builddir, $p->{'pkg'}, $bininfo); - delete $repos[0]->{'gbininfo'}; + $repomgr->updatelocalgbininfo($myarch, $p->{'pkg'}, $bininfo); if ($p->{'useforbuildenabled'}) { # update with new local bin information if ($p->{'native'}) { - $repomgr->updatelocalrepo($bconf, $hostarch, $builddir, \%pkgsrc, \@pkgs_native); + $repomgr->updatelocalrepo($bconf, $hostarch, \%pkgsrc, \@pkgs_native); } else { - $repomgr->updatelocalrepo($bconf, $myarch, $builddir, \%pkgsrc, \@pkgs_target); + $repomgr->updatelocalrepo($bconf, $myarch, \%pkgsrc, \@pkgs_target); } # we also need a new checker undef $ctx;