Thursday, January 19, 2006

pkg_find

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 exit -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 ftp://ftp.usa.openbsd.org/pub/OpenBSD/`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".

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.

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.