NetBSD Problem Report #51269
From paul@whooppee.com Sat Jun 25 10:33:13 2016
Return-Path: <paul@whooppee.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id BF96C7A219
for <gnats-bugs@gnats.NetBSD.org>; Sat, 25 Jun 2016 10:33:13 +0000 (UTC)
Message-Id: <20160625103310.BEA8216E5F@pokey.whooppee.com>
Date: Sat, 25 Jun 2016 18:33:10 +0800 (PHT)
From: paul@whooppee.com
Reply-To: paul@whooppee.com
To: gnats-bugs@NetBSD.org
Subject: pkg_info enhancements
X-Send-Pr-Version: 3.95
>Number: 51269
>Category: bin
>Synopsis: pkg_info(1) needs some new features
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat Jun 25 10:35:00 +0000 2016
>Last-Modified: Sun Jul 31 23:55:00 +0000 2016
>Originator: Paul Goyette
>Release: NetBSD 7.99.30
>Organization:
+------------------+--------------------------+------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org |
+------------------+--------------------------+------------------------+
>Environment:
System: NetBSD pokey.whooppee.com 7.99.30 NetBSD 7.99.30 (POKEY 2016-06-14 11:43:31) #0: Tue Jun 14 23:37:31 PHT 2016 paul@pokey.whooppee.com:/build/netbsd-local/obj/amd64/sys/arch/amd64/compile/POKEY amd64
Architecture: x86_64
Machine: amd64
>Description:
Some useful enhancements to pkg_info(1) would be:
* Allow for querying of more than one variable at a time, by specifying
multiple -Q options
pkg_info -Q PKGPATH -Q PKGNAME
* Allow querying for a list of packages that have a variable set, and/or
packages that have a variable set to a specific value (and maybe even
a third variant to get a list of packages that do _not_ set the variable).
pkg_info -V variable_name
pkg_info -V variable_name=value
pkg_info -V \!variable
* Allow querying for a list of automatic packages. Currently we have -a
for "all" or -u for "user" but nothing for "automatic"
* When querying a variable in multiple packages, (optionally) print each
package name as well as the variable's value. Consider
pkg_info -Q PKGPATH \*
>How-To-Repeat:
>Fix:
>Audit-Trail:
From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: bin/51269: pkg_info enhancements
Date: Sat, 25 Jun 2016 16:44:34 +0200
On Sat, Jun 25, 2016 at 10:35:00AM +0000, paul@whooppee.com wrote:
> * Allow for querying of more than one variable at a time, by specifying
> multiple -Q options
>
> pkg_info -Q PKGPATH -Q PKGNAME
So, how would I know where one variable ends and the next one starts?
> * Allow querying for a list of packages that have a variable set, and/or
> packages that have a variable set to a specific value (and maybe even
> a third variant to get a list of packages that do _not_ set the variable).
>
> pkg_info -V variable_name
> pkg_info -V variable_name=value
> pkg_info -V \!variable
Given that this can be trivally written as shell loop, I don't see the
point.
> * Allow querying for a list of automatic packages. Currently we have -a
> for "all" or -u for "user" but nothing for "automatic"
Same here. E.g.:
pkg_info -e '*' | while read pkg; do
case $(pkg_info -Q automatic "$pkg") in
[yY][eE][sS])
echo "$pkg"
esac
done
> * When querying a variable in multiple packages, (optionally) print each
> package name as well as the variable's value. Consider
>
> pkg_info -Q PKGPATH \*
Same problem as the first, can be written as in the former example.
Joerg
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51269: pkg_info enhancements
Date: Sat, 25 Jun 2016 18:49:11 +0000
On Sat, Jun 25, 2016 at 10:35:00AM +0000, paul@whooppee.com wrote:
> Some useful enhancements to pkg_info(1) would be:
>
> * Allow for querying of more than one variable at a time, by specifying
> multiple -Q options
>
> pkg_info -Q PKGPATH -Q PKGNAME
>
> * Allow querying for a list of packages that have a variable set, and/or
> packages that have a variable set to a specific value (and maybe even
> a third variant to get a list of packages that do _not_ set the variable).
>
> pkg_info -V variable_name
> pkg_info -V variable_name=value
> pkg_info -V \!variable
>
> * Allow querying for a list of automatic packages. Currently we have -a
> for "all" or -u for "user" but nothing for "automatic"
>
> * When querying a variable in multiple packages, (optionally) print each
> package name as well as the variable's value. Consider
>
> pkg_info -Q PKGPATH \*
This all seems reasonable to me but it's much more likely to happen
given a patch...
(Suggestion: use -o for printing the package name, to be like nm(1)
and some other similar things.)
--
David A. Holland
dholland@netbsd.org
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51269: pkg_info enhancements
Date: Sat, 25 Jun 2016 18:50:33 +0000
On Sat, Jun 25, 2016 at 02:45:01PM +0000, Joerg Sonnenberger wrote:
> On Sat, Jun 25, 2016 at 10:35:00AM +0000, paul@whooppee.com wrote:
> > * Allow for querying of more than one variable at a time, by specifying
> > multiple -Q options
> >
> > pkg_info -Q PKGPATH -Q PKGNAME
>
> So, how would I know where one variable ends and the next one starts?
Uh, with getopt?
> > * Allow querying for a list of packages that have a variable set, and/or
> > packages that have a variable set to a specific value (and maybe even
> > a third variant to get a list of packages that do _not_ set the
> > variable).
> >
> > pkg_info -V variable_name
> > pkg_info -V variable_name=value
> > pkg_info -V \!variable
>
> Given that this can be trivally written as shell loop, I don't see the
> point. [...]
"Because shell loops suck" seems like a reason.
You're really giving the impression of looking for excuses not to
change anything :-|
--
David A. Holland
dholland@netbsd.org
From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, paul@whooppee.com
Subject: Re: bin/51269: pkg_info enhancements
Date: Sun, 26 Jun 2016 20:23:03 +0200
On Sat, Jun 25, 2016 at 06:55:01PM +0000, David Holland wrote:
> The following reply was made to PR bin/51269; it has been noted by GNATS.
>
> From: David Holland <dholland-bugs@netbsd.org>
> To: gnats-bugs@NetBSD.org
> Cc:
> Subject: Re: bin/51269: pkg_info enhancements
> Date: Sat, 25 Jun 2016 18:50:33 +0000
>
> On Sat, Jun 25, 2016 at 02:45:01PM +0000, Joerg Sonnenberger wrote:
> > On Sat, Jun 25, 2016 at 10:35:00AM +0000, paul@whooppee.com wrote:
> > > * Allow for querying of more than one variable at a time, by specifying
> > > multiple -Q options
> > >
> > > pkg_info -Q PKGPATH -Q PKGNAME
> >
> > So, how would I know where one variable ends and the next one starts?
>
> Uh, with getopt?
In the output, not on the command line.
> > > * Allow querying for a list of packages that have a variable set, and/or
> > > packages that have a variable set to a specific value (and maybe even
> > > a third variant to get a list of packages that do _not_ set the
> > > variable).
> > >
> > > pkg_info -V variable_name
> > > pkg_info -V variable_name=value
> > > pkg_info -V \!variable
> >
> > Given that this can be trivally written as shell loop, I don't see the
> > point. [...]
>
> "Because shell loops suck" seems like a reason.
Then use awk or Python or Perl or whatever.
>
> You're really giving the impression of looking for excuses not to
> change anything :-|
I've been looking at improving the interface in the past. Most
approaches apart very easily, so are of very limited use for the
complexity they add.
Joerg
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51269: pkg_info enhancements
Date: Sun, 31 Jul 2016 18:39:14 +0000
On Sun, Jun 26, 2016 at 06:25:00PM +0000, Joerg Sonnenberger wrote:
>>>> * Allow for querying of more than one variable at a time, by specifying
>>>> multiple -Q options
>>>>
>>>> pkg_info -Q PKGPATH -Q PKGNAME
>>>
>>> So, how would I know where one variable ends and the next one starts?
>>
>> Uh, with getopt?
>
> In the output, not on the command line.
One per line, same as in +BUILD_INFO? That won't work if there are
multiple values for one of the variables, but that's not the common
case.
Also, right now if you run the above example with two -Q options
pkg_info silently prints nothing, which does not seem like it's better
behavior.
>>>> * Allow querying for a list of packages that have a variable set, and/or
>>>> packages that have a variable set to a specific value (and maybe even
>>>> a third variant to get a list of packages that do _not_ set the
>>>> variable).
>>>>
>>>> pkg_info -V variable_name
>>>> pkg_info -V variable_name=value
>>>> pkg_info -V \!variable
>>>
>>> Given that this can be trivally written as shell loop, I don't see the
>>> point. [...]
>>
>> "Because shell loops suck" seems like a reason.
>
> Then use awk or Python or Perl or whatever.
...which does not avoid needing O(n) invocations of pkg_info.
> > You're really giving the impression of looking for excuses not to
> > change anything :-|
>
> I've been looking at improving the interface in the past. Most
> approaches apart very easily, so are of very limited use for the
> complexity they add.
I agree that making up a simple ad-hoc query language isn't a good
idea (it should be a simple principled query language) but I don't
agree that it's a silly or non-useful thing to do.
I long ago gave up on trying to use pkg_info as the interface to
/var/db/pkg; it's too hard to do anything useful. It's much easier to
write e.g.
grep -h variable_name= /var/db/pkg/*/+BUILD_INFO
grep -h variable_name=value /var/db/pkg/*/+BUILD_INFO
grep -hL variable_name= /var/db/pkg/*/+BUILD_INFO
plus some output filtering. Not only do you not need to argue with
what pkg_info is willing to do this way, but it uses standard tools
and techniques.
If you/we want people to use pkg_info instead of doing this sort of
thing, it needs to be better at data retrieval.
--
David A. Holland
dholland@netbsd.org
From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, paul@whooppee.com
Subject: Re: bin/51269: pkg_info enhancements
Date: Sun, 31 Jul 2016 22:36:05 +0200
On Sun, Jul 31, 2016 at 06:40:01PM +0000, David Holland wrote:
> The following reply was made to PR bin/51269; it has been noted by GNATS.
>
> From: David Holland <dholland-bugs@netbsd.org>
> To: gnats-bugs@NetBSD.org
> Cc:
> Subject: Re: bin/51269: pkg_info enhancements
> Date: Sun, 31 Jul 2016 18:39:14 +0000
>
> On Sun, Jun 26, 2016 at 06:25:00PM +0000, Joerg Sonnenberger wrote:
> >>>> * Allow for querying of more than one variable at a time, by specifying
> >>>> multiple -Q options
> >>>>
> >>>> pkg_info -Q PKGPATH -Q PKGNAME
> >>>
> >>> So, how would I know where one variable ends and the next one starts?
> >>
> >> Uh, with getopt?
> >
> > In the output, not on the command line.
>
> One per line, same as in +BUILD_INFO? That won't work if there are
> multiple values for one of the variables, but that's not the common
> case.
It doesn't even work if there is no input, as that doesn't trigger any
option at all.
> Also, right now if you run the above example with two -Q options
> pkg_info silently prints nothing, which does not seem like it's better
> behavior.
It uses the common behavior of last argument in a group wins. PKGNAME
has no defined value, so no output is given.
Joerg
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51269: pkg_info enhancements
Date: Sun, 31 Jul 2016 23:53:34 +0000
On Sun, Jul 31, 2016 at 08:40:01PM +0000, Joerg Sonnenberger wrote:
>>>>>> pkg_info -Q PKGPATH -Q PKGNAME
>>>>>
>>>>> So, how would I know where one variable ends and the next one starts?
>>>>
>>>> Uh, with getopt?
>>>
>>> In the output, not on the command line.
>>
>> One per line, same as in +BUILD_INFO? That won't work if there are
>> multiple values for one of the variables, but that's not the common
>> case.
>
> It doesn't even work if there is no input, as that doesn't trigger any
> option at all.
That's not the common case either. It could also print a blank line
when there's no value.
> > Also, right now if you run the above example with two -Q options
> > pkg_info silently prints nothing, which does not seem like it's better
> > behavior.
>
> It uses the common behavior of last argument in a group wins. PKGNAME
> has no defined value, so no output is given.
Oops, my bad. n/m
--
David A. Holland
dholland@netbsd.org
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.