search what port/package provides file "x"

da1

Aspiring Daemon

Reaction score: 95
Messages: 876

hello fellas,


I would like to know how I can search for a package if I only know the file name. simply put, how to check which port provides file "x" or "y".

similar to "yum whatpovides".

I remember I was doing it long ago but i forgot how.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,761
Messages: 30,885

Code:
root@molly:/usr/ports#pkg_info -W /usr/local/bin/sudo
/usr/local/bin/sudo was installed by package sudo-1.7.2.5
See pkg_info(1). Only works for installed packages though.
 
OP
OP
D

da1

Aspiring Daemon

Reaction score: 95
Messages: 876

mmm, thx for that but I know it already.

I am looking for something different thow. imagine I need to get file "libsdc++" and I dnt know which port contains it. how would I figure out which package/port to install in order to get the file ?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,761
Messages: 30,885

da1 said:
how would I figure out which package/port to install in order to get the file ?
Google :e
 

phoenix

Administrator
Staff member
Administrator
Moderator

Reaction score: 1,259
Messages: 4,099

$ grep filename /usr/ports/*/*/pkg-plist
May take a long time to run. :) And won't work for ports that use auto-generated plists.
 

fronclynne

Daemon

Reaction score: 176
Messages: 1,296

phoenix said:
$ grep filename /usr/ports/*/*/pkg-plist
May take a long time to run. :) And won't work for ports that use auto-generated plists.
/sbin/grep: Argument list too long.

I don't feel like doing it, but find(1) can probably handle it (slowly).
 

wblock@

Beastie Himself
Developer

Reaction score: 3,645
Messages: 13,850

phoenix said:
$ grep filename /usr/ports/*/*/pkg-plist
May take a long time to run. :) And won't work for ports that use auto-generated plists.
That gives "/usr/bin/grep: Argument list too long." Have to resort to find:
# find /usr/ports -name pkg-plist -exec grep filename {} \+

Using a port search is sometimes worth a try:
# cd /usr/ports && make search key=filename
 

phoenix

Administrator
Staff member
Administrator
Moderator

Reaction score: 1,259
Messages: 4,099

Hrm, yeah, guess that would be along argument list.

Wonder how the speed would compare to (find vs xargs) (completely untested):
Nevermind, that also gives argument list too long.
 

phoenix

Administrator
Staff member
Administrator
Moderator

Reaction score: 1,259
Messages: 4,099

wblock said:
That gives "/usr/bin/grep: Argument list too long." Have to resort to find:
# find /usr/ports -name pkg-plist -exec grep filename {} \+
To speed things up, you can add -depth 3 the find command. That way, it won't search through any sub-directories of the port (old work/ dirs, files/ dir, etc).
 

jalla

Well-Known Member

Reaction score: 85
Messages: 385

If you had your ports tree around for a few days, this is probably the fastest
Code:
locate filename |grep 'usr/ports'
 

wblock@

Beastie Himself
Developer

Reaction score: 3,645
Messages: 13,850

jalla said:
If you had your ports tree around for a few days, this is probably the fastest
Code:
locate filename |grep 'usr/ports'
But that won't look in the pkg-plist files. It would work to find the port that uses a certain distfile or patch file.
 
OP
OP
D

da1

Aspiring Daemon

Reaction score: 95
Messages: 876

@DutchDaemon - the link looked promising at first but the following changed that:

test1:

Code:
pkg_info -L libXi-1.2.1,1
[...]
/usr/local/lib/libXi.so.6
[...]
so let's say I need libXi.so.6, I don't have it installed and I have no clue as to which package it belongs to.

I checked the file in the link you provided me but it does not give me back the "libXi" package. Under a "yum system" I would use "yum whatprovides <filename>" and I am curious if there is something similar under BSD.
 

jalla

Well-Known Member

Reaction score: 85
Messages: 385

wblock said:
But that won't look in the pkg-plist files. It would work to find the port that uses a certain distfile or patch file.
You're right, it won't work for everybody. I have a habit of never doing 'make clean' when building ports so my locate db usually contains everything from all ports I ever built.
 

jalla

Well-Known Member

Reaction score: 85
Messages: 385

phoenix said:
Hrm, yeah, guess that would be along argument list.

Wonder how the speed would compare to (find vs xargs) (completely untested):
Nevermind, that also gives argument list too long.
Strange, I don't get arg list to long. If it does you can use xargs -L to limit the cmd.

Anyway, it takes about 2,5 minutes

Code:
gnome:/usr/ports# time eval "find . -name pkg-plist | xargs grep whatever"
./databases/mantis/pkg-plist:%%WWWDIR%%/library/ezc/Base/src/exceptions/whatever.php
./games/lucidlife/pkg-plist:%%DATADIR%%/patterns/jslife/odds_&_ends/whatever.glf
./sysutils/gsmartcontrol/pkg-plist:%%PORTDOCS%%%%DOCSDIR%%/LICENSE_whatever.txt
./textproc/stardict2-rptts/pkg-plist:share/WyabdcRealPeopleTTS/w/whatever.wav
./textproc/yodl/pkg-plist:bin/yodl2whatever
./textproc/yodl/pkg-plist:%%NO_MANPAGES%%man/man1/yodl2whatever.1.gz
1.543u 7.433s 2:33.86 5.8%      34+810k 52613+0io 0pf+0w
 

duckunix

New Member


Messages: 1

And for completeness sake (I found this thread via google), under pkgng, the way to do it is:
Code:
pkg which<file>
Works like a champ for ports installed or binary package installed ports.
 

wblock@

Beastie Himself
Developer

Reaction score: 3,645
Messages: 13,850

There are two different things here. The original thread is about finding out which port to install to get a certain file. pkg which is used in the opposite situation, when a file has been installed and you want to find out which port it came from.
 

scottro

Daemon

Reaction score: 507
Messages: 1,421

4 years later, for me, (trying various things from this thread) the find command given worked well, and didn't take that long.

Code:
cd /usr/ports
find . -name pkg-plist |xargs grep mp4info
(which was the program I was seeking). Took about 30 seconds.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,761
Messages: 30,885

A lot of ports have a dynamically generated pkg-plist, so this file doesn't always exist.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,761
Messages: 30,885

Did you read the pkg-message? You need to enable plugins in /usr/local/etc/pkg.conf.
 
Top