New version, after some rewrite and input by semarie
Changes to PkgInfo.
- fix a regexp bug... tests showed the issue.
- simplify the -z option code, as it can actually share most of the code
from the rest. This means pkg_info -zm for installed packages, and funnily
enough, pkg_info -zm somepackage will work.
Index: OpenBSD/PackingElement.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PackingElement.pm,v
retrieving revision 1.243
diff -u -p -r1.243 PackingElement.pm
--- OpenBSD/PackingElement.pm 3 Feb 2016 18:30:15 -0000 1.243
+++ OpenBSD/PackingElement.pm 25 Jun 2016 14:58:49 -0000
@@ -894,6 +894,8 @@ sub new
return OpenBSD::PackingElement::Firmware->new;
} elsif ($args eq 'always-update') {
return OpenBSD::PackingElement::AlwaysUpdate->new;
+ } elsif ($args eq 'is-branch') {
+ return OpenBSD::PackingElement::IsBranch->new;
} else {
die "Unknown option: $args";
}
@@ -941,6 +943,13 @@ sub category()
'always-update';
}
+package OpenBSD::PackingElement::IsBranch;
+our @ISA=qw(OpenBSD::PackingElement::UniqueOption);
+
+sub category()
+{
+ 'is-branch';
+}
# The special elements that don't end in the right place
package OpenBSD::PackingElement::ExtraInfo;
our @ISA=qw(OpenBSD::PackingElement::Unique OpenBSD::PackingElement::Comment);
Index: OpenBSD/PackingList.pm
===================================================================
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PackingList.pm,v
retrieving revision 1.136
diff -u -p -r1.136 PackingList.pm
--- OpenBSD/PackingList.pm 14 Jun 2016 15:41:31 -0000 1.136
+++ OpenBSD/PackingList.pm 25 Jun 2016 14:58:49 -0000
@@ -257,7 +257,7 @@ sub ExtraInfoOnly
{
my ($fh, $cont) = @_;
while (<$fh>) {
- if (m/^\@(?:name|pkgpath|comment\s+(?:subdir|pkgpath)\=)\b/o) {
+ if
(m/^\@(?:name|pkgpath|comment\s+(?:subdir|pkgpath)\=|option\s+is-branch)\b/o) {
&$cont($_);
# XXX optimization
} elsif (m/^\@(?:depend|wantlib|newgroup|newuser|cwd)\b/o) {
@@ -446,7 +446,7 @@ sub match_pkgpath
}
our @unique_categories =
- (qw(name url signer digital-signature no-default-conflict
manual-installation firmware always-update extrainfo localbase arch));
+ (qw(name url signer digital-signature no-default-conflict
manual-installation firmware always-update is-branch extrainfo localbase arch));
our @list_categories =
(qw(conflict pkgpath ask-update depend
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 14:58:50 -0000
@@ -415,7 +415,18 @@ sub print_info
return;
}
my $plist;
- if ($state->opt('I')) {
+ if ($state->opt('z')) {
+ $plist = $handle->plist(\&OpenBSD::PackingList::ExtraInfoOnly);
+ my $name = OpenBSD::PackageName->new_from_string($pkg);
+ my $stem = $name->{stem};
+ my $compose = $stem."--".join('-', sort keys
%{$name->{flavors}});
+ if ($plist->has('is-branch')) {
+ if ($plist->fullpkgpath =~ m/\/([^\/]+?)(,.*)?$/) {
+ $compose .= "%$1";
+ }
+ }
+ $state->say("#1", $compose);
+ } elsif ($state->opt('I')) {
if ($state->opt('q')) {
$state->say("#1", $pkg);
} else {
@@ -567,8 +578,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')) {