summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomáš Chvátal <scarabeus@gentoo.org>2009-11-22 02:05:36 +0100
committerTomáš Chvátal <scarabeus@gentoo.org>2009-11-22 02:05:36 +0100
commita892e9120ddbcc77a9310d16168c9bbe5c7a54a6 (patch)
treef90ef88fddd9a77ab84dc1b054e32372843d2d08 /modules
parentHandle aso tar.gz format. (diff)
downloadgentoo-bumpchecker-a892e9120ddbcc77a9310d16168c9bbe5c7a54a6.tar.gz
gentoo-bumpchecker-a892e9120ddbcc77a9310d16168c9bbe5c7a54a6.tar.bz2
gentoo-bumpchecker-a892e9120ddbcc77a9310d16168c9bbe5c7a54a6.zip
[x-modular] Add support for listing stable packages.
Diffstat (limited to 'modules')
-rw-r--r--modules/package_module.py11
-rw-r--r--modules/portage_module.py49
-rw-r--r--modules/xmodular_module.py26
-rw-r--r--modules/xmodular_output.py16
4 files changed, 65 insertions, 37 deletions
diff --git a/modules/package_module.py b/modules/package_module.py
index f06e94f..6e375e3 100644
--- a/modules/package_module.py
+++ b/modules/package_module.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright John N. Laliberte <allanonjl@gentoo.org>
# LICENSE - GPL2
@@ -53,8 +54,8 @@ class Package:
self.category,self.name,self.version,self.revision = split_string
self.raw_name = self.name
self.major_minor = self.parse_mm(self.version)
- else:
- print "Error, " + raw_string + " is not a valid package!"
+# else:
+# print "Error, " + raw_string + " is not a valid package!"
def parse_mm(self, version):
return '.'.join(version.split('.')[0:2])
@@ -69,8 +70,9 @@ class Package:
return self.name_plus_version
class PackageStatus:
- def __init__(self, name, portage_version, gnome_version, latest_version, status):
+ def __init__(self, name, stable_version, portage_version, gnome_version, latest_version, status):
self.name = name
+ self.stable_version = stable_version
self.portage_version = portage_version
self.gnome_version = gnome_version
self.latest_version = latest_version
@@ -85,8 +87,11 @@ class Status:
return -1
def NewerVersion(self):
return 2
+ def StableNeedUpdate(self):
+ return 3
property(Compliant)
property(NeedUpdate)
property(NotFound)
property(NewerVersion)
+ property(StableNeedUpdate)
diff --git a/modules/portage_module.py b/modules/portage_module.py
index ebc91f7..17b8f0f 100644
--- a/modules/portage_module.py
+++ b/modules/portage_module.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright John N. Laliberte <allanonjl@gentoo.org>
# LICENSE - GPL2
@@ -9,7 +10,7 @@ sys.path = ["/usr/lib/portage/pym"]+sys.path
os.environ["PORTAGE_CALLER"]="depchecker"
import portage
-import portage_util
+import portage.util
import clioptions_module
def get_dbtree():
@@ -66,46 +67,54 @@ def best_version_test(package1,package2):
# grabbing this from portageq, best to put it in here instead of
# having the overhead of calling it each time and getting the output.
-def find_latest_package_in_tree(package_name, portdb=None):
+def find_latest_package_in_tree(package_name, portdbapi=None):
try:
- if portdb is None:
- portdb = portage.db['/'][get_dbtree()]
-
- mylist = portdb.dbapi.match(package_name)
+ if portdbapi is None:
+ portdbapi = portage.db['/'][get_dbtree()].dbapi
+ mylist = portdbapi.match(package_name)
return portage.best(mylist)
except KeyError:
return None
# finds the latest available version of a package
-def find_packages_in_tree(package_list, portdir=None, all_overlays=False, overlay_list=None):
+def find_packages_in_tree(package_list, portdir=None, all_overlays=False, overlay_list=None, stable=False):
# this value needs to be configurable from cl
#overlays = ["/home/allanon/cvs/gnome"]
portage_versions = []
- portdb = portage.db['/'][get_dbtree()]
+ portdbsettings = portage.db['/'][get_dbtree()].settings
+ portdbapi = portage.db['/'][get_dbtree()].dbapi
old_dbapi = None
+ olddbapi_kw = None
+
+ if stable is not False:
+ mysettings = portage.config(clone=portdbsettings)
+ mysettings['ACCEPT_KEYWORDS'] = 'amd64' # the arch I care for :]
+ olddbapi_kw = portdbapi
+ portdbapi = portage.portdbapi(mysettings['PORTDIR'], mysettings)
+
if portdir is not None:
- mysettings = portage.config(clone=portdb.settings)
+ mysettings = portage.config(clone=portdbsettings)
mysettings['PORTDIR'] = portdir
- olddbapi = portdb.dbapi
- portdb.dbapi = portage.portdbapi(portdir, mysettings)
+ olddbapi = portdbapi
+ portdbapi = portage.portdbapi(mysettings['PORTDIR'])
else:
- portdir = portdb.settings['PORTDIR']
+ portdir = portdbsettings['PORTDIR']
if all_overlays is False:
# Prune list of trees to be scanned
- oldporttrees = portdb.dbapi.porttrees
- portdb.dbapi.porttrees = [os.path.realpath(portdir)]
+ oldporttrees = portdbapi.porttrees
+ portdbapi.porttrees = [os.path.realpath(portdir)]
# Now append the overlays we want. First resolve to absolute paths.
if overlay_list is not None:
- portdb.dbapi.porttrees += \
+ portdbapi.porttrees += \
[ os.path.realpath(overlay) for overlay in overlay_list ]
for package in package_list:
- best_package = find_latest_package_in_tree(package.name, portdb)
+ best_package = find_latest_package_in_tree(package.name, portdbapi)
# if it returns a package, hardcode to first result.
# cover the case where it doesn't exist in the tree.
@@ -115,13 +124,15 @@ def find_packages_in_tree(package_list, portdir=None, all_overlays=False, overla
# Restore portdb trees list
if all_overlays is False:
- portdb.dbapi.porttrees = oldporttrees
+ portdbapi.porttrees = oldporttrees
+ if olddbapi_kw is not None:
+ portage.dbapi = olddbapi_kw
if old_dbapi is not None:
portage.dbapi = old_dbapi
- return portage_versions
-
+ return portage_versions
+
def tests():
print split_package_into_parts("media-gfx/gimp-3.5.0-r3")
print split_package_into_parts("media-gfx/gimp-3.5")
diff --git a/modules/xmodular_module.py b/modules/xmodular_module.py
index e6a78f1..653318d 100644
--- a/modules/xmodular_module.py
+++ b/modules/xmodular_module.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright Tomas Chvatal <scarabeus@gentoo.org>
# LICENSE - GPL2
@@ -148,7 +149,7 @@ class X_modular:
return newfiles
import portage_module
-def compare_packages(release_packages, latest_packages, packages_in_portage):
+def compare_packages(release_packages, latest_packages, packages_in_portage, stable_packages_in_portage):
# we care about 5 cases
# 1. portage version is less than the release version. (RED)
# 2. portage version is equal to the release version, but less than the latest version. (LIGHT GREEN)
@@ -165,21 +166,27 @@ def compare_packages(release_packages, latest_packages, packages_in_portage):
release_package = package
latest_package = portage_module.findpackage(package.name, latest_packages)
portage_package = portage_module.findpackage(package.name, packages_in_portage)
-
- if portage_package == None:
+ stable_portage_package = portage_module.findpackage(package.name, stable_packages_in_portage)
+
+ if stable_portage_package == None and portage_package == None:
+ status = package_module.Status.NotFound
+ stable_portage_package = package_module.Package(package.name)
+ portage_package = package_module.Package(package.name)
+ elif stable_portage_package == None and portage_package != None:
+ status = package_module.Status.StableNeedUpdate
+ stable_portage_package = package_module.Package(package.name)
+ elif portage_package == None:
status = package_module.Status.NotFound
- # we need to create a phony package since findpackage
- # returns None
portage_package = package_module.Package(package.name)
-
elif portage_module.best_version_test(portage_package.name_plus_version, \
release_package.name_plus_version) == 2:
status = package_module.Status.NeedUpdate
-
elif portage_module.best_version_test(portage_package.name_plus_version, \
latest_package.name_plus_version) == 2:
status = package_module.Status.NewerVersion
-
+ elif portage_module.best_version_test(stable_portage_package.name_plus_version, \
+ portage_package.name_plus_version) == 2:
+ status = package_module.Status.StableNeedUpdate
else:
status = package_module.Status.Compliant
@@ -192,11 +199,12 @@ def compare_packages(release_packages, latest_packages, packages_in_portage):
if DEBUG:
print "package: " + str(release_package.name) + \
+ " | sp: " + str(stable_portage_package.version) + \
" | pp: " + str(portage_package.version) + \
" | rp: " + str(release_package.version) + \
" | lp: " + str(latest_package.version) + \
" | status: " + str(status)
- status_packages.append(package_module.PackageStatus(release_package.name, str(portage_package.version), str(release_package.version), str(latest_package.version), status))
+ status_packages.append(package_module.PackageStatus(release_package.name, str(stable_portage_package.version), str(portage_package.version), str(release_package.version), str(latest_package.version), status))
return status_packages
diff --git a/modules/xmodular_output.py b/modules/xmodular_output.py
index fafd528..84975c0 100644
--- a/modules/xmodular_output.py
+++ b/modules/xmodular_output.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright John N. Laliberte <allanonjl@gentoo.org>
# LICENSE - GPL2
@@ -65,7 +66,7 @@ class Output:
lines.append('</head>')
lines.append("<body>")
lines.append("<h2>Xorg progress Table</h2>")
- lines.append("contact " + os.environ["USER"] + "@gentoo.org if anything is not correct<br>")
+ lines.append("contact " + os.environ["ECHANGELOG_USER"] + " if anything is not correct<br>")
lines.append("Generated date: " + current_time + "<br>")
# stats
lines.append("<br>")
@@ -76,24 +77,27 @@ class Output:
lines.append('<table cellpadding="3">')
lines.append('<tr>')
- lines.append("<th>Package Name</th><th>Portage Version</th><th>Official Version</th><th>Latest Version</th>")
+ lines.append("<th>Package Name</th><th>STABLE Version</th><th>Testing Version</th><th>Official Version</th><th>Latest Version</th>")
lines.append('</tr>')
# data
for package in self.packages:
if package.status == package_module.Status.NeedUpdate:
lines.append('<tr bgcolor="#FF8A75">') # "red"
+ elif package.status == package_module.Status.StableNeedUpdate:
+ lines.append('<tr bgcolor="#66CCCC">') # "blue"
elif package.status == package_module.Status.Compliant:
lines.append('<tr bgcolor="#D0EE80">') # "green"
elif package.status == package_module.Status.NotFound:
lines.append('<tr bgcolor="#EBEBEB">') # "grey"
elif package.status == package_module.Status.NewerVersion:
- lines.append('<tr bgcolor="#FFFF95">') # "yellow"
+ lines.append('<tr bgcolor="#FBEC5D">') # "yellow"
lines.append("<td>" + str(package.name) + "</td>")
- lines.append("<td>" + str(package.portage_version) + "</td>")
- lines.append("<td>" + str(package.gnome_version) + "</td>")
- lines.append("<td>" + str(package.latest_version) + "</td>")
+ lines.append('<th>' + str(package.stable_version) + "</th>")
+ lines.append("<th>" + str(package.portage_version) + "</th>")
+ lines.append("<th>" + str(package.gnome_version) + "</th>")
+ lines.append("<th>" + str(package.latest_version) + "</th>")
lines.append("</tr>")