From e20f1949b10b578e6ecefcd73c91e3c57b6d7c59 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Tue, 5 Jan 2010 12:01:08 +0000 Subject: tracker and updater are also auto-cached --- usr.sbin/pkg_add/pkg_add | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add index cf3094cca56..215585b16c6 100644 --- a/usr.sbin/pkg_add/pkg_add +++ b/usr.sbin/pkg_add/pkg_add @@ -1,7 +1,7 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_add,v 1.462 2010/01/05 11:42:45 espie Exp $ +# $OpenBSD: pkg_add,v 1.463 2010/01/05 12:01:07 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -104,25 +104,17 @@ sub set_name_from_handle $state->log->set_context($extra.$h->pkgname); } -sub updater -{ - my $state = shift; - if (!defined $state->{updater}) { - require OpenBSD::Update; - $state->{updater} = OpenBSD::Update->new; - } - return $state->{updater}; -} +OpenBSD::Auto::cache(updater, + sub { + require OpenBSD::Update; + return OpenBSD::Update->new; + }); -sub tracker -{ - my $state = shift; - if (!defined $state->{tracker}) { - require OpenBSD::Tracker; - $state->{tracker} = OpenBSD::Tracker->new; - } - return $state->{tracker}; -} +OpenBSD::Auto::cache(tracker, + sub { + require OpenBSD::Tracker; + return OpenBSD::Tracker->new; + }); sub quirks { @@ -168,12 +160,12 @@ use OpenBSD::Error; OpenBSD::Auto::cache(solver, sub { - return OpenBSD::Dependencies::Solver->new(shift); + return OpenBSD::Dependencies::Solver->new(shift); }); OpenBSD::Auto::cache(conflict_cache, sub { - return OpenBSD::ConflictCache->new; + return OpenBSD::ConflictCache->new; }); sub setup_header -- cgit v1.2.3