mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-12 16:56:15 +01:00
add obsoletes, conflicts, evr query methods
This commit is contained in:
parent
e1e2dd8676
commit
7acaba2d8a
@ -88,6 +88,12 @@ class ArchQuery(packagequery.PackageQuery):
|
||||
def requires(self):
|
||||
return self.fields['depend'] if 'depend' in self.fields else []
|
||||
|
||||
def conflicts(self):
|
||||
return self.fields['conflict'] if 'conflict' in self.fields else []
|
||||
|
||||
def obsoletes(self):
|
||||
return self.fields['replaces'] if 'replaces' in self.fields else []
|
||||
|
||||
def canonname(self):
|
||||
pkgver = self.fields['pkgver'][0] if 'pkgver' in self.fields else None
|
||||
return self.name() + '-' + pkgver + '-' + self.arch() + '.' + self.pkgsuffix
|
||||
|
@ -13,7 +13,7 @@ class DebError(packagequery.PackageError):
|
||||
class DebQuery(packagequery.PackageQuery):
|
||||
|
||||
default_tags = ('package', 'version', 'release', 'epoch', 'architecture', 'description',
|
||||
'provides', 'depends', 'pre_depends')
|
||||
'provides', 'depends', 'pre_depends', 'conflicts', 'breaks')
|
||||
|
||||
def __init__(self, fh):
|
||||
self.__file = fh
|
||||
@ -71,9 +71,11 @@ class DebQuery(packagequery.PackageQuery):
|
||||
self.fields['provides'] = [ i.strip() for i in re.split(',\s*', self.fields.get('provides', '')) if i ]
|
||||
self.fields['depends'] = [ i.strip() for i in re.split(',\s*', self.fields.get('depends', '')) if i ]
|
||||
self.fields['pre_depends'] = [ i.strip() for i in re.split(',\s*', self.fields.get('pre_depends', '')) if i ]
|
||||
self.fields['conflicts'] = [ i.strip() for i in re.split(',\s*', self.fields.get('conflicts', '')) if i ]
|
||||
self.fields['breaks'] = [ i.strip() for i in re.split(',\s*', self.fields.get('breaks', '')) if i ]
|
||||
if self_provides:
|
||||
# add self provides entry
|
||||
self.fields['provides'].append('%s = %s' % (self.name(), '-'.join(versrel)))
|
||||
self.fields['provides'].append('%s (= %s)' % (self.name(), '-'.join(versrel)))
|
||||
|
||||
def vercmp(self, debq):
|
||||
res = cmp(int(self.epoch()), int(debq.epoch()))
|
||||
@ -110,7 +112,13 @@ class DebQuery(packagequery.PackageQuery):
|
||||
return self.fields['provides']
|
||||
|
||||
def requires(self):
|
||||
return self.fields['depends']
|
||||
return self.fields['depends'] + self.fields['pre_depends']
|
||||
|
||||
def conflicts(self):
|
||||
return self.fields['conflicts'] + self.fields['breaks']
|
||||
|
||||
def obsoletes(self):
|
||||
return []
|
||||
|
||||
def gettag(self, num):
|
||||
return self.fields.get(num, None)
|
||||
|
@ -77,6 +77,12 @@ class PackageQuery:
|
||||
def requires(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def conflicts(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def obsoletes(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def gettag(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@ -86,6 +92,13 @@ class PackageQuery:
|
||||
def canonname(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def evr(self):
|
||||
evr = self.version() + "-" + self.release()
|
||||
epoch = self.epoch()
|
||||
if epoch is not None and epoch != 0:
|
||||
evr = epoch + ":" + evr
|
||||
return evr
|
||||
|
||||
@staticmethod
|
||||
def query(filename, all_tags=False, extra_rpmtags=(), extra_debtags=(), self_provides=True):
|
||||
f = open(filename, 'rb')
|
||||
|
@ -60,7 +60,9 @@ class RpmQuery(packagequery.PackageQuery):
|
||||
|
||||
default_tags = (1000, 1001, 1002, 1003, 1004, 1022, 1005, 1020,
|
||||
1047, 1112, 1113, # provides
|
||||
1049, 1048, 1050 # requires
|
||||
1049, 1048, 1050, # requires
|
||||
1054, 1053, 1055, # conflicts
|
||||
1090, 1114, 1115 # obsoletes
|
||||
)
|
||||
|
||||
def __init__(self, fh):
|
||||
@ -154,7 +156,10 @@ class RpmQuery(packagequery.PackageQuery):
|
||||
raise RpmHeaderError(self.__path, 'unsupported tag type \'%d\' (tag: \'%s\'' % (entry.type, entry.tag))
|
||||
|
||||
def __reqprov(self, tag, flags, version):
|
||||
pnames = self.header.gettag(tag).data
|
||||
pnames = self.header.gettag(tag)
|
||||
if not pnames:
|
||||
return []
|
||||
pnames = pnames.data
|
||||
pflags = self.header.gettag(flags).data
|
||||
pvers = self.header.gettag(version).data
|
||||
if not (pnames and pflags and pvers):
|
||||
@ -224,6 +229,12 @@ class RpmQuery(packagequery.PackageQuery):
|
||||
def requires(self):
|
||||
return self.__reqprov(1049, 1048, 1050)
|
||||
|
||||
def conflicts(self):
|
||||
return self.__reqprov(1054, 1053, 1055)
|
||||
|
||||
def obsoletes(self):
|
||||
return self.__reqprov(1090, 1114, 1115)
|
||||
|
||||
def is_src(self):
|
||||
# SOURCERPM = 1044
|
||||
return self.gettag(1044) is None
|
||||
|
Loading…
Reference in New Issue
Block a user