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.