1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

- get "osc build --prefer-pkgs ..." working with Arch

This commit is contained in:
Marcus Huewe 2014-04-03 17:41:41 +02:00
parent 0b7e49b648
commit d6e6c0538e
5 changed files with 19 additions and 11 deletions

View File

@ -316,6 +316,8 @@ def get_prefer_pkgs(dirs, wanted_arch, type):
suffix = '*.rpm'
if type == 'dsc':
suffix = '*.deb'
elif type == 'arch':
suffix = '*.pkg.tar.xz'
for dir in dirs:
# check for repodata

View File

@ -19,7 +19,8 @@ class ArchQuery(packagequery.PackageQuery):
#self.pkgsuffix = 'pkg.tar.gz'
self.pkgsuffix = 'arch'
def read(self, *extra_tags):
def read(self, all_tags=True, self_provides=True, *extra_tags):
# all_tags and *extra_tags are currently ignored
f = open(self.__path, 'rb')
#self.magic = f.read(5)
#if self.magic == '\375\067zXZ':
@ -32,6 +33,9 @@ class ArchQuery(packagequery.PackageQuery):
if not line[0] in self.fields:
self.fields[line[0]] = []
self.fields[line[0]].append(line[1])
if self_provides:
prv = '%s = %s' % (self.name(), self.fields['pkgver'][0])
self.fields.setdefault('provides', []).append(prv)
def vercmp(self, archq):
res = cmp(int(self.epoch()), int(archq.epoch()))

View File

@ -21,7 +21,7 @@ class DebQuery(packagequery.PackageQuery):
self.filename_suffix = 'deb'
self.fields = {}
def read(self, all_tags = False, *extra_tags):
def read(self, all_tags=False, self_provides=True, *extra_tags):
arfile = ar.Ar(fh = self.__file)
arfile.read()
debbin = arfile.get_file('debian-binary')
@ -42,9 +42,9 @@ class DebQuery(packagequery.PackageQuery):
control = tar.extractfile(name)
except KeyError:
raise DebError(self.__path, 'missing \'control\' file in control.tar.gz')
self.__parse_control(control, all_tags, *extra_tags)
self.__parse_control(control, all_tags, self_provides, *extra_tags)
def __parse_control(self, control, all_tags = False, *extra_tags):
def __parse_control(self, control, all_tags=False, self_provides=True, *extra_tags):
data = control.readline().strip()
while data:
field, val = re.split(':\s*', data.strip(), 1)
@ -71,8 +71,9 @@ 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 ]
# add self provides entry
self.fields['provides'].append('%s = %s' % (self.name(), '-'.join(versrel)))
if self_provides:
# add self provides entry
self.fields['provides'].append('%s = %s' % (self.name(), '-'.join(versrel)))
def vercmp(self, debq):
res = cmp(int(self.epoch()), int(debq.epoch()))

View File

@ -36,8 +36,8 @@ class PackageQueries(dict):
architecture = query.arch()
if (architecture in [self.wanted_architecture, 'noarch', 'all'] or
self.wanted_architecture in self.architectureMap.get(architecture,
if (architecture in [self.wanted_architecture, 'noarch', 'all', 'any']
or self.wanted_architecture in self.architectureMap.get(architecture,
[])):
current_query = self.get(name)
@ -87,7 +87,7 @@ class PackageQuery:
raise NotImplementedError
@staticmethod
def query(filename, all_tags = False, extra_rpmtags = (), extra_debtags = ()):
def query(filename, all_tags=False, extra_rpmtags=(), extra_debtags=(), self_provides=True):
f = open(filename, 'rb')
magic = f.read(7)
f.seek(0)
@ -109,7 +109,7 @@ class PackageQuery:
pkgquery = archquery.ArchQuery(f)
else:
raise PackageError(filename, 'unsupported package type. magic: \'%s\'' % magic)
pkgquery.read(all_tags, *extra_tags)
pkgquery.read(all_tags, self_provides, *extra_tags)
f.close()
return pkgquery

View File

@ -69,7 +69,8 @@ class RpmQuery(packagequery.PackageQuery):
self.filename_suffix = 'rpm'
self.header = None
def read(self, all_tags = False, *extra_tags):
def read(self, all_tags=False, self_provides=True, *extra_tags):
# self_provides is unused because a rpm always has a self provides
self.__read_lead()
data = self.__file.read(RpmHeaderEntry.ENTRY_SIZE)
hdrmgc, reserved, il, dl = struct.unpack('!I3i', data)