have been loaded, complain loudly if something doesn't work.
(and complain when quirks don't load in !verbose mode)
# ex:ts=8 sw=4:
-# $OpenBSD: AddDelete.pm,v 1.56 2013/12/23 16:50:29 espie Exp $
+# $OpenBSD: AddDelete.pm,v 1.57 2013/12/25 14:20:48 espie Exp $
#
# Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org>
#
}
}
+sub run_quirks
+{
+ my ($state, $sub) = @_;
+
+ if (!exists $state->{quirks}) {
+ eval {
+ require OpenBSD::Quirks;
+ # interface version number.
+ $state->{quirks} = OpenBSD::Quirks->new(1);
+ };
+ if ($@) {
+ $state->errsay("Can't load quirk: #1", $@)
+ if $state->verbose >= 2;
+ # cache that this didn't work
+ $state->{quirks} = undef;
+ }
+ }
+
+ if (defined $state->{quirks}) {
+ eval {
+ &$sub($state->{quirks});
+ };
+ if ($@) {
+ $state->errsay("Bad quirk: #1", $@);
+ }
+ }
+}
+
sub vsystem
{
my $self = shift;
if (@$list == 0) {
if (!$is_quirks) {
$state->errsay("Can't find #1", $name);
- eval {
- my $r = [$name];
- $state->quirks->filter_obsolete($r, $state);
- }
+ $state->run_quirks(
+ sub {
+ my $quirks = shift;
+ $quirks->filter_obsolete([$name], $state);
+ });
}
return undef;
} elsif (@$list == 1) {
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgAdd.pm,v 1.38 2013/12/23 15:40:24 espie Exp $
+# $OpenBSD: PkgAdd.pm,v 1.39 2013/12/25 14:20:48 espie Exp $
#
# Copyright (c) 2003-2010 Marc Espie <espie@openbsd.org>
#
return OpenBSD::Tracker->new;
});
-sub quirks
-{
- my $state = shift;
-
- return $state->{quirks};
-}
-
package OpenBSD::ConflictCache;
our @ISA = (qw(OpenBSD::Cloner));
sub new
my $state = shift;
my @cantupdate = $state->tracker->cant_list;
if (@cantupdate > 0) {
- eval {
- $state->quirks->filter_obsolete(\@cantupdate, $state);
- };
+ $state->run_quirks(
+ sub {
+ my $quirks = shift;
+ $quirks->filter_obsolete(\@cantupdate, $state);
+ });
$state->say("Couldn't find updates for #1", join(', ', @cantupdate));
}
sub do_quirks
{
my ($self, $state) = @_;
-
- $self->process_set(quirk_set($state), $state);
- eval {
- require OpenBSD::Quirks;
- # interface version number.
- $state->{quirks} = OpenBSD::Quirks->new(1);
- };
+ my $set = quirk_set($state);
+ $self->process_set($set, $state);
}
{
my ($self, $state) = @_;
- eval {
- $state->quirks->tweak_list($state->{setlist}, $state);
- }
+ $state->run_quirks(
+ sub {
+ my $quirks = shift;
+ $quirks->tweak_list($state->{setlist}, $state);
+ });
}
sub main
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.153 2012/10/13 10:28:22 jeremy Exp $
+# $OpenBSD: Update.pm,v 1.154 2013/12/25 14:20:48 espie Exp $
#
# Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org>
#
}
my $base = 0;
- eval {
- $base = $state->quirks->is_base_system($h, $state);
- };
+ $state->run_quirks(
+ sub {
+ my $quirks = shift;
+ $base = $quirks->is_base_system($h, $state);
+ });
if ($base) {
$h->{update_found} = OpenBSD::Handle->system;
$set->{updates}++;
}
push(@search, OpenBSD::Search::Stem->split($sname));
- eval {
- $state->quirks->tweak_search(\@search, $h, $state);
- };
+ $state->run_quirks(
+ sub {
+ my $quirks = shift;
+ $quirks->tweak_search(\@search, $h, $state);
+ });
my $oldfound = 0;
my @skipped_locs = ();