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

Contents of /src/packages/gentoo.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations) (download) (as text)
Wed Oct 5 01:41:55 2005 UTC (9 years ago) by marduk
Branch: MAIN
Changes since 1.14: +2 -11 lines
File MIME type: text/x-python
Quite crapily backported changelogs rendering enhancements from pre_2-0

1 #!/usr/bin/python -O
2 """These functions mainly take ebuild info (grabbed from the database and
3 convert it to HTML. See the "main" function at the bottom."""
4
5 __revision__ = "$Revision: 1.14 $"
6 # $Source: /var/cvsroot/gentoo/src/packages/gentoo.py,v $
7
8 import config
9 import os
10 import time
11 import string
12 import sys
13 import ebuilddb
14 import bugs
15 import changelogs
16 from cgi import escape
17 from urllib import quote
18
19 endversion={"pre":-2,"p":0,"alpha":-4,"beta":-3,"rc":-1}
20 # as there's no reliable way to set {}.keys() order
21 # netversion_keys will be used instead of endversion.keys
22 # to have fixed search order, so that "pre" is checked
23 # before "p"
24 endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
25
26 def is_new(db, ebuild):
27 """Check for newness."""
28
29 c = db.cursor()
30 query = ('SELECT new FROM package WHERE category="%s" AND name="%s"'
31 % (ebuild['category'], ebuild['name']))
32 c.execute(query)
33 results = c.fetchall()
34 if len(results) == 1 and results[0][0]:
35 return 1
36 return 0
37
38 changelog_to_html = changelogs.bugs_to_html
39
40 def homepage_to_html(homepage):
41 """convert HOMEPAGE entry to HTML"""
42 if not homepage.strip():
43 return "?"
44 homepage = homepage.replace('|',' ')
45 pieces = homepage.split()
46 count = len(pieces)
47 if count == 1:
48 return ('<a class="homepage" href="%s">'
49 'Homepage</a>' % pieces[0])
50
51 html = ['[<a href="%s">%s</a>]' % (page, index + 1) for index,
52 page in enumerate(pieces)]
53 return " ".join(['<span class="homepage">Homepages'] + html +
54 ['</span>'])
55
56 def license_to_html(license):
57 """Create link to license[s]"""
58 if not license.strip(): return "?"
59 license = license.replace('|',' ')
60 license = license.replace('(', '')
61 license = license.replace(')', '')
62 pieces = license.split()
63 html = ['<a href="http://www.gentoo.org/cgi-bin/viewcvs.cgi/*checkout*/'
64 'licenses/%s">%s</a>' % (piece, piece) for piece in pieces]
65 return '<br>\n'.join(html)
66
67 def package_to_html(pkginfo, db, full=False):
68 """This function needs a database (db) connection because it performs a
69 query_to_dict on the package"""
70
71 table_begin = '<table class="ebuild">'
72 name = '<tr><td class="fields">%s</td></tr>' % pkginfo['name']
73 if full:
74 image = ('<img class="pkgimg"alt="" src="%s/%s/%s.jpg" align="right">' %
75 (config.ICONS, pkginfo['category'], pkginfo['name'])
76 )
77 else:
78 image = ''
79 description = ('<tr><td class="item">'
80 '%s<b>Description: </b>%s</td></tr>'
81 % (image, escape(pkginfo['description']))
82 )
83 ebuilds = get_recent_releases(pkginfo, db)
84 releases = '<tr><td>%s</td></tr>' % archs_to_html(ebuilds, 'Releases')
85 #bug_string = ('<br><h3>Related bugs:</h3>\n%s'
86 # % bugs_to_html(pkginfo['name']))
87 general = '<tr><td>%s</td></tr>' % general_info_to_html(pkginfo)
88 #similar = '<tr><td>%s</td></tr>' % create_similar_pkgs_link(pkginfo)
89 table_end = '</table>'
90 rows = '\n\t'.join([name, description, releases, general])
91 return '\n\t'.join([table_begin, rows, table_end])
92
93 def archs_to_html(ebuilds, heading = None):
94 """Create table for availability on each architecture"""
95 heading = heading or '&nbsp;'
96 table_begin = '<table class="releases">'
97 header_row = ''.join(['<tr><td><b>%s</b></td>' % heading] +
98 ['<th class="arch">%s</th>' % i.replace('-',' ') for i in config.ARCHLIST] +
99 ['</tr>']
100 )
101 rows = []
102 ebuilds.sort(cmp_ebuilds)
103 ebuilds.reverse()
104 for ebuild in ebuilds:
105 archs = ebuild['arch'].split()
106 row_start = ('<tr>\n\t<th class="releases"><a href="%sebuilds/?%s-%s"'
107 ' title="%s">%s</a></th>\n' % (config.FEHOME,
108 ebuild['name'], ebuild['version'], ebuild['time'],
109 ebuild['version']))
110 row_data = []
111 for arch in config.ARCHLIST:
112 if arch in archs:
113 arch_string = '+'
114 elif '~%s' % arch in archs:
115 arch_string = '~'
116 else:
117 arch_string = '-'
118 if arch_string != '-' and ebuild['masked']:
119 arch_string = 'M' + arch_string
120 row_data.append('\t<td class="archcell" arch="%s">%s</td>'
121 % (arch_string, arch_string))
122 row_end = '</tr>'
123 rows.append('\n\t'.join([row_start] + row_data + [row_end]))
124 table_end = '</table>'
125 return '\n\t'.join([table_begin] + [header_row] + rows + [table_end])
126
127 def ebuild_to_html(ebinfo, new=0, show_bugs=0, full = False):
128 """Convert ebuild (dict) to html, if new, print out a "this is new" notice
129 if show_bugs, show bugs for this particular ebuild (requires access to
130 bugzilla"""
131 if new:
132 new_string = """ &nbsp;&nbsp;<span class="new">new!</span> """
133 else:
134 new_string = ""
135
136 table_begin = '<table class="ebuild">'
137 name_and_date = ('<tr><td class="fields">'
138 '<a href="%spackages/?category=%s;name=%s">%s</a> %s%s<br>'
139 '<span class="time">%s</span>'
140 '</td></tr>' % (config.FEHOME, quote(ebinfo['category']),
141 quote(ebinfo['name']),
142 ebinfo['name'],
143 ebinfo['version'],
144 new_string,
145 ebinfo['time'].strftime("%c %Z")))
146
147 if full:
148 image = ('<img class="pkgimg" alt="" src="%s/%s/%s.jpg" align="right">' %
149 (config.ICONS, ebinfo['category'], ebinfo['name'])
150 )
151 else:
152 image = ''
153 desc_and_changes = ('<tr><td class="item" valign="top">'
154 '<p><b>Description:</b> %s %s</p>'
155 '<p><b>Changes:</b><br>'
156 '%s</p></td></tr>' % (
157 escape(ebinfo['description']),
158 image,
159 changelog_to_html(ebinfo['changelog'])))
160
161 archs = '<tr><td>%s</td></tr>' % archs_to_html([ebinfo])
162 general = '<tr><td>%s</td></tr>' % general_info_to_html(ebinfo)
163 table_end = '</table>'
164
165 bug_string = ''
166 if show_bugs:
167 bug_string = bugs_to_html(ebinfo['name'])
168 if bug_string:
169 bug_string = '<br><h3 class="bugs">Related bugs:</h3>%s' \
170 % bug_string
171
172 return '\n\t'.join([table_begin,
173 name_and_date,
174 desc_and_changes,
175 archs,
176 general,
177 table_end,
178 bug_string])
179
180 def general_info_to_html(pkg):
181 """This actually will (should) take either a package or ebuild dict
182 as an argument"""
183
184 import forums
185
186 changelogurl = ('http://www.gentoo.org/cgi-bin/viewcvs.cgi/*checkout*/'
187 '%s/%s/ChangeLog' % (pkg['category'],pkg['name']))
188 cat_header = '<th class="category">Category</th>'
189 license_header = '<th class="license">License</th>'
190 category = ('<td class="category">'
191 '<a href="%spackages/?category=%s">%s</a></td>' % (config.FEHOME,
192 pkg['category'], pkg['category']))
193 homepage = ('<td class="homepage" rowspan="2">%s</td>'
194 % homepage_to_html(pkg['homepage']))
195 license = ('<td class="license">%s</td>'
196 % license_to_html(pkg['license']))
197 changelog = ('<td class="changelog" rowspan="2">'
198 '<a href="%s">ChangeLog</a></td>' % changelogurl)
199 similar = ('<td class="similar" rowspan="2">'
200 '%s</td>' % create_similar_pkgs_link(pkg))
201 related_bugs = ('<td class="related_bugs" rowspan="2">'
202 '%s</td>' % create_related_bugs_link(pkg))
203 forums = ('<td class="forums" rowspan="2">'
204 '%s</td>' % forums.create_forums_link(pkg))
205
206 return '\n\t'.join(['<table class="general_info">',
207 '<tr>',
208 cat_header,
209 homepage,
210 license_header,
211 changelog,
212 similar,
213 related_bugs,
214 forums,
215 '</tr>',
216 '<tr>',
217 category,
218 license,
219 '</tr>',
220 '</table>'])
221
222 def create_similar_pkgs_link(pkg):
223 """Create a link to similar packages"""
224
225 def strip_chars(mystring):
226 newstring = ''
227 for char in mystring:
228 if char not in string.punctuation:
229 newstring = newstring + char
230 else:
231 newstring = newstring + ' '
232 return newstring
233
234 description = strip_chars(pkg['description'].lower())
235
236 words = [word for word in description.split()
237 if word and len(word)>2 and word not in config.EXCLUDED_FROM_SIMILAR]
238 words = words[:config.SIMILAR_MAX_WORDS] + [pkg['name']]
239 #query = ['[[:<:]]%s[[:>:]].*' % word for word in words]
240 query = ['[[:<:]]%s.*' % word for word in words]
241 query = '(%s){%s,}' % ('|'.join(query), config.SIMILAR_MIN_MATCHES)
242 url = '%ssearch/?sstring=%s' % (config.FEHOME, escape(query))
243 return '<a href="%s">Similar</a>' % url
244
245 def create_related_bugs_link(pkg):
246 """Create a link to related bugs"""
247
248 url = ('http://bugs.gentoo.org/buglist.cgi?query_format='
249 '&amp;short_desc_type=allwords'
250 '&amp;short_desc=%s'
251 '&amp;bug_status=UNCONFIRMED'
252 '&amp;bug_status=NEW'
253 '&amp;bug_status=ASSIGNED'
254 '&amp;bug_status=REOPENED'
255 % escape(pkg['name']))
256
257 return '<a title="bugs.gentoo.org" href="%s">Bugs</a>' % url
258
259 def bugs_to_html(package):
260 """Given package name (no version #s), return html text of bugs as
261 reported by bugzilla"""
262 # Right now we have an issue with the bugzilla site. New interface
263 # needs to be written, Bail out.
264 #return ""
265 import urllib2
266 url = ('http://bugs.gentoo.org/buglist.cgi?query_format='
267 '&amp;short_desc_type=allwords'
268 '&amp;short_desc=%s'
269 '&amp;bug_status=UNCONFIRMED'
270 '&amp;bug_status=NEW'
271 '&amp;bug_status=ASSIGNED'
272 '&amp;bug_status=REOPENED'
273 '&amp;ctype=csv'
274 % package)
275 fp = urllib2.urlopen(url)
276 factory = bugs.BugFactory()
277 package_bugs = factory.fromCSV(fp)
278 if package_bugs:
279 writer = bugs.HTMLWriter(package_bugs, 'bugs.gentoo.org')
280 return str(writer)
281 else:
282 return ""
283
284 def get_most_recent(db, max=config.MAXPERPAGE, arch="", branch="", new = False):
285 c = db.cursor()
286 extra = ''
287 if arch:
288 stable_extra = ('ebuild.arch REGEXP "^%s[[:>:]]|[[:blank:]]%s[[:>:]]" '
289 % (arch,arch))
290 testing_extra = ('ebuild.arch REGEXP "[~]%s[[:>:]]" ' % arch)
291 if branch == 'stable':
292 extra = ' AND (%s) ' % stable_extra
293 elif branch == 'testing':
294 extra = ' AND (%s) ' % testing_extra
295 else:
296 extra = ' AND ((%s) OR (%s)) ' % (stable_extra, testing_extra)
297
298 if new:
299 extra = ('%s AND package.new=1 ' % extra)
300
301 query = """SELECT ebuild.category,ebuild.name,version,when_found,description,
302 changelog,arch,homepage,license,is_masked FROM ebuild,package WHERE ebuild.name=\
303 package.name AND ebuild.category=package.category %s ORDER by when_found DESC \
304 LIMIT %s""" % (extra,max)
305 c.execute(query)
306 results = c.fetchall()
307 return results
308
309 def get_most_recent_bumps(db, max=config.MAXPERPAGE):
310 """Return most recent version bumps (pkgs with no prevarch)"""
311 c = db.cursor()
312 query = ('SELECT ebuild.category, ebuild.name, version, when_found, '
313 'description, changelog, arch, homepage, license,is_masked FROM ebuild, package '
314 'WHERE ebuild.name=package.name AND ebuild.category=package.category '
315 'AND prevarch="" AND version NOT LIKE "%%-r_" AND version NOT LIKE '
316 '"%%-r__" AND NOT new ORDER by when_found '
317 'DESC LIMIT %s' % max)
318
319 c.execute(query)
320 results = c.fetchall()
321 return results
322
323 def query_to_dict(d):
324 """Convert a SQL query to a dict"""
325 einfo = {}
326 keys = ('category', 'name', 'version', 'time', 'description', 'changelog',
327 'arch', 'homepage', 'license', 'masked')
328 for i in range(len(keys)):
329 try:
330 einfo[keys[i]] = d[i]
331 except IndexError:
332 continue
333 return einfo
334
335 def get_recent_releases(pkg, db, max=config.MAX_RECENT_RELEASES):
336 """Return MAX_RECENT_RELEASES most recent releases for pkg. Returns and
337 ebuild-type dict"""
338 c = db.cursor()
339 query = ('SELECT category,name,version,when_found,NULL,changelog,arch ,'
340 'NULL,NULL,is_masked FROM ebuild WHERE name="%s" AND category="%s" ORDER BY '
341 'version DESC LIMIT %s' % (pkg['name'],pkg['category'],max))
342 c.execute(query)
343 results = c.fetchall()
344 #print results
345 return [ query_to_dict(i) for i in results ]
346
347 def cmp_ebuilds(a, b):
348 """Compare two ebuilds"""
349 fields_a = pkgsplit('%s-%s' % (a['name'], a['version']))
350 fields_b = pkgsplit('%s-%s' % (b['name'], b['version']))
351 return pkgcmp(fields_a, fields_b)
352
353 pkgcache={}
354
355 def pkgsplit(mypkg,silent=1):
356 try:
357 if not pkgcache[mypkg]:
358 return None
359 return pkgcache[mypkg][:]
360 except KeyError:
361 pass
362 myparts=string.split(mypkg,'-')
363 if len(myparts)<2:
364 if not silent:
365 print "!!! Name error in",mypkg+": missing a version or name part."
366 pkgcache[mypkg]=None
367 return None
368 for x in myparts:
369 if len(x)==0:
370 if not silent:
371 print "!!! Name error in",mypkg+": empty \"-\" part."
372 pkgcache[mypkg]=None
373 return None
374 #verify rev
375 revok=0
376 myrev=myparts[-1]
377 if len(myrev) and myrev[0]=="r":
378 try:
379 int(myrev[1:])
380 revok=1
381 except SystemExit, e:
382 raise
383 except:
384 pass
385 if revok:
386 if ververify(myparts[-2]):
387 if len(myparts)==2:
388 pkgcache[mypkg]=None
389 return None
390 else:
391 for x in myparts[:-2]:
392 if ververify(x):
393 pkgcache[mypkg]=None
394 return None
395 #names can't have versiony looking parts
396 myval=[string.join(myparts[:-2],"-"),myparts[-2],myparts[-1]]
397 pkgcache[mypkg]=myval
398 return myval
399 else:
400 pkgcache[mypkg]=None
401 return None
402
403 elif ververify(myparts[-1],silent=silent):
404 if len(myparts)==1:
405 if not silent:
406 print "!!! Name error in",mypkg+": missing name part."
407 pkgcache[mypkg]=None
408 return None
409 else:
410 for x in myparts[:-1]:
411 if ververify(x):
412 if not silent:
413 print "!!! Name error in",mypkg+": multiple version parts."
414 pkgcache[mypkg]=None
415 return None
416 myval=[string.join(myparts[:-1],"-"),myparts[-1],"r0"]
417 pkgcache[mypkg]=myval[:]
418 return myval
419 else:
420 pkgcache[mypkg]=None
421 return None
422
423 vercache={}
424 def ververify(myorigval,silent=1):
425 try:
426 return vercache[myorigval]
427 except KeyError:
428 pass
429 if len(myorigval)==0:
430 if not silent:
431 print "!!! Name error: package contains empty \"-\" part."
432 return 0
433 myval=string.split(myorigval,'.')
434 if len(myval)==0:
435 if not silent:
436 print "!!! Name error: empty version string."
437 vercache[myorigval]=0
438 return 0
439 #all but the last version must be a numeric
440 for x in myval[:-1]:
441 if not len(x):
442 if not silent:
443 print "!!! Name error in",myorigval+": two decimal points in a row"
444 vercache[myorigval]=0
445 return 0
446 try:
447 foo=int(x)
448 except SystemExit, e:
449 raise
450 except:
451 if not silent:
452 print "!!! Name error in",myorigval+": \""+x+"\" is not a valid version component."
453 vercache[myorigval]=0
454 return 0
455 if not len(myval[-1]):
456 if not silent:
457 print "!!! Name error in",myorigval+": two decimal points in a row"
458 vercache[myorigval]=0
459 return 0
460 try:
461 foo=int(myval[-1])
462 vercache[myorigval]=1
463 return 1
464 except SystemExit, e:
465 raise
466 except:
467 pass
468 #ok, our last component is not a plain number or blank, let's continue
469 if myval[-1][-1] in string.lowercase:
470 try:
471 foo=int(myval[-1][:-1])
472 vercache[myorigval]=1
473 return 1
474 # 1a, 2.0b, etc.
475 except SystemExit, e:
476 raise
477 except:
478 pass
479 #ok, maybe we have a 1_alpha or 1_beta2; let's see
480 #ep="endpart"
481 ep=string.split(myval[-1],"_")
482 if len(ep)!=2:
483 if not silent:
484 print "!!! Name error in",myorigval
485 vercache[myorigval]=0
486 return 0
487 try:
488 foo=int(ep[0][-1])
489 chk=ep[0]
490 except SystemExit, e:
491 raise
492 except:
493 # because it's ok last char is not numeric. example: foo-1.0.0a_pre1
494 chk=ep[0][:-1]
495
496 try:
497 foo=int(chk)
498 except SystemExit, e:
499 raise
500 except:
501 #this needs to be numeric or numeric+single letter,
502 #i.e. the "1" in "1_alpha" or "1a_alpha"
503 if not silent:
504 print "!!! Name error in",myorigval+": characters before _ must be numeric or numeric+single letter"
505 vercache[myorigval]=0
506 return 0
507 for mye in endversion_keys:
508 if ep[1][0:len(mye)]==mye:
509 if len(mye)==len(ep[1]):
510 #no trailing numeric; ok
511 vercache[myorigval]=1
512 return 1
513 else:
514 try:
515 foo=int(ep[1][len(mye):])
516 vercache[myorigval]=1
517 return 1
518 except SystemExit, e:
519 raise
520 except:
521 #if no endversions work, *then* we return 0
522 pass
523 if not silent:
524 print "!!! Name error in",myorigval
525 vercache[myorigval]=0
526 return 0
527
528 def relparse(myver):
529 "converts last version part into three components"
530 number=0
531 suffix=0
532 endtype=0
533 endnumber=0
534
535 mynewver=string.split(myver,"_")
536 myver=mynewver[0]
537
538 #normal number or number with letter at end
539 divider=len(myver)-1
540 if myver[divider:] not in "1234567890":
541 #letter at end
542 suffix=ord(myver[divider:])
543 number=string.atof(myver[0:divider])
544 else:
545 number=string.atof(myver)
546
547 if len(mynewver)==2:
548 #an endversion
549 for x in endversion_keys:
550 elen=len(x)
551 if mynewver[1][:elen] == x:
552 endtype=endversion[x]
553 try:
554 endnumber=string.atof(mynewver[1][elen:])
555 except:
556 endnumber=0
557 break
558 return [number,suffix,endtype,endnumber]
559
560 # vercmp:
561 # ripped from portage.py to prevent having to import
562 vcmpcache={}
563 def vercmp(val1,val2):
564 if val1==val2:
565 #quick short-circuit
566 return 0
567 valkey=val1+" "+val2
568 try:
569 return vcmpcache[valkey]
570 try:
571 return -vcmpcache[val2+" "+val1]
572 except KeyError:
573 pass
574 except KeyError:
575 pass
576
577 # consider 1_p2 vc 1.1
578 # after expansion will become (1_p2,0) vc (1,1)
579 # then 1_p2 is compared with 1 before 0 is compared with 1
580 # to solve the bug we need to convert it to (1,0_p2)
581 # by splitting _prepart part and adding it back _after_expansion
582 val1_prepart = val2_prepart = ''
583 if val1.count('_'):
584 val1, val1_prepart = val1.split('_', 1)
585 if val2.count('_'):
586 val2, val2_prepart = val2.split('_', 1)
587
588 # replace '-' by '.'
589 # FIXME: Is it needed? can val1/2 contain '-'?
590 val1=string.split(val1,'-')
591 if len(val1)==2:
592 val1[0]=val1[0]+"."+val1[1]
593 val2=string.split(val2,'-')
594 if len(val2)==2:
595 val2[0]=val2[0]+"."+val2[1]
596
597 val1=string.split(val1[0],'.')
598 val2=string.split(val2[0],'.')
599
600 #add back decimal point so that .03 does not become "3" !
601 for x in range(1,len(val1)):
602 if val1[x][0] == '0' :
603 val1[x]='.' + val1[x]
604 for x in range(1,len(val2)):
605 if val2[x][0] == '0' :
606 val2[x]='.' + val2[x]
607
608 # extend version numbers
609 if len(val2)<len(val1):
610 val2.extend(["0"]*(len(val1)-len(val2)))
611 elif len(val1)<len(val2):
612 val1.extend(["0"]*(len(val2)-len(val1)))
613
614 # add back _prepart tails
615 if val1_prepart:
616 val1[-1] += '_' + val1_prepart
617 if val2_prepart:
618 val2[-1] += '_' + val2_prepart
619 #The above code will extend version numbers out so they
620 #have the same number of digits.
621 for x in range(0,len(val1)):
622 cmp1=relparse(val1[x])
623 cmp2=relparse(val2[x])
624 for y in range(0,4):
625 myret=cmp1[y]-cmp2[y]
626 if myret != 0:
627 vcmpcache[valkey]=myret
628 return myret
629 vcmpcache[valkey]=0
630 return 0
631
632 # pkgcmp:
633 # ripped from portage.py to prevent having to import
634 def pkgcmp(pkg1,pkg2):
635 """if returnval is less than zero, then pkg2 is newer than pkg1, zero if equal and positive if older."""
636 if pkg1[0] != pkg2[0]:
637 return None
638 mycmp=vercmp(pkg1[1],pkg2[1])
639 if mycmp>0:
640 return 1
641 if mycmp<0:
642 return -1
643 r1=int(pkg1[2][1:])
644 r2=int(pkg2[2][1:])
645 if r1>r2:
646 return 1
647 if r2>r1:
648 return -1
649 return 0
650
651 def ebuilds_to_rss(fp, ebuilds, simple=False, subtitle=""):
652 """write out ebuild info to RSS file (fp)"""
653
654 # web link for RSS feed
655 if subtitle:
656 link = '%s/%s' % (config.FEHOME, subtitle.replace(' ','/',1))
657 else:
658 link = config.FEHOME
659
660 pubDate = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
661 fp.write("""<?xml version="1.0" encoding="UTF-8"?>
662 <rss version="2.0">
663 <channel>
664 <title>packages.gentoo.org [ %s ]</title>
665 <link>%s</link>
666 <description>Latest ebuilds from the Gentoo Linux portage tree</description>
667 <webMaster>www@gentoo.org</webMaster>
668
669 <image>
670 <title>Online Package Database</title>
671 <url>%s</url>
672 <link>%s</link>
673 </image>
674
675 <managingEditor>marduk@gentoo.org</managingEditor>
676 <pubDate>%s</pubDate>""" % (subtitle, link, config.RSS_IMAGE,
677 config.FEHOME, pubDate))
678
679 for ebuild in ebuilds:
680 if simple:
681 description = escape(ebuild['description'])
682 else:
683 description = ('\n'
684 '<![CDATA[\n'
685 '<link rel="stylesheet" type="text/css" href="%s"></link>\n'
686 '%s\n]]>' % (config.STYLESHEET, ebuild_to_html(ebuild, full=True))
687 )
688
689 fp.write("""<item>
690 <title>%s/%s %s</title>
691 <link>%sebuilds/?%s-%s</link>
692 <description>
693 %s
694 </description>
695 <pubDate>%s</pubDate>
696 </item>
697 """ % (ebuild['category'],
698 ebuild['name'],
699 ebuild['version'],
700 config.FEHOME,
701 ebuild['name'],
702 ebuild['version'],
703 description,
704 ebuild['time'].strftime("%a, %d %b %Y %H:%M:%S +0000"))
705 )
706
707 fp.write("\n\
708 <textInput>\n\
709 <title>Search the Online Package Database</title>\n\
710 <link>%s/search/</link>\n\
711 <description>emerge -Ss</description>\n\
712 <name>sstring</name>\n\
713 </textInput>\n\
714 </channel>\n\
715 </rss>\n" % config.FEHOME)
716
717 def main(argv=None):
718 if argv is None:
719 argv = sys.argv
720 try:
721 if argv[1] == '-g':
722 ebuilddb.main()
723 except IndexError:
724 pass
725
726 db = ebuilddb.db_connect()
727 branches = ('', 'stable', 'testing')
728 for arch in [''] + config.ARCHLIST:
729 for branch in branches:
730 fullpath = os.path.join(config.LOCALHOME, "archs", arch, branch,
731 config.INDEX)
732 index = open(fullpath,'w')
733
734 index.write("""<table border="0" cellpadding="0" cellspacing="5"
735 width="100%">\n""")
736 index.write("""<tr><td valign="top">\n""")
737 index.write('<!--#include file="archnav.html" -->\n\n</td></tr>\n'
738 '<tr><td>')
739 results = get_most_recent(db, arch=arch, branch=branch)
740 ebuilds = [ query_to_dict(i) for i in results ]
741 for ebuild in ebuilds:
742 new = is_new(db, ebuild)
743 pkgfilename = "%s/%s-%s.html" % (
744 config.EBUILD_FILES,ebuild['name'],ebuild['version'])
745 ebuild_html = ebuild_to_html(ebuild, new, show_bugs = False)
746 if arch == '' and branch == '':
747 pkgfile = open(pkgfilename,'w')
748 pkgfile.write(ebuild_html)
749 pkgfile.close()
750 ebuildfilename = "%s/%s/%s/%s-%s.ebuild" \
751 % (ebuilddb.config.PORTAGE_DIR,
752 ebuild['category'],ebuild['name'],ebuild['name'],
753 ebuild['version'])
754 os.system('touch -r %s %s || touch -d "today -1 year" %s'
755 % (ebuildfilename,pkgfilename,pkgfilename))
756
757 try:
758 index.write('%s\n\n' % (ebuild_html))
759 except IOError:
760 continue
761 index.write("""</table>\n""")
762 index.close()
763
764 subtitle = ' %s %s' % (arch, branch)
765 rss = open(os.path.join(config.LOCALHOME, "archs", arch, branch,
766 config.RSS), 'w')
767 ebuilds_to_rss(rss, ebuilds, simple=False, subtitle=subtitle)
768 rss.close()
769
770 rss2 = open(os.path.join(config.LOCALHOME, "archs", arch, branch,
771 config.RSS2), 'w')
772 ebuilds_to_rss(rss2, ebuilds, simple=True, subtitle=subtitle)
773 rss.close()
774
775 if __name__ == '__main__':
776 sys.exit(main())

  ViewVC Help
Powered by ViewVC 1.1.20