Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg which -p <pkgname> don't works as desired #1174

Closed
andrejzverev opened this issue Feb 15, 2015 · 3 comments
Closed

pkg which -p <pkgname> don't works as desired #1174

andrejzverev opened this issue Feb 15, 2015 · 3 comments

Comments

@andrejzverev
Copy link
Contributor

For example if we talking about perl5 package and want to see which package contain perl5 file.

root@az-testnode1:/pkg # ./src/pkg-static which -p perl5
/usr/bin/perl5 was not found in the database

logic of src/which.c don't allow it save matched path and move forward till end. So only first match is used and if first match not in database you will get no proper result.

Correct result must be

root@az-testnode1:/pkg # ./src/pkg-static which -p perl5
/usr/local/bin/perl5 was installed by package perl5-5.18.4_11
@infracaninophile
Copy link
Member

On 15/02/2015 16:17, Andrej Z. wrote:

For example if we talking about perl5 package and want to see which package contain perl5 file.

root@az-testnode1:/pkg # ./src/pkg-static which -p perl5
/usr/bin/perl5 was not found in the database

logic of src/which.c don't allow it save matched path and move forward till end. So only first match is used and if first match not in database you will get no proper result.

Correct result must be

root@az-testnode1:/pkg # ./src/pkg-static which -p perl5
/usr/local/bin/perl5 was installed by package perl5-5.18.4_11

perl5 is rather a special case. First of all, /usr/bin/perl5 is no
longer created by the perl5 port -- if it exists on your machine, either
you're running an older version or you recreated it manually.

On my machine:

lucid-nonsense:~:% pkg which -p perl5
/usr/local/bin/perl5 was installed by package perl5-5.20.1_10

which is your intended result. But then I don't have anything like
/usr/bin/perl*:

lucid-nonsense:~:% ls -laL /usr/bin/perl*
ls: No match.

To choose some different examples:

(1)

lucid-nonsense::% pkg which /usr/local/libexec/dovecot/deliver
/usr/local/libexec/dovecot/deliver was installed by package
dovecot2-2.2.15_3
lucid-nonsense:
:% ls -la /usr/local/libexec/dovecot/deliver
lrwxr-xr-x 1 root wheel 11 Feb 7 11:15
/usr/local/libexec/dovecot/deliver@ -> dovecot-lda

This is producing the correct output IMHO. The dovecot port owns the
.../deliver symlink.

(2)

lucid-nonsense::% ls -la /usr/local/bin/gpg
lrwxr-xr-x 1 root wheel 4 Jan 3 18:13 /usr/local/bin/gpg@ -> gpg2
lucid-nonsense:
:% pkg which -p gpg
/usr/local/bin/gpg was not found in the database

OK -- I agree that this output is not ideal. However, it is pedanticly
correct: the gpg symlink might have been created by, but is not owned by
the either of the gnupg{1,2} ports.

What I think this needs is the same output as currently, but then, IFF
the file concerned is a symlink, and the symlink itself is not owned by
any port, subsequent lines saying eg:

/usr/local/bin/gpg is linked to gpg2
/usr/local/bin/gpg2 was installed by package gnupg-2.1.1_1

Cheers,

Matthew

Dr Matthew J Seaman MA, D.Phil.

PGP: http://www.infracaninophile.co.uk/pgpkey
JID: matthew@infracaninophile.co.uk

@andrejzverev
Copy link
Contributor Author

Hm, Perl 5.18 is still default perl version in the ports tree and will create /usr/bin/perl5 symlink by default :-)

While I'm agree with you here, but i'm not sure what we need to expand symlinks. Maybe cheap version? like just iterate over the PATH and search for matches. No more.

root@az-testnode1:/pkg # ./src/pkg-static which -p perl5
/usr/bin/perl5 was not found in the database
/usr/local/bin/perl5 was installed by package perl5-5.18.4_11

@bapt
Copy link
Member

bapt commented Feb 16, 2015

Expanding the symlinks would be a bad idea imho
I do like looping over PATH

bapt added a commit that referenced this issue Mar 31, 2015
@bapt bapt closed this as completed Apr 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants