1 |
-----BEGIN PGP SIGNED MESSAGE----- |
2 |
Hash: SHA1 |
3 |
|
4 |
Rob Smith wrote: |
5 |
> It will not get here, any attachments are killed, sent to the big /dev/null in |
6 |
> the sky... |
7 |
|
8 |
|
9 |
This reply-to business is getting stupid, I replied to all from Todd |
10 |
Heim's message and waited for it to appear here, and waited etc. |
11 |
|
12 |
Anyway, this should get through! |
13 |
|
14 |
- ------------------------------------------------------- |
15 |
#! /usr/bin/env python2.2 |
16 |
|
17 |
# Very simple program that searches the /usr/portage tree for |
18 |
# ebuilds that match a key provided by the user. |
19 |
|
20 |
from os.path import splitext, walk, isdir |
21 |
import re |
22 |
|
23 |
portageRoot = "/usr/portage" |
24 |
installRoot = "/var/db/pkg" |
25 |
|
26 |
# inelegant routine to assemble the install directory that is associated |
27 |
# with a given portage directory |
28 |
def getinstalldir(portagedir): |
29 |
path = portagedir.split('/') |
30 |
installdir = installRoot |
31 |
for dir in path[3:-1]: |
32 |
installdir += "/" + dir |
33 |
return installdir |
34 |
|
35 |
# workhorse routine: for each directory look for ebuild files and |
36 |
# interrogate each ebuild file to see if it matches the key and, |
37 |
# if it does, also check to see if it is installed. |
38 |
def visit(key, dirname, files): |
39 |
for file in files: |
40 |
(base, ext) = splitext(file) |
41 |
if (ext == ".ebuild"): |
42 |
if (re.search(key.lower(), base.lower())): |
43 |
# package found. Is it also installed? |
44 |
installname = getinstalldir(dirname) + '/' + base |
45 |
if (isdir(installname)): |
46 |
print dirname + "/" + file + "\t (installed)" |
47 |
else: |
48 |
print dirname + "/" + file |
49 |
|
50 |
|
51 |
if __name__ == '__main__': |
52 |
import sys |
53 |
if (len(sys.argv) != 2): |
54 |
print "Usage: pkgsearch key" |
55 |
sys.exit(1) |
56 |
key = sys.argv[1] |
57 |
walk(portageRoot, visit, key) |
58 |
|
59 |
- ------------------------------------------------------- |
60 |
|
61 |
- -- |
62 |
- ------------------------------------------------------------------------ |
63 |
Ian Smith |
64 |
Worst . . . signature . . . ever ! |
65 |
- ------------------------------------------------------------------------ |
66 |
-----BEGIN PGP SIGNATURE----- |
67 |
Version: GnuPG v1.0.7 (GNU/Linux) |
68 |
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org |
69 |
|
70 |
iD8DBQE9W/qEhzSkrHqkFB4RAnkyAKCp38jriNWjwednMREwpnoK8WEekACgobg4 |
71 |
S2qzFmphHkli/oNpBfSrbwc= |
72 |
=dAVr |
73 |
-----END PGP SIGNATURE----- |