Re: pkg_info -Q bug?

2019-11-23 Thread Antonio Bibiano
Thanks Stuart,
I tried that package and it indeed does what i needed :)

But I decided to scratch my itch anyway and dug a bit into the
pkg_info code to figure out
what was going on and I found the culprit: is the match_locations function
in the PackageRepositoryList class that all the matches from the first
repository that has some.

I changed that behaviour but that had some side effects so I modified
the PkgInfo class, the patch
follows. Hope this might help for future work on pkg_info.


Cheers,
Antonio


##
Index: usr.sbin/pkg_add/OpenBSD/PkgInfo.pm
===
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm,v
retrieving revision 1.49
diff -u -p -u -p -r1.49 PkgInfo.pm
--- usr.sbin/pkg_add/OpenBSD/PkgInfo.pm7 Oct 2017 13:23:05 -1.49
+++ usr.sbin/pkg_add/OpenBSD/PkgInfo.pm23 Nov 2019 17:45:52 -
@@ -597,15 +597,18 @@ sub parse_and_run
 $state->say("PKG_PATH=#1", $ENV{PKG_PATH} // "")
 if $state->verbose;
 my $partial = OpenBSD::Search::PartialStem->new($state->opt('Q'));
-my $r = $state->repo->match_locations($partial);

-for my $pkg (sort {$a->name cmp $b->name} @$r) {
-my $p = $pkg->name;
-if ($state->hasanyopt('cdfMqs')) {
-$self->print_info($state, $p, $pkg);
-} else {
-$state->say(
-is_installed($p) ? "#1 (installed)" : "#1", $p);
+for my $repo (@{$state->locator->default_path($state)->{l}}) {
+$state->say("Repo: #1:#2", $repo->urlscheme, $repo->baseurl);
+my $r = $repo->match_locations($partial);
+for my $pkg (sort {$a->name cmp $b->name} @$r) {
+my $p = $pkg->name;
+if ($state->hasanyopt('cdfMqs')) {
+$self->print_info($state, $p, $pkg);
+} else {
+$state->say(
+is_installed($p) ? "#1 (installed)" : "#1", $p);
+}
 }
 }
##

On Tue, Nov 19, 2019 at 22:53 Stuart Henderson  wrote:
>
> On 2019-11-19, Marc Espie  wrote:
> > On Tue, Nov 19, 2019 at 12:13:37PM +0200, Dumitru Moldovan wrote:
> >> On Mon, Nov 18, 2019 at 11:15:05AM +0100, Antonio Bibiano wrote:
> >> > Hello,
> >> > I just wanted to add to this thread that I incurred in the same
> >> > issue on a fresh 6.6 installation.
> >> > I also tried with a different mirror in /etc/installurl and receive
> >> > the same partial response from pkg_info -Q.
> >> > What makes it even more odd is that pkg_add finds the correct package.
> >>
> >> Thanks Antonio for double-checking this!  I have also tested it on a
> >> fresh installation at the time and got the same results.
> >>
> >> Maybe the behaviour is undefined if PKG_PATH is not set, which is fine
> >> by me.  But still, it's quite puzzling and against the principle of
> >> least surprise.
> >
> > It's one of those little things that is well known, but that won't change
> > until I have time to look at it, and it's definitely not a high priority
> > problem right now.
> >
> >
>
> As a workaround (but also something that would be more likely to give
> the results wanted than a properly-working pkg_info -Q which doesn't match
> filenames inside the packages), you might like to "pkg_add pkglocatedb"
> and use the "pkglocate" tool that this provides.
>



Re: pkg_info -Q bug?

2019-11-18 Thread Antonio Bibiano
Hello,
I just wanted to add to this thread that I incurred in the same
issue on a fresh 6.6 installation.
I also tried with a different mirror in /etc/installurl and receive
the same partial response from pkg_info -Q.
What makes it even more odd is that pkg_add finds the correct package.


Cheers,
Antonio Bibiano

On Fri, Nov 08, 2019 at 09:34:06PM GMT, Dumitru Moldovan wrote:
>On Fri, Nov 08, 2019 at 08:04:45PM +, Raf Czlonka wrote:
>>On Fri, Nov 08, 2019 at 05:45:23PM GMT, Dumitru Moldovan wrote:
>>>
>>> Hi misc,
>>>
>>> I see pkg_info's man page says:
>>>
>>>-Q query
>>>Show all packages in $PKG_PATH which match the given query.
>>>
>>> Trying in 6.6 to find the Python module "mysqlclient", I get the
>>> following puzzling results:
>>>
>>> $ pkg_info -Q mysql
>>> php-mysqli-7.2.24
>>> php-mysqli-7.3.11
>>> php-pdo_mysql-7.2.24
>>> php-pdo_mysql-7.3.11
>>>
>>> $ pkg_info -Q py-mysql
>>> py-mysql-1.2.5p6
>>> py-mysqlclient-1.4.2p0
>>>
>>> Am I doing something wrong?  Why is "py-mysqlclient" not matched for
>>> the first query?
>>>
>>
>>Hi Dumitru,
>>
>>Not only isn't "py-mysqlclient" matched, but also over 40 other
>>packages with "mysql" string.
>>
>>How does your $PKG_PATH look like?
>
>Thanks for looking into it!
>
>$PKG_PATH is empty here, should have checked it first.  I get the
>expected results with:
>
>PKG_PATH=`cat /etc/installurl`/`uname -r`/packages/`uname -m`/ pkg_info -Q 
>mysql
>
>But now I don't understand why I got any results at all with an empty
>$PKG_PATH...  Maybe I would have read that one line in the man page
>more carefully if there was no result at all to begin with.  :-]
>