diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2019-12-08 10:35:18 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2019-12-08 10:35:18 +0000 |
commit | 0f80d65821cbe039080c9a41a9c60cc6974f9acb (patch) | |
tree | 34b182e3781884f4b89f0e402779ca98f5dd43a5 /usr.sbin/pkg_add | |
parent | e84799efe580f9f409f377e101ac82ed512ef534 (diff) |
have DEBUG_PKG_CACHE also apply to already installed packages, to
help bootstrap the process
Clean the code:
- move the decision logic into individual may_grab_debug_for
- acknowledge the PkgAdd object doesn't matter in there, just use class
- for already installed stuff, we skip packages that already exist
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgAdd.pm | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm index 6267188c7fe..67ce5be2d0a 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgAdd.pm,v 1.117 2019/12/04 10:47:38 espie Exp $ +# $OpenBSD: PkgAdd.pm,v 1.118 2019/12/08 10:35:17 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -362,6 +362,9 @@ sub find_kept_handle $o->{tweaked} = OpenBSD::Add::tweak_package_status($pkgname, $state); $state->updater->progress_message($state, "No change in $pkgname"); + if (defined $state->debug_cache_directory) { + OpenBSD::PkgAdd->may_grab_debug_for($pkgname, 1, $state); + } delete $set->{newer}{$pkgname}; $n->cleanup; } @@ -1050,17 +1053,31 @@ sub process_set $set->cleanup; $state->tracker->done($set); if (defined $state->debug_cache_directory) { - $self->grab_debug_packages($set, $state); + for my $p ($set->newer_names) { + $self->may_grab_debug_for($p, 0, $state); + } } return (); } +sub may_grab_debug_for +{ + my ($class, $orig, $kept, $state) = @_; + return if $orig =~ m/^debug\-/; + my $dbg = "debug-$orig"; + return if $state->tracker->is_known($dbg); + return if OpenBSD::PackageInfo::is_installed($dbg); + my $d = $state->debug_cache_directory; + return if $kept && -f "$d/$dbg.tgz"; + $class->grab_debug_package($d, $dbg, $state); +} + sub grab_debug_package { - my ($self, $pkg, $state) = @_; - my $o = $state->locator->find($pkg); + my ($class, $d, $dbg, $state) = @_; + + my $o = $state->locator->find($dbg); return if !defined $o; - my $d = $state->debug_cache_directory; require OpenBSD::Temp; my ($fh, $name) = OpenBSD::Temp::permanent_file($d, "debug-pkg"); if (!defined $fh) { @@ -1081,27 +1098,15 @@ sub grab_debug_package my $c = $?; $o->{repository}->parse_problems($o->{errors}, 1, $o); if ($c == 0) { - rename($name, "$d/$pkg.tgz"); + rename($name, "$d/$dbg.tgz"); } else { unlink($name); - $self->errsay("Grabbing debug package failed: #1", + $state->errsay("Grabbing debug package failed: #1", $state->child_error($c)); } } } -sub grab_debug_packages -{ - my ($self, $set, $state) = @_; - for my $p ($set->newer_names) { - next if $p =~ m/^debug\-/; - my $dbg = "debug-$p"; - next if $state->tracker->is_known($dbg); - next if OpenBSD::PackageInfo::is_installed($dbg); - $self->grab_debug_package($dbg, $state); - } -} - sub inform_user_of_problems { my $state = shift; |