| 1 |
#!/usr/bin/python |
| 2 |
|
| 3 |
import cgi |
| 4 |
import os |
| 5 |
import sys |
| 6 |
import config |
| 7 |
import gentoo,ebuilddb |
| 8 |
|
| 9 |
DEFAULT_EBUILD = "404" |
| 10 |
PKG_DIR = config.EBUILD_FILES |
| 11 |
|
| 12 |
if len(sys.argv): |
| 13 |
ebuild = sys.argv[1] |
| 14 |
else: |
| 15 |
ebuild = DEFAULT_EBUILD |
| 16 |
|
| 17 |
|
| 18 |
html_file = os.path.join(PKG_DIR,"%s.html" % ebuild.replace('..','')) |
| 19 |
#if os.path.exists(html_file): |
| 20 |
if 0: |
| 21 |
send_file = html_file |
| 22 |
else: |
| 23 |
# let's try the database |
| 24 |
# connect |
| 25 |
pieces = gentoo.pkgsplit(ebuild) |
| 26 |
name = pieces[0] |
| 27 |
if pieces[2] == 'r0': |
| 28 |
version = pieces[1] |
| 29 |
else: |
| 30 |
version = '-'.join(pieces[1:]) |
| 31 |
db = ebuilddb.db_connect() |
| 32 |
# query |
| 33 |
query = ('SELECT ebuild.category,ebuild.name,version,when_found,' |
| 34 |
'description,changelog,arch,homepage,license,is_masked ' |
| 35 |
'FROM ebuild,package WHERE ebuild.name="%s" AND ' |
| 36 |
'version="%s" AND ' |
| 37 |
'ebuild.name=package.name AND ebuild.category=package.category ' |
| 38 |
'ORDER by when_found DESC LIMIT 1' % (name,version)) |
| 39 |
#print query |
| 40 |
c = db.cursor() |
| 41 |
c.execute(query) |
| 42 |
result = c.fetchone() |
| 43 |
if result: |
| 44 |
#print result |
| 45 |
eb = gentoo.query_to_dict(result) |
| 46 |
sys.stdout.write(gentoo.ebuild_to_html(eb,show_bugs=0, full=True)) |
| 47 |
sys.exit(0) |
| 48 |
# else 404 |
| 49 |
else: |
| 50 |
send_file = os.path.join(PKG_DIR,"%s.html" % DEFAULT_EBUILD) |
| 51 |
|
| 52 |
sys.stdout.write(open(send_file,"r").read()) |
| 53 |
sys.stdout.flush() |