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. |
4 |
|
5 |
The heart of the tool is a python module gentoo-src/portage/pym/portagedb.py |
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. |
12 |
|
13 |
Each of these front-ends has a small config section at the top that you |
14 |
will probably want to modify before using. |
15 |
|
16 |
To start using pdb locally, you must first store the packages you want |
17 |
to be able to look up: |
18 |
|
19 |
$ pdb --local --store foo/bar-1.2.3 |
20 |
|
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: |
23 |
|
24 |
$ cd /var/db/pkg; pdb -l -s */* |
25 |
|
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. |
30 |
|
31 |
$ pdb --local --query /usr/lib/libnsl.a |
32 |
sys-libs/glibc-2.2.4-r1 |
33 |
obj /usr/lib/libnsl.a B0C142667130D58EC72530CDB9FFBAD3 999228261 |
34 |
|
35 |
As you can see, this simply returns which package the file belongs to, |
36 |
and the related CONTENTS line. |
37 |
|
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 |
45 |
|
46 |
For example, if you are trying to make an ebuild and the ./configure |
47 |
script whines about not being able to find 'libfoobar.so', just do: |
48 |
|
49 |
$ pdb -q /usr/lib/libfoobar.so |
50 |
|
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. |
53 |
|
54 |
--Chouser |