2017-09-25 16:21:40 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2018-04-18 09:15:54 +02:00
|
|
|
import re
|
2018-04-18 14:53:31 +02:00
|
|
|
from collections import namedtuple
|
|
|
|
import osc.core
|
2019-09-04 13:00:41 +02:00
|
|
|
from oqamaint.update import Update
|
2022-02-18 10:16:17 +01:00
|
|
|
from lxml import etree as ET
|
2018-04-18 14:53:31 +02:00
|
|
|
|
|
|
|
Package = namedtuple('Package', ('name', 'version', 'release'))
|
2017-09-25 16:21:40 +02:00
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2017-09-25 16:21:40 +02:00
|
|
|
class openSUSEUpdate(Update):
|
|
|
|
|
|
|
|
repo_prefix = 'http://download.opensuse.org/repositories'
|
|
|
|
maintenance_project = 'openSUSE:Maintenance'
|
|
|
|
|
2018-04-18 14:53:31 +02:00
|
|
|
def package_details(self, prj, repo, arch, binary):
|
|
|
|
url = osc.core.makeurl(
|
|
|
|
self.apiurl,
|
|
|
|
('build', prj, repo, arch, '_repository', binary),
|
|
|
|
query={'view': 'fileinfo'})
|
|
|
|
|
|
|
|
root = ET.parse(osc.core.http_GET(url)).getroot()
|
|
|
|
return Package(root.find('.//name').text,
|
|
|
|
root.find('.//version').text,
|
|
|
|
root.find('.//release').text)
|
|
|
|
|
|
|
|
# list all packages released for an incident
|
|
|
|
def packages(self, src_prj, dst_prj):
|
|
|
|
packages = dict()
|
|
|
|
repo = dst_prj.replace(':', '_')
|
|
|
|
# patchinfo collects the binaries and is build for an
|
|
|
|
# unpredictable architecture so we need iterate over all
|
|
|
|
url = osc.core.makeurl(self.apiurl, ('build', src_prj, repo))
|
|
|
|
root = ET.parse(osc.core.http_GET(url)).getroot()
|
|
|
|
for arch in [n.attrib['name'] for n in root.findall('entry')]:
|
|
|
|
query = {'nosource': 1}
|
|
|
|
url = osc.core.makeurl(
|
|
|
|
self.apiurl,
|
|
|
|
('build', src_prj, repo, arch, '_repository'),
|
|
|
|
query=query)
|
|
|
|
|
|
|
|
root = ET.parse(osc.core.http_GET(url)).getroot()
|
|
|
|
|
|
|
|
for binary in root.findall('binary'):
|
|
|
|
b = binary.attrib['filename']
|
|
|
|
if b.endswith('.rpm'):
|
|
|
|
p = self.package_details(src_prj, repo, arch, b)
|
|
|
|
packages[p.name] = p
|
|
|
|
|
|
|
|
return packages
|
|
|
|
|
|
|
|
def settings(self, src_prj, dst_prj):
|
2018-04-18 09:15:54 +02:00
|
|
|
# strip the architecture for openSUSE - we do them all in one
|
|
|
|
dst_prj = re.sub(r':x86_64$', '', dst_prj)
|
2018-04-18 14:53:31 +02:00
|
|
|
settings = super(openSUSEUpdate, self).settings(src_prj, dst_prj)
|
2017-09-25 16:21:40 +02:00
|
|
|
settings = settings[0]
|
|
|
|
|
|
|
|
# openSUSE:Maintenance key
|
|
|
|
settings['IMPORT_GPG_KEYS'] = 'gpg-pubkey-b3fd7e48-5549fd0f'
|
|
|
|
settings['ZYPPER_ADD_REPO_PREFIX'] = 'incident'
|
|
|
|
|
2018-04-18 14:53:31 +02:00
|
|
|
packages = self.packages(src_prj, dst_prj)
|
|
|
|
settings['INSTALL_PACKAGES'] = ' '.join(packages.keys())
|
|
|
|
settings['VERIFY_PACKAGE_VERSIONS'] = ' '.join(
|
|
|
|
['{} {}-{}'.format(p.name, p.version, p.release) for p in packages.values()])
|
2017-09-25 16:21:40 +02:00
|
|
|
|
|
|
|
return [settings]
|