Thursday, January 19, 2006


There is no need for my old "pkg_find" script/package. To find firefox, run: pkg_info -Q firefox

To make package installation easier with OpenBSD, I've created a shell script called pkg_find.

With this script, you can run "pkg_find firefox". You will then be presented with a list of packages matching the string "firefox" (currently only one). You can then type in the number of the match to install that package. If there's only one match, you will be prompted (y/n) to install that package.

pkg_find has the following options:

-i|--install Install package
-n|--no-install Do not install package
-p|--prompt Prompt to install when just one match
-q|--quiet Do not prompt to install when just one match
-u|--update Update package list (if -u is specified and no
search_string, list will update and script will
-v|--verbose Be verbose
-d|--debug Debug
-t|--test Test mode. Print command that would be run
-V|--version Print version and exit
-h|--help Print this screen and exit

pkg_find uses the PKG_PATH variable from your environment (or defaults to`uname -r`/packages/`arch -s`). It downloads a listing of packages available in $PKG_PATH and stores the list locally in ~/.pkg_find/.

When you supply a search_string to pkg_find, it will search the local list and display all matches. You can use the -u option to force your local cache to be updated from the server (PKG_PATH) or your local cache will expire when it is more than 7 days old.

You can also tell pkg_find not to install, but just display matches "pkg_find -n foo" or you can force an install when there's only one match with "pkg_find -i -q mozilla-firefox".

The pkg_find script is available as an OpenBSD port for OpenBSD 3.8. The "source" is also available.



  1. Great work man!

    Do you think the -i option of pkg_add (Espie is working on it) will cover the problems your tool solve?
    (ugh, I hope my english is understandable :D)

  2. It definitely could. A lot of the problems I intended to solve have already been solved by Marc's work. Previously, "pkg_add mozilla-firefox" wouldn't work. Now it does. But "pkg_add firefox" doesn't. On my -current box (today's snapshot), I just ran "pkg_add -i php5" and nothing happened ("Can't resolve php5"). But that's the right direction, I believe.

    I mainly wrote this script for myself. I used to (before I knew about the index.txt file) install ncftp, run ncftpls $PKG_PATH/ > pkgs.txt. Then run "grep foo pkgs.txt", and then pkg_add. After a year or so of doing this, I thought I should script it.


  3. I'd been doing the same thing forever. Just too lazy to fix the problem. Great job on this. Just threw it on a freshly installed box and it's make an already trivial install process even easier. Cheers.

  4. I've had a pkg_find shell script for ages but it's not very clever. I like yours more and have started using it instead of mine.

    Thks z0mbix :)

  5. deadlink.
    is it still usefull?! or have I missed some "new" tool?