diff --git a/osc/util/rpmquery.py b/osc/util/rpmquery.py index 534636a7..535cd37e 100644 --- a/osc/util/rpmquery.py +++ b/osc/util/rpmquery.py @@ -5,6 +5,10 @@ import os import re import struct from . import packagequery +from osc.util.helper import decode_it + +def cmp(a, b): + return (a > b) - (a < b) class RpmError(packagequery.PackageError): pass @@ -184,14 +188,14 @@ class RpmQuery(packagequery.PackageQuery, packagequery.PackageQueryResult): continue # RPMSENSE_SENSEMASK = 15 (see rpmlib.h) but ignore RPMSENSE_SERIAL (= 1 << 0) therefore use 14 if flags & 14: - name += ' ' + name += b' ' if flags & self.GREATER: - name += '>' + name += b'>' elif flags & self.LESS: - name += '<' + name += b'<' if flags & self.EQUAL: - name += '=' - name += ' %s' % ver + name += b'=' + name += b' %s' % ver res.append(name) return res @@ -288,7 +292,7 @@ class RpmQuery(packagequery.PackageQuery, packagequery.PackageQueryResult): arch = 'src' else: arch = self.arch() - return RpmQuery.filename(self.name(), None, self.version(), self.release(), arch) + return RpmQuery.filename(decode_it(self.name()), None, decode_it(self.version()), decode_it(self.release()), decode_it(arch)) @staticmethod def query(filename): @@ -318,6 +322,8 @@ class RpmQuery(packagequery.PackageQuery, packagequery.PackageQueryResult): if ver1 == ver2: return 0 res = 0 + ver1 = decode_it(ver1) + ver2 = decode_it(ver2) while res == 0: # remove all leading non alphanumeric or tilde chars ver1 = re.sub('^[^a-zA-Z0-9~]*', '', ver1)