Subject: Re: Determening if a package is installed?
To: Jan Danielsson <jan.m.danielsson@gmail.com>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: pkgsrc-users
Date: 05/01/2007 21:34:50
On Wed, 02 May 2007 02:05:30 +0200
Jan Danielsson <jan.m.danielsson@gmail.com> wrote:

> Hello all,
> 
>    I have a file which looks like this:
> 
> ---------------
> misc/screen
> shells/bash
> databases/py-psycopg2
> .
> .
> .
> ---------------
> 
>    It's simply a file which lists all the packages I want to have
> installed.
> 
>    This is what I want to do: I want to be able to run
> lintpkgsrc/pkgdepgraph to generate a list of outdated packages, then
> delete all the outdated packages and their dependencies. Then finally
> loop through my file of the packages I want, check if they are
> installed already, and if they aren't, then build them. (I'm doing
> all this in a chrooted environent).
> 
>    The problem I keep running into is that I am unable to determine
> if a package is installed using the pkgsrc path. Everything assumes
> that I have the package name, which isn't always true (for instance,
> the installed package is called py24-psycopg2).
> 

Try this:

	cd /usr/pkgsrc/$x && make show-var VARNAME=PKGNAME

You may have to use a regular expression to strip off the version
suffix; for my scripts, I don't need to.

(It took me quite a while to figure it out, too.)

The other useful trick I worked out is

	pkg_info -Q PKGPATH $x

which takes the name of an installed package and gives the pkgsrc
directory.

		--Steve Bellovin, http://www.cs.columbia.edu/~smb