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

Diff of /src/packages/gentoo.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.10 Revision 1.11
1#!/usr/bin/python -O 1#!/usr/bin/python -O
2"""These functions mainly take ebuild info (grabbed from the database and 2"""These functions mainly take ebuild info (grabbed from the database and
3 convert it to HTML. See the "main" function at the bottom.""" 3 convert it to HTML. See the "main" function at the bottom."""
4 4
5__revision__ = "$Revision: 1.10 $" 5__revision__ = "$Revision: 1.11 $"
6# $Source: /var/cvsroot/gentoo/src/packages/gentoo.py,v $ 6# $Source: /var/cvsroot/gentoo/src/packages/gentoo.py,v $
7 7
8import config 8import config
9import os 9import os
10import time 10import time
23# before "p" 23# before "p"
24endversion_keys = ["pre", "p", "alpha", "beta", "rc"] 24endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
25 25
26def is_new(db, ebuild): 26def is_new(db, ebuild):
27 """Check for newness.""" 27 """Check for newness."""
28 28
29 c = db.cursor() 29 c = db.cursor()
30 query = ('SELECT new FROM package WHERE category="%s" AND name="%s"' 30 query = ('SELECT new FROM package WHERE category="%s" AND name="%s"'
31 % (ebuild['category'], ebuild['name'])) 31 % (ebuild['category'], ebuild['name']))
32 c.execute(query) 32 c.execute(query)
33 results = c.fetchall() 33 results = c.fetchall()
46 html = changelogs.bugs_to_html(html) 46 html = changelogs.bugs_to_html(html)
47 return html 47 return html
48 48
49def homepage_to_html(homepage): 49def homepage_to_html(homepage):
50 """convert HOMEPAGE entry to HTML""" 50 """convert HOMEPAGE entry to HTML"""
51 if not homepage.strip(): 51 if not homepage.strip():
52 return "?" 52 return "?"
53 homepage = homepage.replace('|',' ') 53 homepage = homepage.replace('|',' ')
54 pieces = homepage.split() 54 pieces = homepage.split()
55 count = len(pieces) 55 count = len(pieces)
56 if count == 1: 56 if count == 1:
57 return ('<a class="homepage" href="%s">' 57 return ('<a class="homepage" href="%s">'
58 'Homepage</a>' % pieces[0]) 58 'Homepage</a>' % pieces[0])
59 59
60 html = ['[<a href="%s">%s</a>]' % (page, index + 1) for index, 60 html = ['[<a href="%s">%s</a>]' % (page, index + 1) for index,
61 page in enumerate(pieces)] 61 page in enumerate(pieces)]
62 return " ".join(['<span class="homepage">Homepages'] + html + 62 return " ".join(['<span class="homepage">Homepages'] + html +
63 ['</span>']) 63 ['</span>'])
64 64
65def license_to_html(license): 65def license_to_html(license):
66 """Create link to license[s]""" 66 """Create link to license[s]"""
67 if not license.strip(): return "?" 67 if not license.strip(): return "?"
72 html = ['<a href="http://www.gentoo.org/cgi-bin/viewcvs.cgi/*checkout*/' 72 html = ['<a href="http://www.gentoo.org/cgi-bin/viewcvs.cgi/*checkout*/'
73 'licenses/%s">%s</a>' % (piece, piece) for piece in pieces] 73 'licenses/%s">%s</a>' % (piece, piece) for piece in pieces]
74 return '<br>\n'.join(html) 74 return '<br>\n'.join(html)
75 75
76def package_to_html(pkginfo, db, full=False): 76def package_to_html(pkginfo, db, full=False):
77 """This function needs a database (db) connection because it performs a 77 """This function needs a database (db) connection because it performs a
78 query_to_dict on the package""" 78 query_to_dict on the package"""
79 79
80 table_begin = '<table class="ebuild">' 80 table_begin = '<table class="ebuild">'
81 name = '<tr><td class="fields">%s</td></tr>' % pkginfo['name'] 81 name = '<tr><td class="fields">%s</td></tr>' % pkginfo['name']
82 if full: 82 if full:
83 image = ('<img class="pkgimg"alt="" src="%s/%s/%s.jpg" align="right">' % 83 image = ('<img class="pkgimg"alt="" src="%s/%s/%s.jpg" align="right">' %
84 (config.ICONS, pkginfo['category'], pkginfo['name']) 84 (config.ICONS, pkginfo['category'], pkginfo['name'])
85 ) 85 )
86 else: 86 else:
87 image = '' 87 image = ''
88 description = ('<tr><td class="item">' 88 description = ('<tr><td class="item">'
89 '%s<b>Description: </b>%s</td></tr>' 89 '%s<b>Description: </b>%s</td></tr>'
90 % (image, escape(pkginfo['description'])) 90 % (image, escape(pkginfo['description']))
91 ) 91 )
92 ebuilds = get_recent_releases(pkginfo, db) 92 ebuilds = get_recent_releases(pkginfo, db)
93 releases = '<tr><td>%s</td></tr>' % archs_to_html(ebuilds, 'Releases') 93 releases = '<tr><td>%s</td></tr>' % archs_to_html(ebuilds, 'Releases')
94 #bug_string = ('<br><h3>Related bugs:</h3>\n%s' 94 #bug_string = ('<br><h3>Related bugs:</h3>\n%s'
95 # % bugs_to_html(pkginfo['name'])) 95 # % bugs_to_html(pkginfo['name']))
96 general = '<tr><td>%s</td></tr>' % general_info_to_html(pkginfo) 96 general = '<tr><td>%s</td></tr>' % general_info_to_html(pkginfo)
97 similar = '<tr><td>%s</td></tr>' % create_similar_pkgs_link(pkginfo) 97 #similar = '<tr><td>%s</td></tr>' % create_similar_pkgs_link(pkginfo)
98 table_end = '</table>' 98 table_end = '</table>'
99 rows = '\n\t'.join([name, description, releases, general]) 99 rows = '\n\t'.join([name, description, releases, general])
100 return '\n\t'.join([table_begin, rows, table_end]) 100 return '\n\t'.join([table_begin, rows, table_end])
101 101
102def archs_to_html(ebuilds, heading = None): 102def archs_to_html(ebuilds, heading = None):
111 ebuilds.sort(cmp_ebuilds) 111 ebuilds.sort(cmp_ebuilds)
112 ebuilds.reverse() 112 ebuilds.reverse()
113 for ebuild in ebuilds: 113 for ebuild in ebuilds:
114 archs = ebuild['arch'].split() 114 archs = ebuild['arch'].split()
115 row_start = ('<tr>\n\t<th class="releases"><a href="%sebuilds/?%s-%s"' 115 row_start = ('<tr>\n\t<th class="releases"><a href="%sebuilds/?%s-%s"'
116 ' title="%s">%s</a></th>\n' % (config.FEHOME, 116 ' title="%s">%s</a></th>\n' % (config.FEHOME,
117 ebuild['name'], ebuild['version'], ebuild['time'], 117 ebuild['name'], ebuild['version'], ebuild['time'],
118 ebuild['version'])) 118 ebuild['version']))
119 row_data = [] 119 row_data = []
120 for arch in config.ARCHLIST: 120 for arch in config.ARCHLIST:
121 if arch in archs: 121 if arch in archs:
122 arch_string = '+' 122 arch_string = '+'
130 % (arch_string, arch_string)) 130 % (arch_string, arch_string))
131 row_end = '</tr>' 131 row_end = '</tr>'
132 rows.append('\n\t'.join([row_start] + row_data + [row_end])) 132 rows.append('\n\t'.join([row_start] + row_data + [row_end]))
133 table_end = '</table>' 133 table_end = '</table>'
134 return '\n\t'.join([table_begin] + [header_row] + rows + [table_end]) 134 return '\n\t'.join([table_begin] + [header_row] + rows + [table_end])
135 135
136def ebuild_to_html(ebinfo, new=0, show_bugs=0, full = False): 136def 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 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 138 if show_bugs, show bugs for this particular ebuild (requires access to
139 bugzilla""" 139 bugzilla"""
140 if new: 140 if new:
141 new_string = """ &nbsp;&nbsp;<span class="new">new!</span> """ 141 new_string = """ &nbsp;&nbsp;<span class="new">new!</span> """
142 else: 142 else:
143 new_string = "" 143 new_string = ""
144 144
145 table_begin = '<table class="ebuild">' 145 table_begin = '<table class="ebuild">'
146 name_and_date = ('<tr><td class="fields">' 146 name_and_date = ('<tr><td class="fields">'
147 '<a href="%spackages/?category=%s;name=%s">%s</a> %s%s<br>' 147 '<a href="%spackages/?category=%s;name=%s">%s</a> %s%s<br>'
148 '<span class="time">%s</span>' 148 '<span class="time">%s</span>'
149 '</td></tr>' % (config.FEHOME, quote(ebinfo['category']), 149 '</td></tr>' % (config.FEHOME, quote(ebinfo['category']),
150 quote(ebinfo['name']), 150 quote(ebinfo['name']),
151 ebinfo['name'], 151 ebinfo['name'],
152 ebinfo['version'], 152 ebinfo['version'],
153 new_string, 153 new_string,
154 ebinfo['time'].localtime().strftime("%c %Z"))) 154 ebinfo['time'].localtime().strftime("%c %Z")))
155 155
156 if full: 156 if full:
157 image = ('<img class="pkgimg" alt="" src="%s/%s/%s.jpg" align="right">' % 157 image = ('<img class="pkgimg" alt="" src="%s/%s/%s.jpg" align="right">' %
158 (config.ICONS, ebinfo['category'], ebinfo['name']) 158 (config.ICONS, ebinfo['category'], ebinfo['name'])
159 ) 159 )
160 else: 160 else:
168 changelog_to_html(ebinfo['changelog']))) 168 changelog_to_html(ebinfo['changelog'])))
169 169
170 archs = '<tr><td>%s</td></tr>' % archs_to_html([ebinfo]) 170 archs = '<tr><td>%s</td></tr>' % archs_to_html([ebinfo])
171 general = '<tr><td>%s</td></tr>' % general_info_to_html(ebinfo) 171 general = '<tr><td>%s</td></tr>' % general_info_to_html(ebinfo)
172 table_end = '</table>' 172 table_end = '</table>'
173 173
174 bug_string = '' 174 bug_string = ''
175 if show_bugs: 175 if show_bugs:
176 bug_string = bugs_to_html(ebinfo['name']) 176 bug_string = bugs_to_html(ebinfo['name'])
177 if bug_string: 177 if bug_string:
178 bug_string = '<br><h3 class="bugs">Related bugs:</h3>%s' \ 178 bug_string = '<br><h3 class="bugs">Related bugs:</h3>%s' \
179 % bug_string 179 % bug_string
180 180
181 return '\n\t'.join([table_begin, 181 return '\n\t'.join([table_begin,
182 name_and_date, 182 name_and_date,
183 desc_and_changes, 183 desc_and_changes,
184 archs, 184 archs,
185 general, 185 general,
186 table_end, 186 table_end,
187 bug_string]) 187 bug_string])
188 188
189def general_info_to_html(pkg): 189def general_info_to_html(pkg):
190 """This actually will (should) take either a package or ebuild dict 190 """This actually will (should) take either a package or ebuild dict
191 as an argument""" 191 as an argument"""
192 192
193 import forums 193 import forums
194 194
195 changelogurl = ('http://www.gentoo.org/cgi-bin/viewcvs.cgi/*checkout*/' 195 changelogurl = ('http://www.gentoo.org/cgi-bin/viewcvs.cgi/*checkout*/'
196 '%s/%s/ChangeLog' % (pkg['category'],pkg['name'])) 196 '%s/%s/ChangeLog' % (pkg['category'],pkg['name']))
197 cat_header = '<th class="category">Category</th>' 197 cat_header = '<th class="category">Category</th>'
198 license_header = '<th class="license">License</th>' 198 license_header = '<th class="license">License</th>'
199 category = ('<td class="category">' 199 category = ('<td class="category">'
200 '<a href="%spackages/?category=%s">%s</a></td>' % (config.FEHOME, 200 '<a href="%spackages/?category=%s">%s</a></td>' % (config.FEHOME,
201 pkg['category'], pkg['category'])) 201 pkg['category'], pkg['category']))
202 homepage = ('<td class="homepage" rowspan="2">%s</td>' 202 homepage = ('<td class="homepage" rowspan="2">%s</td>'
203 % homepage_to_html(pkg['homepage'])) 203 % homepage_to_html(pkg['homepage']))
204 license = ('<td class="license">%s</td>' 204 license = ('<td class="license">%s</td>'
205 % license_to_html(pkg['license'])) 205 % license_to_html(pkg['license']))
206 changelog = ('<td class="changelog" rowspan="2">' 206 changelog = ('<td class="changelog" rowspan="2">'
207 '<a href="%s">ChangeLog</a></td>' % changelogurl) 207 '<a href="%s">ChangeLog</a></td>' % changelogurl)
208 similar = ('<td class="similar" rowspan="2">' 208 similar = ('<td class="similar" rowspan="2">'
209 '%s</td>' % create_similar_pkgs_link(pkg)) 209 '%s</td>' % create_similar_pkgs_link(pkg))
210 related_bugs = ('<td class="related_bugs" rowspan="2">' 210 related_bugs = ('<td class="related_bugs" rowspan="2">'
211 '%s</td>' % create_related_bugs_link(pkg)) 211 '%s</td>' % create_related_bugs_link(pkg))
212 forums = ('<td class="forums" rowspan="2">' 212 forums = ('<td class="forums" rowspan="2">'
213 '%s</td>' % forums.create_forums_link(pkg)) 213 '%s</td>' % forums.create_forums_link(pkg))
214 214
215 return '\n\t'.join(['<table class="general_info">', 215 return '\n\t'.join(['<table class="general_info">',
216 '<tr>', 216 '<tr>',
217 cat_header, 217 cat_header,
218 homepage, 218 homepage,
219 license_header, 219 license_header,
225 '<tr>', 225 '<tr>',
226 category, 226 category,
227 license, 227 license,
228 '</tr>', 228 '</tr>',
229 '</table>']) 229 '</table>'])
230 230
231def create_similar_pkgs_link(pkg): 231def create_similar_pkgs_link(pkg):
232 """Create a link to similar packages""" 232 """Create a link to similar packages"""
233 233
234 def strip_chars(mystring): 234 def strip_chars(mystring):
235 newstring = '' 235 newstring = ''
236 for char in mystring: 236 for char in mystring:
237 if char not in string.punctuation: 237 if char not in string.punctuation:
238 newstring = newstring + char 238 newstring = newstring + char
239 else: 239 else:
240 newstring = newstring + ' ' 240 newstring = newstring + ' '
241 return newstring 241 return newstring
242 242
243 description = strip_chars(pkg['description'].lower()) 243 description = strip_chars(pkg['description'].lower())
244 244
245 words = [word for word in description.split() 245 words = [word for word in description.split()
246 if word and len(word)>2 and word not in config.EXCLUDED_FROM_SIMILAR] 246 if word and len(word)>2 and word not in config.EXCLUDED_FROM_SIMILAR]
247 words = words[:config.SIMILAR_MAX_WORDS] + [pkg['name']] 247 words = words[:config.SIMILAR_MAX_WORDS] + [pkg['name']]
248 #query = ['[[:<:]]%s[[:>:]].*' % word for word in words] 248 #query = ['[[:<:]]%s[[:>:]].*' % word for word in words]
249 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) 250 query = '(%s){%s,}' % ('|'.join(query), config.SIMILAR_MIN_MATCHES)
251 url = '%ssearch/?sstring=%s' % (config.FEHOME, escape(query)) 251 url = '%ssearch/?sstring=%s' % (config.FEHOME, escape(query))
252 return '<a href="%s">Similar</a>' % url 252 return '<a href="%s">Similar</a>' % url
253 253
254def create_related_bugs_link(pkg): 254def create_related_bugs_link(pkg):
255 """Create a link to related bugs""" 255 """Create a link to related bugs"""
256 256
257 url = ('http://bugs.gentoo.org/buglist.cgi?query_format=' 257 url = ('http://bugs.gentoo.org/buglist.cgi?query_format='
258 '&amp;short_desc_type=allwords' 258 '&amp;short_desc_type=allwords'
259 '&amp;short_desc=%s' 259 '&amp;short_desc=%s'
260 '&amp;bug_status=UNCONFIRMED' 260 '&amp;bug_status=UNCONFIRMED'
261 '&amp;bug_status=NEW' 261 '&amp;bug_status=NEW'
262 '&amp;bug_status=ASSIGNED' 262 '&amp;bug_status=ASSIGNED'
263 '&amp;bug_status=REOPENED' 263 '&amp;bug_status=REOPENED'
264 % escape(pkg['name'])) 264 % escape(pkg['name']))
265 265
266 return '<a title="bugs.gentoo.org" href="%s">Bugs</a>' % url 266 return '<a title="bugs.gentoo.org" href="%s">Bugs</a>' % url
267 267
268def bugs_to_html(package): 268def bugs_to_html(package):
269 """Given package name (no version #s), return html text of bugs as 269 """Given package name (no version #s), return html text of bugs as
270 reported by bugzilla""" 270 reported by bugzilla"""
271 # Right now we have an issue with the bugzilla site. New interface 271 # Right now we have an issue with the bugzilla site. New interface
272 # needs to be written, Bail out. 272 # needs to be written, Bail out.
277 '&amp;short_desc=%s' 277 '&amp;short_desc=%s'
278 '&amp;bug_status=UNCONFIRMED' 278 '&amp;bug_status=UNCONFIRMED'
279 '&amp;bug_status=NEW' 279 '&amp;bug_status=NEW'
280 '&amp;bug_status=ASSIGNED' 280 '&amp;bug_status=ASSIGNED'
281 '&amp;bug_status=REOPENED' 281 '&amp;bug_status=REOPENED'
282 '&amp;ctype=csv' 282 '&amp;ctype=csv'
283 % package) 283 % package)
284 fp = urllib2.urlopen(url) 284 fp = urllib2.urlopen(url)
285 factory = bugs.BugFactory() 285 factory = bugs.BugFactory()
286 package_bugs = factory.fromCSV(fp) 286 package_bugs = factory.fromCSV(fp)
287 if package_bugs: 287 if package_bugs:
288 writer = bugs.HTMLWriter(package_bugs, 'bugs.gentoo.org') 288 writer = bugs.HTMLWriter(package_bugs, 'bugs.gentoo.org')
289 return str(writer) 289 return str(writer)
290 else: 290 else:
291 return "" 291 return ""
292 292
293def get_most_recent(db, max=config.MAXPERPAGE, arch="", branch="", new = False): 293def get_most_recent(db, max=config.MAXPERPAGE, arch="", branch="", new = False):
294 c = db.cursor() 294 c = db.cursor()
295 extra = '' 295 extra = ''
296 if arch: 296 if arch:
297 stable_extra = ('ebuild.arch REGEXP "^%s[[:>:]]|[[:blank:]]%s[[:>:]]" ' 297 stable_extra = ('ebuild.arch REGEXP "^%s[[:>:]]|[[:blank:]]%s[[:>:]]" '
301 extra = ' AND (%s) ' % stable_extra 301 extra = ' AND (%s) ' % stable_extra
302 elif branch == 'testing': 302 elif branch == 'testing':
303 extra = ' AND (%s) ' % testing_extra 303 extra = ' AND (%s) ' % testing_extra
304 else: 304 else:
305 extra = ' AND ((%s) OR (%s)) ' % (stable_extra, testing_extra) 305 extra = ' AND ((%s) OR (%s)) ' % (stable_extra, testing_extra)
306 306
307 if new: 307 if new:
308 extra = ('%s AND package.new=1 ' % extra) 308 extra = ('%s AND package.new=1 ' % extra)
309 309
310 query = """SELECT ebuild.category,ebuild.name,version,when_found,description, 310 query = """SELECT ebuild.category,ebuild.name,version,when_found,description,
311 changelog,arch,homepage,license,is_masked FROM ebuild,package WHERE ebuild.name=\ 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 \ 312 package.name AND ebuild.category=package.category %s ORDER by when_found DESC \
313 LIMIT %s""" % (extra,max) 313 LIMIT %s""" % (extra,max)
314 c.execute(query) 314 c.execute(query)
315 results = c.fetchall() 315 results = c.fetchall()
316 return results 316 return results
317 317
318def get_most_recent_bumps(db, max=config.MAXPERPAGE): 318def get_most_recent_bumps(db, max=config.MAXPERPAGE):
319 """Return most recent version bumps (pkgs with no prevarch)""" 319 """Return most recent version bumps (pkgs with no prevarch)"""
320 c = db.cursor() 320 c = db.cursor()
321 query = ('SELECT ebuild.category, ebuild.name, version, when_found, ' 321 query = ('SELECT ebuild.category, ebuild.name, version, when_found, '
322 'description, changelog, arch, homepage, license,is_masked FROM ebuild, package ' 322 'description, changelog, arch, homepage, license,is_masked FROM ebuild, package '
323 'WHERE ebuild.name=package.name AND ebuild.category=package.category ' 323 'WHERE ebuild.name=package.name AND ebuild.category=package.category '
324 'AND prevarch="" AND version NOT LIKE "%%-r_" AND version NOT LIKE ' 324 'AND prevarch="" AND version NOT LIKE "%%-r_" AND version NOT LIKE '
325 '"%%-r__" AND NOT new ORDER by when_found ' 325 '"%%-r__" AND NOT new ORDER by when_found '
326 'DESC LIMIT %s' % max) 326 'DESC LIMIT %s' % max)
327 327
328 c.execute(query) 328 c.execute(query)
329 results = c.fetchall() 329 results = c.fetchall()
330 return results 330 return results
331 331
332def query_to_dict(d): 332def query_to_dict(d):
333 """Convert a SQL query to a dict""" 333 """Convert a SQL query to a dict"""
334 einfo = {} 334 einfo = {}
335 keys = ('category', 'name', 'version', 'time', 'description', 'changelog', 335 keys = ('category', 'name', 'version', 'time', 'description', 'changelog',
336 'arch', 'homepage', 'license', 'masked') 336 'arch', 'homepage', 'license', 'masked')
387 try: 387 try:
388 int(myrev[1:]) 388 int(myrev[1:])
389 revok=1 389 revok=1
390 except SystemExit, e: 390 except SystemExit, e:
391 raise 391 raise
392 except: 392 except:
393 pass 393 pass
394 if revok: 394 if revok:
395 if ververify(myparts[-2]): 395 if ververify(myparts[-2]):
396 if len(myparts)==2: 396 if len(myparts)==2:
397 pkgcache[mypkg]=None 397 pkgcache[mypkg]=None
526 return 1 526 return 1
527 except SystemExit, e: 527 except SystemExit, e:
528 raise 528 raise
529 except: 529 except:
530 #if no endversions work, *then* we return 0 530 #if no endversions work, *then* we return 0
531 pass 531 pass
532 if not silent: 532 if not silent:
533 print "!!! Name error in",myorigval 533 print "!!! Name error in",myorigval
534 vercache[myorigval]=0 534 vercache[myorigval]=0
535 return 0 535 return 0
536 536
538 "converts last version part into three components" 538 "converts last version part into three components"
539 number=0 539 number=0
540 suffix=0 540 suffix=0
541 endtype=0 541 endtype=0
542 endnumber=0 542 endnumber=0
543 543
544 mynewver=string.split(myver,"_") 544 mynewver=string.split(myver,"_")
545 myver=mynewver[0] 545 myver=mynewver[0]
546 546
547 #normal number or number with letter at end 547 #normal number or number with letter at end
548 divider=len(myver)-1 548 divider=len(myver)-1
549 if myver[divider:] not in "1234567890": 549 if myver[divider:] not in "1234567890":
550 #letter at end 550 #letter at end
551 suffix=ord(myver[divider:]) 551 suffix=ord(myver[divider:])
552 number=string.atof(myver[0:divider]) 552 number=string.atof(myver[0:divider])
553 else: 553 else:
554 number=string.atof(myver) 554 number=string.atof(myver)
555 555
556 if len(mynewver)==2: 556 if len(mynewver)==2:
557 #an endversion 557 #an endversion
558 for x in endversion_keys: 558 for x in endversion_keys:
559 elen=len(x) 559 elen=len(x)
560 if mynewver[1][:elen] == x: 560 if mynewver[1][:elen] == x:
561 match=1
562 endtype=endversion[x] 561 endtype=endversion[x]
563 try: 562 try:
564 endnumber=string.atof(mynewver[1][elen:]) 563 endnumber=string.atof(mynewver[1][elen:])
565 except SystemExit, e:
566 raise
567 except: 564 except:
568 endnumber=0 565 endnumber=0
569 break 566 break
570 return [number,suffix,endtype,endnumber] 567 return [number,suffix,endtype,endnumber]
571 568
583 return -vcmpcache[val2+" "+val1] 580 return -vcmpcache[val2+" "+val1]
584 except KeyError: 581 except KeyError:
585 pass 582 pass
586 except KeyError: 583 except KeyError:
587 pass 584 pass
588 585
589 # consider 1_p2 vc 1.1 586 # consider 1_p2 vc 1.1
590 # after expansion will become (1_p2,0) vc (1,1) 587 # after expansion will become (1_p2,0) vc (1,1)
591 # then 1_p2 is compared with 1 before 0 is compared with 1 588 # 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) 589 # to solve the bug we need to convert it to (1,0_p2)
593 # by splitting _prepart part and adding it back _after_expansion 590 # by splitting _prepart part and adding it back _after_expansion
660 return -1 657 return -1
661 return 0 658 return 0
662 659
663def ebuilds_to_rss(fp, ebuilds, simple=False, subtitle=""): 660def ebuilds_to_rss(fp, ebuilds, simple=False, subtitle=""):
664 """write out ebuild info to RSS file (fp)""" 661 """write out ebuild info to RSS file (fp)"""
662
663 # web link for RSS feed
664 if subtitle:
665 link = '%s/%s' % (config.FEHOME, subtitle.replace(' ','/',1))
666 else:
667 link = config.FEHOME
668
669 pubDate = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
665 fp.write("""<?xml version="1.0" encoding="UTF-8"?> 670 fp.write("""<?xml version="1.0" encoding="UTF-8"?>
666 <rss version="0.92"> 671 <rss version="2.0">
667 <channel> 672 <channel>
668 <title>packages.gentoo.org [ %s ]</title> 673 <title>packages.gentoo.org [ %s ]</title>
669 <link>%s</link> 674 <link>%s</link>
670 <description>Latest ebuilds from the Gentoo Linux portage tree</description> 675 <description>Latest ebuilds from the Gentoo Linux portage tree</description>
671 <webMaster>www@gentoo.org</webMaster> 676 <webMaster>www@gentoo.org</webMaster>
677
678 <image>
679 <title>Online Package Database</title>
680 <url>%s</url>
681 <link>%s</link>
682 </image>
683
672 <managingEditor>marduk@gentoo.org</managingEditor> 684 <managingEditor>marduk@gentoo.org</managingEditor>
673 <pubDate>%s</pubDate>""" % (subtitle,config.FEHOME, 685 <pubDate>%s</pubDate>""" % (subtitle, link, config.RSS_IMAGE,
674 time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()))) 686 config.FEHOME, pubDate))
675 687
676 for ebuild in ebuilds: 688 for ebuild in ebuilds:
677 if simple: 689 if simple:
678 description = escape(ebuild['description']) 690 description = escape(ebuild['description'])
679 else: 691 else:
680 description = ('\n' 692 description = ('\n'
681 '<![CDATA[\n' 693 '<![CDATA[\n'
682 '<link rel="stylesheet" type="text/css" href="%s"></link>\n' 694 '<link rel="stylesheet" type="text/css" href="%s"></link>\n'
683 '%s\n]]>' % (config.STYLESHEET, ebuild_to_html(ebuild, full=True)) 695 '%s\n]]>' % (config.STYLESHEET, ebuild_to_html(ebuild, full=True))
684 ) 696 )
685 697
686 fp.write("""<item> 698 fp.write("""<item>
687 <title>%s %s</title> 699 <title>%s %s</title>
688 <link>%sebuilds/?%s-%s</link> 700 <link>%sebuilds/?%s-%s</link>
689 <description> 701 <description>
697 ebuild['name'], 709 ebuild['name'],
698 ebuild['version'], 710 ebuild['version'],
699 description, 711 description,
700 ebuild['time'].gmtime().strftime("%a, %d %b %Y %H:%M:%S +0000")) 712 ebuild['time'].gmtime().strftime("%a, %d %b %Y %H:%M:%S +0000"))
701 ) 713 )
702 714
703 fp.write("</channel>\n</rss>\n") 715 fp.write("\n\
704 716 <textinput>\n\
717 <title>Search the Online Package Database</title>\n\
718 <link>%s/search/</link>\n\
719 <description>emerge -Ss</description>\n\
720 <name>sstring</name>\n\
721 </textinput>\n\
722 </channel>\n\
723 </rss>\n" % config.FEHOME)
724
705def main(argv=None): 725def main(argv=None):
706 if argv is None: 726 if argv is None:
707 argv = sys.argv 727 argv = sys.argv
708 try: 728 try:
709 if argv[1] == '-g': 729 if argv[1] == '-g':
710 ebuilddb.main() 730 ebuilddb.main()
711 except IndexError: 731 except IndexError:
712 pass 732 pass
713 733
714 db = ebuilddb.db_connect() 734 db = ebuilddb.db_connect()
715 branches = ('', 'stable', 'testing') 735 branches = ('', 'stable', 'testing')
716 for arch in [''] + config.ARCHLIST: 736 for arch in [''] + config.ARCHLIST:
717 for branch in branches: 737 for branch in branches:
718 fullpath = os.path.join(config.LOCALHOME, "archs", arch, branch, 738 fullpath = os.path.join(config.LOCALHOME, "archs", arch, branch,
719 config.INDEX) 739 config.INDEX)
720 index = open(fullpath,'w') 740 index = open(fullpath,'w')
721 if arch: 741
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" 742 index.write("""<table border="0" cellpadding="0" cellspacing="5"
731 width="100%">\n""") 743 width="100%">\n""")
732 index.write("""<tr><td valign="top">\n""") 744 index.write("""<tr><td valign="top">\n""")
733 index.write('<!--#include file="archnav.html" -->\n\n</td></tr>\n' 745 index.write('<!--#include file="archnav.html" -->\n\n</td></tr>\n'
734 '<tr><td>') 746 '<tr><td>')
735 results = get_most_recent(db, arch=arch, branch=branch) 747 results = get_most_recent(db, arch=arch, branch=branch)
736 ebuilds = [ query_to_dict(i) for i in results ] 748 ebuilds = [ query_to_dict(i) for i in results ]
737 for ebuild in ebuilds: 749 for ebuild in ebuilds:
738 new = is_new(db, ebuild) 750 new = is_new(db, ebuild)
739 pkgfilename = "%s/%s-%s.html" % ( 751 pkgfilename = "%s/%s-%s.html" % (
745 pkgfile.close() 757 pkgfile.close()
746 ebuildfilename = "%s/%s/%s/%s-%s.ebuild" \ 758 ebuildfilename = "%s/%s/%s/%s-%s.ebuild" \
747 % (ebuilddb.config.PORTAGE_DIR, 759 % (ebuilddb.config.PORTAGE_DIR,
748 ebuild['category'],ebuild['name'],ebuild['name'], 760 ebuild['category'],ebuild['name'],ebuild['name'],
749 ebuild['version']) 761 ebuild['version'])
750 os.system('touch -r %s %s || touch -d "today -1 year" %s' 762 os.system('touch -r %s %s || touch -d "today -1 year" %s'
751 % (ebuildfilename,pkgfilename,pkgfilename)) 763 % (ebuildfilename,pkgfilename,pkgfilename))
752 764
753 try: 765 try:
754 index.write('%s\n\n' % (ebuild_html)) 766 index.write('%s\n\n' % (ebuild_html))
755 except IOError: 767 except IOError:
756 continue 768 continue
757 index.write("""</table>\n""") 769 index.write("""</table>\n""")
758 index.close() 770 index.close()
759 771
760 subtitle = ' %s %s' % (arch, branch) 772 subtitle = ' %s %s' % (arch, branch)
761 rss = open(os.path.join(config.LOCALHOME, "archs", arch, branch, 773 rss = open(os.path.join(config.LOCALHOME, "archs", arch, branch,
762 config.RSS), 'w') 774 config.RSS), 'w')
763 ebuilds_to_rss(rss, ebuilds, simple=False, subtitle=subtitle) 775 ebuilds_to_rss(rss, ebuilds, simple=False, subtitle=subtitle)
764 rss.close() 776 rss.close()
765 777
766 rss2 = open(os.path.join(config.LOCALHOME, "archs", arch, branch, 778 rss2 = open(os.path.join(config.LOCALHOME, "archs", arch, branch,
767 config.RSS2), 'w') 779 config.RSS2), 'w')
768 ebuilds_to_rss(rss2, ebuilds, simple=True, subtitle=subtitle) 780 ebuilds_to_rss(rss2, ebuilds, simple=True, subtitle=subtitle)
769 rss.close() 781 rss.close()
770 782

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20