summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'fever/fever.py')
-rw-r--r--fever/fever.py95
1 files changed, 53 insertions, 42 deletions
diff --git a/fever/fever.py b/fever/fever.py
index 5fdd690..900c390 100644
--- a/fever/fever.py
+++ b/fever/fever.py
@@ -4,13 +4,12 @@
# Fever - by Michał Bentkowski 2007
# licensed under GPL
-# first, let's do some koji things
-import koji
-session=koji.ClientSession("http://koji.fedoraproject.org/kojihub")
+# Adapted to Gentoo by Robert Buchholz <rbu@gentoo.org>
# now, import the other things we need
-from commons import download, rpmvercmp, vercmpsort
+from commons import download, vercmpsort
+import ebuildversion
import re
from xml.sax.saxutils import unescape
@@ -21,43 +20,40 @@ socket.setdefaulttimeout(45)
import sys
class Fever:
- def __init__(self, debug=0,
- listformat="\* (?P<name>.*?) (?P<regex>.*) (?P<url>.*?)\n",
- listlocation="http://fedoraproject.org/wiki/PackageMaintainers/FEver"):
+ def __init__(self, debug = 0,
+ listformat = "\* (?P<name>.*?) (?P<regex>.*) (?P<url>.*?)\n",
+ listlocation = "http://fedoraproject.org/wiki/PackageMaintainers/FEver"):
+ if debug >= 1:
+ print "Starting download of Package list"
self.debug=debug
- #self.listformat=listformat
- #self.lislocation=listlocation
- # it's sane to download a site with a list of packages at once
- site=download(listlocation, debug)
+ # it's sane to download the site with a list of packages at once
+ site = download(listlocation, debug)
# and let's parse it!
- self.pkglist={} # this var will keep all info of packages
+ self.pkglist = {} # this var will keep all info of packages
for package in re.finditer(listformat, site):
- dict=package.groupdict() #retrieve dictionary with name regex and url
- name=dict['name']
- del dict['name'] # we don't need name in dict anymore
- # sometimes there are escaped chars like &lt; in regex
+ #retrieve dictionary with name regex and url
+ dict = package.groupdict()
+ name = dict['name']
+ # we don't need name in dict anymore
+ del dict['name']
+ # sometimes there are escaped chars like &lt; in regex
# so we need to unescape them first
- dict['regex']=unescape(dict['regex'])
- self.pkglist[name]=dict
- self.pkglist[name]['checked']=False
+ dict['regex'] = unescape(dict['regex'])
+ self.pkglist[name] = dict
+ self.pkglist[name]['checked'] = False
if debug >= 2:
print "%s parsed. Data: %s" % (name,dict)
+ if debug >= 1:
+ print "Finished building package list"
- def getPkgSiteVersion(self,pkgname):
+ def getPkgSiteVersion(self, pkgname):
# download a proper site and get a package version
- site=download(self.pkglist[pkgname]['url'], self.debug)
- regex=self.pkglist[pkgname]['regex']
- versions=vercmpsort( re.findall(regex, site) ) # find all versions and sort'em
- return versions[0] # we need only the newest one
-
- def getPkgKojiVersion(self, pkgname):
- # first, we need koji's package id
- pkgid=session.getPackageID(pkgname)
- # now, list all builds
- builds=session.listBuilds(pkgid)
- # extract all versions and sort'em
- versions=vercmpsort( [x['version'] for x in session.listBuilds(pkgid)])
- return versions[0] # return the newest one
+ site = download(self.pkglist[pkgname]['url'], self.debug)
+ regex = self.pkglist[pkgname]['regex']
+ # find all versions and sort'em
+ versions = vercmpsort(re.findall(regex, site))
+ # we need only the newest one
+ return versions[0]
def getPkgList(self):
return self.pkglist
@@ -72,23 +68,38 @@ class Fever:
# (it may happen if there's something wrong with regex) and 1 if a package's
# owner need to update his package, -1 - if error.
if self.debug >= 1:
- print 'Checking %s...' % pkgname
+ print 'Checking %s ...' % pkgname
try:
- sitever=self.getPkgSiteVersion(pkgname)
- kojiver=self.getPkgKojiVersion(pkgname)
+ sitever = self.getPkgSiteVersion(pkgname)
+ if self.debug >= 2:
+ print 'Latest on site: %s' % str(sitever)
+ comparison_result = ebuildversion.compareVersionsFor(pkgname, sitever)
+ kojiver = comparison_result['best_version']
+ if self.debug >= 2:
+ print 'Latest ebuild: %s' % str(kojiver)
+ is_latest = comparison_result['is_latest']
+ if self.debug >= 2:
+ if is_latest:
+ print 'Is latest'
+ else:
+ print 'Needs update'
+ except KeyError:
+ if self.debug >= 1:
+ print "%s was not found in Gentoo." % (pkgname)
+ self.pkglist[pkgname]['checked']=False
+ return -1
except:
# if no version were found, we don't need this package anymore
if self.debug >= 1:
- print "%s won't be checked. Error. %s" % (pkgname, str(sys.exc_info()))
+ print "%s won't be checked. Error. %s" % (pkgname, str(sys.exc_info()[0]))
self.pkglist[pkgname]['checked']=False
return -1
- if self.debug >= 2:
- print '%s: koji: %s; site: %s' % (pkgname, kojiver, sitever)
- compare=rpmvercmp(kojiver, sitever)
self.pkglist[pkgname]['kojiver']=kojiver
self.pkglist[pkgname]['sitever']=sitever
self.pkglist[pkgname]['checked']=True
- if compare == -1: #if a newer version's available
+ if self.debug >= 2:
+ print ""
+ if not is_latest: #if a newer version's available
self.pkglist[pkgname]['uptodate']=False
return 1
else: # if isn't
@@ -100,7 +111,7 @@ class Fever:
for package in self.pkglist.keys():
result=self.checkPackage(package)
- def isPackageUpToDate(self,pkgname):
+ def isPackageUpToDate(self, pkgname):
# just check if a given package is up to date
return self.pkglist[pkgname]['uptodate']