/[gentoo]/src/packages/util.py
Gentoo

Contents of /src/packages/util.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Tue Aug 16 16:38:20 2005 UTC (9 years ago) by marduk
Branch: MAIN
CVS Tags: v1_3_1, release_1-5, HEAD
Branch point for: v1_3
File MIME type: text/x-python
Various utilities for manipulating packages.g.o.  Includes homepage_update
utility.

1 #!/usr/bin/python
2
3 """Various Utilities/Scriptlets for packages.gentoo.org"""
4
5
6 import sys
7 import config
8 from ebuilddb import parse_ebuild, get_extended_info
9
10 class Util:
11 def homepage_update(self):
12 """Update the HOMEPAGE Column for packages based on last updated Ebuild"""
13
14 sys.path = ["/usr/lib/portage/pym"]+sys.path
15 import portage
16 sys.path = sys.path[1:]
17
18 try:
19 c = config.db.cursor()
20 except AttributeError:
21 # old version of p.g.o
22 from ebuilddb import db_connect
23 config.db = db_connect()
24 c = config.db.cursor()
25
26 portage_dir = config.PORTAGE_DIR
27 query = ('SELECT category,name,version from ebuild GROUP BY category,name '
28 ' ORDER BY when_found DESC')
29 c.execute(query)
30 for category, name, version in c.fetchall():
31 ebuild_path = ('%(portage_dir)s/%(category)s/%(name)s/%(name)s-'
32 '%(version)s.ebuild' % locals())
33 ebuild = parse_ebuild(ebuild_path, portage.pkgsplit)
34 ebuild = get_extended_info(ebuild)
35
36 homepage = ebuild['homepage']
37 c.execute = ("""
38 UPDATE package
39 SET homepage = %s
40 WHERE category=%s
41 AND name = %s
42 """, (homepage, category, name))
43 config.db.commit()
44
45 def update_license_data(self):
46 """ONe time call"""
47 sys.path = ["/usr/lib/portage/pym"]+sys.path
48 import portage
49 sys.path = sys.path[1:]
50
51 try:
52 c = config.db.cursor()
53 except AttributeError:
54 # old version of p.g.o
55 from ebuilddb import db_connect
56 config.db = db_connect()
57 c = config.db.cursor()
58
59 for data in find_ebuilds():
60 ebuild = parse_ebuild(data, portage.pkgsplit)
61 if not ebuild:
62 continue
63 ebuild = get_extended_info(ebuild)
64
65 license = ebuild['license']
66 c.execute("""
67 UPDATE ebuild
68 SET license = %s
69 WHERE category = %s
70 AND name = %s
71 AND version = %s
72 """, (ebuild["license"], ebuild["category"], ebuild["name"],
73 ebuild["version"]))
74 config.db.commit()
75
76 if __name__ == '__main__':
77 from sys import argv, stderr, exit
78 from types import FunctionType
79
80 myUtil = Util()
81 util_dict = Util.__dict__
82 FUNCS = [x for x in util_dict if type(util_dict[x]) is FunctionType]
83
84 try:
85 func_name = argv[1]
86 except IndexError:
87 stderr.write('Usage %s <function>\n' % argv[0])
88 exit(1)
89
90 print func_name
91
92 if func_name in FUNCS:
93 util_dict[func_name](myUtil)
94
95 else:
96 stderr.write('%s is not defined\n' % func_name)
97 stderr.write('Available functions:\n%s\n' % '\n'.join(FUNCS))
98 exit(1)

  ViewVC Help
Powered by ViewVC 1.1.20