From: Michael Tremer Date: Tue, 8 Mar 2011 17:18:50 +0000 (+0100) Subject: Move packages that do not have all metadata to bottom of sorted lists. X-Git-Tag: 0.9.3~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b566f7e3c83884fc3bd0f9e59459174faacb9a7f;p=pakfire.git Move packages that do not have all metadata to bottom of sorted lists. --- diff --git a/pakfire/packages/base.py b/pakfire/packages/base.py index 2e6fd11bd..5b346253c 100644 --- a/pakfire/packages/base.py +++ b/pakfire/packages/base.py @@ -26,11 +26,23 @@ class Package(object): return cmp(self.name, other.name) # Compare the uuids: if packages have the same id they are totally equal. - if self.uuid and self.uuid == other.uuid: + if self.uuid and other.uuid and self.uuid == other.uuid: return 0 ret = util.version_compare(self.version_tuple, other.version_tuple) + # XXX this is to move packages that have been built a while ago and + # do not have all the meta information that they won't be evaluated + # as the best match. + if not ret: + if "X"*3 in (self.build_id, other.build_id): + if self.build_id == "X"*3 and not other.build_id == "X"*3: + ret = -1 + + elif not self.build_id == "X"*3 and other.build_id == "X"*3: + ret = 1 + # XXX hack end + # Compare the build times if we have a rebuilt package. if not ret and self.build_time and other.build_time: ret = cmp(self.build_time, other.build_time) diff --git a/pakfire/packages/installed.py b/pakfire/packages/installed.py index 8e9c97922..22c2a9421 100644 --- a/pakfire/packages/installed.py +++ b/pakfire/packages/installed.py @@ -85,7 +85,12 @@ class DatabasePackage(Package): @property def build_time(self): - return self.metadata.get("build_time") + build_time = self.metadata.get("build_time", 0) + + if build_time == "X"*3: + build_time = 0 + + return int(build_time) @property def build_host(self):