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

Contents of /src/packages/gentoo.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download) (as text)
Fri Jul 22 17:53:13 2005 UTC (9 years, 1 month ago) by marduk
Branch: MAIN
Changes since 1.9: +4 -7 lines
File MIME type: text/x-python
Change MySQL REGEXP argument for arch selection.  Fixes #99835

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

  ViewVC Help
Powered by ViewVC 1.1.20