Here is what it turns out as, -z option to pkg_info

Prints just simple stem--flavor[%branch] list of installed packages...

Only manual installs, no need to encumber it with dependencies.

Index: OpenBSD/PkgInfo.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm,v
retrieving revision 1.38
diff -u -p -r1.38 PkgInfo.pm
--- OpenBSD/PkgInfo.pm  22 Jun 2016 12:18:21 -0000      1.38
+++ OpenBSD/PkgInfo.pm  25 Jun 2016 11:37:38 -0000
@@ -407,6 +407,30 @@ sub may_check_data
        $handle->{checked} = 1;
 }
 
+sub print_branch
+{
+       my ($self, $state, $pkg, $handle) = @_;
+       unless (defined $handle) {
+               $state->errsay("Error printing info for #1: no info ?", $pkg);
+               return;
+       }
+       require OpenBSD::PackingList;
+       require OpenBSD::PackageName;
+
+       my $plist = $handle->plist(\&OpenBSD::PackingList::ExtraInfoOnly);
+
+       my $name = OpenBSD::PackageName->new_from_string($plist->pkgname);
+       my $stem = $name->{stem};
+       my $compose = $stem."--".join('-', sort keys %{$name->{flavors}});
+       if ($plist->fullpkgpath =~ m/\b\Q$stem\E\/(.*?)([,\/].*)?$/) {
+               my $branch = $1;
+               unless ($branch eq $stem or $branch eq 'core') {
+                       $compose .= "%$branch";
+               }
+       }
+       $state->say("#1", $compose);
+}
+
 sub print_info
 {
        my ($self, $state, $pkg, $handle) = @_;
@@ -567,8 +591,8 @@ sub parse_and_run
                    }
            };
        $state->{no_exports} = 1;
-       $state->handle_options('cCdfF:hIKLmPQ:qr:RsSUe:E:Ml:aAt',
-           '[-AaCcdfIKLMmPqRSstUv] [-D nolock][-E filename] [-e pkg-name] ',
+       $state->handle_options('cCdfF:hIKLmPQ:qr:RsSUe:E:Ml:aAtz',
+           '[-AaCcdfIKLMmPqRSstUvz] [-D nolock][-E filename] [-e pkg-name] ',
            '[-l str] [-Q query] [-r pkgspec] [pkg-name ...]');
 
        if ($state->opt('r')) {
@@ -607,6 +631,9 @@ sub parse_and_run
                        $state->setopts('cdMR');
                }
        }
+       if ($state->opt('z')) {
+               $state->setopts('am');
+       }
 
        if ($state->opt('Q')) {
                require OpenBSD::Search;
@@ -674,7 +701,11 @@ sub parse_and_run
                }
                if (!$self->find_pkg($state, $pkg,
                    sub {
-                       $self->print_info($state, @_);
+                       if ($state->opt('z')) {
+                               $self->print_branch($state, @_);
+                       } else {
+                               $self->print_info($state, @_);
+                       }
                })) {
                        $exit_code = 1;
                }

Reply via email to