Gentoo Archives: gentoo-dev

From: Chris Houser <chouser@g.o>
To: gentoo-dev@××××××××××.org
Subject: [gentoo-dev] new portage database tool
Date: Mon, 17 Sep 2001 18:58:37
1 I wrote a little tool to help track which package owns each file in a
2 gentoo system. I'm calling it pdb for now, for lack of a better name.
3 It is currently only in the gentoo-src CVS tree.
5 The heart of the tool is a python module gentoo-src/portage/pym/
6 I guess this needs to be copied somewhere that python can find it in
7 order to use it. There are two front-ends, both in
8 gentoo-src/portage/bin, named 'pdb' and 'pdb.cgi'. The first is a
9 command-line tool, described below. The second is a CGI (surprise!)
10 that provides the same functionality as the command-line tool, but
11 through a web interface.
13 Each of these front-ends has a small config section at the top that you
14 will probably want to modify before using.
16 To start using pdb locally, you must first store the packages you want
17 to be able to look up:
19 $ pdb --local --store foo/bar-1.2.3
21 This uses the CONTENTS file in the specified /var/db/pkg dir to populate
22 the local database. To store all your packages, you could:
24 $ cd /var/db/pkg; pdb -l -s */*
26 To look up a file, use the --query command. For now, you may only give
27 one query at a time, and it must be the full path a file. Multiple
28 queries, wildcards, and other features may be added later if it seems
29 worth it at that point.
31 $ pdb --local --query /usr/lib/libnsl.a
32 sys-libs/glibc-2.2.4-r1
33 obj /usr/lib/libnsl.a B0C142667130D58EC72530CDB9FFBAD3 999228261
35 As you can see, this simply returns which package the file belongs to,
36 and the related CONTENTS line.
38 Where this really gets fun is if we set up a central server running the
39 CGI version. Not only can this be accessed through a web browser, but
40 also through the command-line tool. If you leave off the '--local' or
41 '-l' switches in any of the above examples, the local tool will try to
42 connect to the server listed in it's config lines, instead of working
43 with a local database. This would allow you to query for files that you
44 have not yet installed
46 For example, if you are trying to make an ebuild and the ./configure
47 script whines about not being able to find '', just do:
49 $ pdb -q /usr/lib/
51 ...and if anyone has stored that package to the server, you should get
52 back the name of the package you need to install.
54 --Chouser