Have -S actually behave like the other introspection options, namely only
authorespie <espie@openbsd.org>
Tue, 1 Nov 2022 17:41:19 +0000 (17:41 +0000)
committerespie <espie@openbsd.org>
Tue, 1 Nov 2022 17:41:19 +0000 (17:41 +0000)
eschew building the package is -n is mentionned.

Document that -S -n is heavily optimized for speed since it's mostly used
by dpb -R to figure out what to rebuild.

usr.sbin/pkg_add/OpenBSD/PkgCreate.pm

index b85ecca..d4e139c 100644 (file)
@@ -1,6 +1,6 @@
 #! /usr/bin/perl
 # ex:ts=8 sw=4:
-# $OpenBSD: PkgCreate.pm,v 1.183 2022/11/01 17:25:33 espie Exp $
+# $OpenBSD: PkgCreate.pm,v 1.184 2022/11/01 17:41:19 espie Exp $
 #
 # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
 #
@@ -1476,7 +1476,10 @@ sub create_plist
                $state->fatal(OpenBSD::Temp->last_error);
        }
        $plist->set_infodir($dir);
-       if (!defined $state->opt('S')) {
+       # XXX optimization: we want -S to be fast even if we don't check
+       # everything, e.g., we don't need the actual packing-list to
+       # print a signature if that's all we do.
+       if (!(defined $state->opt('S') && defined $state->opt('n'))) {
                $self->read_all_fragments($state, $plist);
        }
        $self->add_elements($plist, $state);
@@ -1725,7 +1728,8 @@ sub run_command
 
        if (defined $state->opt('S')) {
                print $plist->signature->string, "\n";
-               exit 0;
+               # no need to check anything else if we're running -n
+               exit 0 if defined $state->opt('n');
        }
        $plist->discover_directories($state);
        my $ordered = [];