NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/51269: pkg_info enhancements



The following reply was made to PR bin/51269; it has been noted by GNATS.

From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
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@localhost
 


Home | Main Index | Thread Index | Old Index