fix autoloading of quirks: don't try to run quirks while processing the
authorespie <espie@openbsd.org>
Wed, 25 Dec 2013 15:59:51 +0000 (15:59 +0000)
committerespie <espie@openbsd.org>
Wed, 25 Dec 2013 15:59:51 +0000 (15:59 +0000)
quirks set, as we may accidentally load the old one.
also, in case we can't load quirks, report if quirks should be there,
e.g., compilation error, without regard to verbose status

usr.sbin/pkg_add/OpenBSD/AddDelete.pm
usr.sbin/pkg_add/OpenBSD/Update.pm

index 91dc7b6..8022e55 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: AddDelete.pm,v 1.57 2013/12/25 14:20:48 espie Exp $
+# $OpenBSD: AddDelete.pm,v 1.58 2013/12/25 15:59:51 espie Exp $
 #
 # Copyright (c) 2007-2010 Marc Espie <espie@openbsd.org>
 #
@@ -278,8 +278,12 @@ sub run_quirks
                        $state->{quirks} = OpenBSD::Quirks->new(1);
                };
                if ($@) {
-                       $state->errsay("Can't load quirk: #1", $@)
-                           if $state->verbose >= 2;
+                       my $show = $state->verbose >= 2;
+                       if (!$show) {
+                               my $l = $state->repo->installed->match_locations(OpenBSD::Search::Stem->new('quirks'));
+                               $show = @$l > 0;
+                       }
+                       $state->errsay("Can't load quirk: #1", $@) if $show;
                        # cache that this didn't work
                        $state->{quirks} = undef;
                }
index 3e69d1f..66921ef 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.154 2013/12/25 14:20:48 espie Exp $
+# $OpenBSD: Update.pm,v 1.155 2013/12/25 15:59:51 espie Exp $
 #
 # Copyright (c) 2004-2010 Marc Espie <espie@openbsd.org>
 #
@@ -88,16 +88,18 @@ sub process_handle
                return 0;
        }
 
-       my $base = 0;
-       $state->run_quirks(
-           sub {
-               my $quirks = shift;
-               $base = $quirks->is_base_system($h, $state);
-           });
-       if ($base) {
-               $h->{update_found} = OpenBSD::Handle->system;
-               $set->{updates}++;
-               return 1;
+       if (!$set->{quirks}) {
+               my $base = 0;
+               $state->run_quirks(
+                   sub {
+                       my $quirks = shift;
+                       $base = $quirks->is_base_system($h, $state);
+                   });
+               if ($base) {
+                       $h->{update_found} = OpenBSD::Handle->system;
+                       $set->{updates}++;
+                       return 1;
+               }
        }
 
        my $plist = OpenBSD::PackingList->from_installation($pkgname,
@@ -124,11 +126,13 @@ sub process_handle
        }
        push(@search, OpenBSD::Search::Stem->split($sname));
 
-       $state->run_quirks(
-           sub {
-               my $quirks = shift;
-               $quirks->tweak_search(\@search, $h, $state);
-           });
+       if (!$set->{quirks}) {
+               $state->run_quirks(
+                   sub {
+                       my $quirks = shift;
+                       $quirks->tweak_search(\@search, $h, $state);
+                   });
+       }
        my $oldfound = 0;
        my @skipped_locs = ();