Can pkg search non installed packages for files?

Is there any easy way how to determine which package to install if I know which file or file pattern I am looking for? For example I would need startx binary. How to dermine which package(s) will install it?
 
I know what you are referring to. With RPM based Linux systems yum provides "*/startx" would get you what you are looking for. But on FreeBSD the package repos don't contain the same list of every file. If you look at the digests.txz and packagesite.txz files from a repo you only find basic info on the package. Do read the man page with pkg help search to see what you can search for. As a workaround, you can look through your ports collection for the same information in the pkg-plist files for each port.

Try:
find /usr/ports -name pkg-plist -exec grep --with-filename startx {} \;

You should see x11/xinit provides what you are looking for.
 
I looked at the pkg-search() man page before asking, but hope dies last so I asked if there is something I had overlooked. Thanks for reply anyway.

I also thinked about greping through the plist files, but not all ports have them, you can specify installed files in the Makefile for example. And in all possible scenarios, there may not be the ports tree installed on all machines. Both those problems are relative easily resolvable, but I hoped for something more elegant and integrated.
 
pkg query %Fn <package_pattern> lists the files that match <package_pattern>. This only for packages in the database (local installed packages). Changing the environment variable PKG_DBDIR you can download (if exists) the repository database and then query in it. Then you can greping the result. This is a guess, this is only a guess.
 
freethread said:
pkg query %Fn <package_pattern> lists the files that match <package_pattern>. This only for packages in the database (local installed packages). Changing the environment variable PKG_DBDIR you can download (if exists) the repository database and then query in it. Then you can greping the result. This is a guess, this is only a guess.

The same can not be done for a remote repository with pkg-rquery(8) because the files included in a package are not known until a package gets installed. If the contents of the packages were static the file list could be part of the repository metadata but that's not the case, the pkg-plist system allows dynamic modifications of the package contents at install time.
 
Mmmmh, ports-mgmt/pkg-plist and ports tree is a partial solution, the installation of some files depends on the options selected in ports. Also running the command for each port take a lot of time and perhaps the pkg-plist file generated overwrite the one in the port.
 
freethread said:
If only you can trap the make clean list...

It may be possible with new make target, which will store this dynamic package list for later indexing and searching. Any Makefile hacker here? :)
 
Back
Top