2020-02-18 22:47:52 +08:00
|
|
|
#!/usr/bin/python3
|
2015-08-14 05:47:59 +08:00
|
|
|
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import sys
|
2020-02-18 22:47:52 +08:00
|
|
|
import time
|
2018-11-16 08:32:25 +01:00
|
|
|
|
2022-02-18 10:16:17 +01:00
|
|
|
from urllib.error import HTTPError, URLError
|
2018-11-16 08:32:25 +01:00
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
import random
|
2015-08-21 21:10:06 +08:00
|
|
|
import re
|
2022-02-18 10:16:17 +01:00
|
|
|
from lxml import etree as ET
|
2015-08-14 05:47:59 +08:00
|
|
|
|
|
|
|
import osc.conf
|
|
|
|
import osc.core
|
2018-01-17 18:10:01 -06:00
|
|
|
from osclib.core import devel_project_get
|
2018-08-17 22:23:09 -05:00
|
|
|
from osclib.core import project_pseudometa_package
|
2015-08-14 05:47:59 +08:00
|
|
|
|
2020-02-18 22:47:52 +08:00
|
|
|
OPENSUSE = 'openSUSE:Leap:15.2'
|
|
|
|
OPENSUSE_PREVERSION = 'openSUSE:Leap:15.1'
|
|
|
|
OPENSUSE_RELEASED_VERSION = ['openSUSE:Leap:15.0', 'openSUSE:Leap:15.1']
|
2024-05-07 17:55:17 +02:00
|
|
|
FCC = f'{OPENSUSE}:FactoryCandidates'
|
2015-08-14 05:47:59 +08:00
|
|
|
|
|
|
|
makeurl = osc.core.makeurl
|
|
|
|
http_GET = osc.core.http_GET
|
2015-08-17 20:28:15 +08:00
|
|
|
http_POST = osc.core.http_POST
|
2016-08-05 15:47:52 +08:00
|
|
|
http_PUT = osc.core.http_PUT
|
2015-08-14 05:47:59 +08:00
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2016-08-05 15:47:52 +08:00
|
|
|
class FccFreezer(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.factory = 'openSUSE:Factory'
|
|
|
|
self.apiurl = osc.conf.config['apiurl']
|
|
|
|
self.debug = osc.conf.config['debug']
|
|
|
|
|
|
|
|
def list_packages(self, project):
|
|
|
|
url = makeurl(self.apiurl, ['source', project])
|
|
|
|
pkglist = []
|
|
|
|
|
|
|
|
root = ET.parse(http_GET(url)).getroot()
|
|
|
|
xmllines = root.findall("./entry")
|
|
|
|
for pkg in xmllines:
|
|
|
|
pkglist.append(pkg.attrib['name'])
|
|
|
|
|
|
|
|
return set(pkglist)
|
|
|
|
|
2017-02-15 19:08:46 +08:00
|
|
|
def check_one_source(self, flink, si, pkglist, pkglist_prever):
|
2017-02-14 21:03:03 +08:00
|
|
|
"""
|
|
|
|
Insert package information to the temporary frozenlinks.
|
|
|
|
Return package name if the package can not fit the condition
|
|
|
|
add to the frozenlinks, can be the ignored package.
|
|
|
|
"""
|
2016-08-05 15:47:52 +08:00
|
|
|
package = si.get('package')
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.debug(f"Processing {package}")
|
2016-08-05 15:47:52 +08:00
|
|
|
|
|
|
|
# If the package is an internal one (e.g _product)
|
2017-11-23 17:08:02 +08:00
|
|
|
if package.startswith('_') or package.startswith('Test-DVD') or package.startswith('000'):
|
2016-08-05 15:47:52 +08:00
|
|
|
return None
|
|
|
|
|
2018-01-12 18:51:12 +08:00
|
|
|
# filter out multibuild package
|
|
|
|
for originpackage in si.findall('originpackage'):
|
|
|
|
if ':' in package and package.split(':')[0] == originpackage.text:
|
|
|
|
return package
|
|
|
|
|
2016-08-05 15:47:52 +08:00
|
|
|
for linked in si.findall('linked'):
|
|
|
|
if linked.get('project') == self.factory:
|
2017-02-15 19:08:46 +08:00
|
|
|
if linked.get('package') in pkglist or linked.get('package') in pkglist_prever:
|
2016-08-05 15:47:52 +08:00
|
|
|
return package
|
|
|
|
url = makeurl(self.apiurl, ['source', self.factory, package], {'view': 'info', 'nofilename': '1'})
|
|
|
|
# print(package, linked.get('package'), linked.get('project'))
|
|
|
|
f = http_GET(url)
|
|
|
|
proot = ET.parse(f).getroot()
|
|
|
|
lsrcmd5 = proot.get('lsrcmd5')
|
|
|
|
if lsrcmd5 is None:
|
2024-05-07 17:55:17 +02:00
|
|
|
raise Exception(f"{self.factory}/{package} is not a link but we expected one")
|
2016-08-05 15:47:52 +08:00
|
|
|
ET.SubElement(flink, 'package', {'name': package, 'srcmd5': lsrcmd5, 'vrev': si.get('vrev')})
|
2017-02-14 21:03:03 +08:00
|
|
|
return None
|
2016-08-05 15:47:52 +08:00
|
|
|
|
2017-02-15 19:08:46 +08:00
|
|
|
if package in pkglist or package in pkglist_prever:
|
2016-08-05 15:47:52 +08:00
|
|
|
return package
|
|
|
|
|
|
|
|
if package in ['rpmlint-mini-AGGR']:
|
2017-02-14 21:03:03 +08:00
|
|
|
# we should not freeze aggregates
|
|
|
|
return None
|
2016-08-05 15:47:52 +08:00
|
|
|
|
|
|
|
ET.SubElement(flink, 'package', {'name': package, 'srcmd5': si.get('srcmd5'), 'vrev': si.get('vrev')})
|
2017-02-14 21:03:03 +08:00
|
|
|
return None
|
2016-08-05 15:47:52 +08:00
|
|
|
|
2017-02-14 21:03:03 +08:00
|
|
|
def receive_sources(self, flink):
|
|
|
|
ignored_sources = []
|
2016-08-05 15:47:52 +08:00
|
|
|
pkglist = self.list_packages(OPENSUSE)
|
2017-02-15 19:08:46 +08:00
|
|
|
# we also don't want the package is exist in the previous version
|
|
|
|
pkglist_prever = self.list_packages(OPENSUSE_PREVERSION)
|
2016-08-05 15:47:52 +08:00
|
|
|
|
|
|
|
url = makeurl(self.apiurl, ['source', self.factory], {'view': 'info', 'nofilename': '1'})
|
|
|
|
f = http_GET(url)
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
|
|
|
|
for si in root.findall('sourceinfo'):
|
2017-02-15 19:08:46 +08:00
|
|
|
package = self.check_one_source(flink, si, pkglist, pkglist_prever)
|
2017-02-14 21:03:03 +08:00
|
|
|
if package is not None:
|
|
|
|
ignored_sources.append(str(package))
|
|
|
|
return ignored_sources
|
2016-08-05 15:47:52 +08:00
|
|
|
|
|
|
|
def freeze(self):
|
|
|
|
"""Main method"""
|
|
|
|
flink = ET.Element('frozenlinks')
|
|
|
|
|
|
|
|
fl = ET.SubElement(flink, 'frozenlink', {'project': self.factory})
|
2017-02-14 21:03:03 +08:00
|
|
|
ignored_sources = self.receive_sources(fl)
|
|
|
|
if self.debug:
|
|
|
|
logging.debug("Dump ignored source")
|
|
|
|
for source in ignored_sources:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.debug(f"Ignored source: {source}")
|
2016-08-05 15:47:52 +08:00
|
|
|
|
|
|
|
url = makeurl(self.apiurl, ['source', FCC, '_project', '_frozenlinks'], {'meta': '1'})
|
2022-02-18 13:17:02 +01:00
|
|
|
link = ET.tostring(flink)
|
2016-08-05 15:47:52 +08:00
|
|
|
try:
|
2022-02-18 13:17:02 +01:00
|
|
|
http_PUT(url, data=link)
|
2018-11-16 08:32:25 +01:00
|
|
|
except HTTPError as e:
|
2016-08-05 15:47:52 +08:00
|
|
|
raise e
|
2015-08-14 05:47:59 +08:00
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
class FccSubmitter(object):
|
|
|
|
def __init__(self, from_prj, to_prj, submit_limit):
|
|
|
|
self.from_prj = from_prj
|
|
|
|
self.to_prj = to_prj
|
2015-08-14 13:53:11 +08:00
|
|
|
self.factory = 'openSUSE:Factory'
|
|
|
|
self.submit_limit = int(submit_limit)
|
2015-08-14 05:47:59 +08:00
|
|
|
self.apiurl = osc.conf.config['apiurl']
|
|
|
|
self.debug = osc.conf.config['debug']
|
2015-08-19 17:58:33 +08:00
|
|
|
self.sle_base_prjs = [
|
2022-02-18 16:02:08 +01:00
|
|
|
'SUSE:SLE-15-SP2:GA',
|
|
|
|
'SUSE:SLE-15-SP1:Update',
|
|
|
|
'SUSE:SLE-15-SP1:GA',
|
|
|
|
'SUSE:SLE-15:Update',
|
|
|
|
'SUSE:SLE-15:GA',
|
|
|
|
'SUSE:SLE-12-SP4:Update',
|
|
|
|
'SUSE:SLE-12-SP4:GA',
|
|
|
|
'SUSE:SLE-12-SP3:Update',
|
|
|
|
'SUSE:SLE-12-SP3:GA',
|
|
|
|
'SUSE:SLE-12-SP2:Update',
|
|
|
|
'SUSE:SLE-12-SP2:GA',
|
|
|
|
'SUSE:SLE-12-SP1:Update',
|
|
|
|
'SUSE:SLE-12-SP1:GA',
|
|
|
|
'SUSE:SLE-12:Update',
|
|
|
|
'SUSE:SLE-12:GA']
|
2015-08-18 19:18:56 +08:00
|
|
|
# the skip list against devel project
|
2016-08-12 15:21:48 +08:00
|
|
|
self.skip_devel_project_list = [
|
2022-02-18 16:02:08 +01:00
|
|
|
'mobile:synchronization:FACTORY']
|
2016-08-05 15:47:52 +08:00
|
|
|
# put the except packages from skip_devel_project_list, use regex in this list, eg. "^golang-x-(\w+)", "^nodejs$"
|
|
|
|
self.except_pkgs_list = []
|
2015-08-14 05:47:59 +08:00
|
|
|
|
|
|
|
def get_source_packages(self, project, expand=False):
|
|
|
|
"""Return the list of packages in a project."""
|
|
|
|
query = {'expand': 1} if expand else {}
|
2017-10-20 08:54:37 +02:00
|
|
|
root = ET.parse(http_GET(makeurl(self.apiurl, ['source', project],
|
2015-08-14 05:47:59 +08:00
|
|
|
query=query))).getroot()
|
|
|
|
packages = [i.get('name') for i in root.findall('entry')]
|
2017-10-17 09:10:17 +02:00
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
return packages
|
|
|
|
|
|
|
|
def get_request_list(self, package):
|
2018-01-23 20:19:41 +08:00
|
|
|
return osc.core.get_request_list(self.apiurl, self.to_prj, package, req_state=('new', 'review', 'declined', 'revoked'))
|
2015-08-14 05:47:59 +08:00
|
|
|
|
2015-08-19 17:58:33 +08:00
|
|
|
def get_link(self, project, package):
|
|
|
|
try:
|
2017-10-20 08:54:37 +02:00
|
|
|
link = http_GET(makeurl(self.apiurl, ['source', project, package, '_link'])).read()
|
2018-11-16 08:32:25 +01:00
|
|
|
except (HTTPError, URLError):
|
2015-08-19 17:58:33 +08:00
|
|
|
return None
|
|
|
|
return ET.fromstring(link)
|
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
def get_build_succeeded_packages(self, project):
|
|
|
|
"""Get the build succeeded packages from `from_prj` project.
|
|
|
|
"""
|
|
|
|
|
|
|
|
f = osc.core.show_prj_results_meta(self.apiurl, project)
|
2018-08-16 00:26:53 -05:00
|
|
|
root = ET.fromstringlist(f)
|
2021-09-21 14:30:07 +02:00
|
|
|
# print ET.dump(root)
|
2015-08-14 05:47:59 +08:00
|
|
|
|
2017-12-26 19:23:49 +08:00
|
|
|
failed_multibuild_pacs = []
|
2015-08-14 05:47:59 +08:00
|
|
|
pacs = []
|
|
|
|
for node in root.findall('result'):
|
2018-01-12 17:29:29 +08:00
|
|
|
if node.get('repository') == 'standard' and node.get('arch') == 'x86_64':
|
2015-08-14 05:47:59 +08:00
|
|
|
for pacnode in node.findall('status'):
|
2017-12-26 19:23:49 +08:00
|
|
|
if ':' in pacnode.get('package'):
|
|
|
|
mainpac = pacnode.get('package').split(':')[0]
|
|
|
|
if pacnode.get('code') not in ['succeeded', 'excluded']:
|
|
|
|
failed_multibuild_pacs.append(pacnode.get('package'))
|
|
|
|
if mainpac not in failed_multibuild_pacs:
|
|
|
|
failed_multibuild_pacs.append(mainpac)
|
|
|
|
if mainpac in pacs:
|
|
|
|
pacs.remove(mainpac)
|
|
|
|
else:
|
|
|
|
if mainpac in failed_multibuild_pacs:
|
|
|
|
failed_multibuild_pacs.append(pacnode.get('package'))
|
|
|
|
elif mainpac not in pacs:
|
|
|
|
pacs.append(mainpac)
|
|
|
|
continue
|
2015-08-14 05:47:59 +08:00
|
|
|
if pacnode.get('code') == 'succeeded':
|
|
|
|
pacs.append(pacnode.get('package'))
|
|
|
|
else:
|
2018-01-12 17:29:29 +08:00
|
|
|
logging.error("Can not find standard/x86_64 results")
|
2015-08-14 05:47:59 +08:00
|
|
|
|
|
|
|
return pacs
|
|
|
|
|
2015-08-18 21:04:38 +08:00
|
|
|
def is_new_package(self, tgt_project, tgt_package):
|
|
|
|
try:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.debug(f"Gathering package_meta {tgt_project}/{tgt_package}")
|
2015-08-18 21:04:38 +08:00
|
|
|
osc.core.show_package_meta(self.apiurl, tgt_project, tgt_package)
|
2018-11-16 08:32:25 +01:00
|
|
|
except (HTTPError, URLError):
|
2015-08-18 21:04:38 +08:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
def create_submitrequest(self, package):
|
|
|
|
"""Create a submit request using the osc.commandline.Osc class."""
|
2022-02-18 16:39:16 +01:00
|
|
|
src_project = self.factory # submit from Factory only
|
2015-08-14 05:47:59 +08:00
|
|
|
dst_project = self.to_prj
|
2015-08-17 20:28:15 +08:00
|
|
|
|
2024-05-07 17:55:17 +02:00
|
|
|
msg = f'Automatic request from {src_project} by F-C-C Submitter. Please review this change and decline it if Leap do not need it.'
|
2015-08-14 05:47:59 +08:00
|
|
|
res = osc.core.create_submit_request(self.apiurl,
|
|
|
|
src_project,
|
|
|
|
package,
|
|
|
|
dst_project,
|
|
|
|
package,
|
|
|
|
message=msg)
|
|
|
|
return res
|
|
|
|
|
2015-08-14 06:09:08 +08:00
|
|
|
def check_multiple_specfiles(self, project, package):
|
2016-08-11 18:40:41 +08:00
|
|
|
try:
|
2022-02-18 17:23:02 +01:00
|
|
|
url = makeurl(self.apiurl, ['source', project, package], {'expand': '1'})
|
2018-11-16 08:32:25 +01:00
|
|
|
except HTTPError as e:
|
2016-08-11 18:40:41 +08:00
|
|
|
if e.code == 404:
|
|
|
|
return None
|
|
|
|
raise e
|
2015-08-14 06:09:08 +08:00
|
|
|
root = ET.fromstring(http_GET(url).read())
|
2017-03-10 18:39:43 +08:00
|
|
|
data = {}
|
2016-08-08 16:19:50 +08:00
|
|
|
linkinfo = root.find('linkinfo')
|
2018-01-16 04:31:57 +08:00
|
|
|
if linkinfo is not None:
|
2017-03-10 18:39:43 +08:00
|
|
|
data['linkinfo'] = linkinfo.attrib['package']
|
2017-03-15 20:29:54 +08:00
|
|
|
else:
|
|
|
|
data['linkinfo'] = None
|
2017-03-10 18:39:43 +08:00
|
|
|
|
2022-02-18 17:44:32 +01:00
|
|
|
files = [entry.get('name').replace('.spec', '')
|
|
|
|
for entry in root.findall('entry') if entry.get('name').endswith('.spec')]
|
2017-03-10 18:39:43 +08:00
|
|
|
data['specs'] = files
|
|
|
|
|
|
|
|
if len(files) > 1:
|
|
|
|
return data
|
2016-08-08 16:19:50 +08:00
|
|
|
else:
|
2016-08-11 18:40:41 +08:00
|
|
|
return False
|
2015-08-14 06:09:08 +08:00
|
|
|
|
2015-08-19 17:58:33 +08:00
|
|
|
def is_sle_base_pkgs(self, package):
|
|
|
|
link = self.get_link(self.to_prj, package)
|
|
|
|
if link is None or link.get('project') not in self.sle_base_prjs:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.debug(f"{package} not from SLE base")
|
2015-08-19 17:58:33 +08:00
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2016-08-05 15:47:52 +08:00
|
|
|
def list_pkgs(self):
|
|
|
|
"""List build succeeded packages"""
|
|
|
|
succeeded_packages = []
|
|
|
|
succeeded_packages = self.get_build_succeeded_packages(self.from_prj)
|
|
|
|
if not len(succeeded_packages) > 0:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'No build succeeded package in {self.from_prj}')
|
2016-08-05 15:47:52 +08:00
|
|
|
return
|
|
|
|
|
2019-04-20 21:16:50 +02:00
|
|
|
print('Build succeeded packages:')
|
|
|
|
print('-------------------------------------')
|
2016-08-05 15:47:52 +08:00
|
|
|
for pkg in succeeded_packages:
|
2019-04-20 21:16:50 +02:00
|
|
|
print(pkg)
|
2016-08-05 15:47:52 +08:00
|
|
|
|
2019-04-20 21:16:50 +02:00
|
|
|
print('-------------------------------------')
|
2024-05-07 17:55:17 +02:00
|
|
|
print(f"Found {len(succeeded_packages)} build succeded packages")
|
2016-08-05 15:47:52 +08:00
|
|
|
|
2016-08-12 15:06:43 +08:00
|
|
|
def get_deleted_packages(self, project):
|
|
|
|
query = 'states=accepted&types=delete&project={}&view=collection'
|
|
|
|
query = query.format(project)
|
|
|
|
url = makeurl(self.apiurl, ['request'], query)
|
|
|
|
f = http_GET(url)
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
|
|
|
|
pkgs = []
|
|
|
|
for sr in root.findall('request'):
|
|
|
|
tgt_package = sr.find('action').find('target').get('package')
|
|
|
|
pkgs.append(tgt_package)
|
|
|
|
|
|
|
|
return pkgs
|
|
|
|
|
2017-02-16 18:17:11 +08:00
|
|
|
def load_skip_pkgs_list(self, project, package):
|
2024-05-07 17:55:17 +02:00
|
|
|
url = makeurl(self.apiurl, ['source', project, package, 'fcc_skip_pkgs?expand=1'])
|
2017-02-16 18:17:11 +08:00
|
|
|
try:
|
|
|
|
return http_GET(url).read()
|
2018-11-16 08:32:25 +01:00
|
|
|
except HTTPError:
|
2017-02-16 18:17:11 +08:00
|
|
|
return ''
|
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
def crawl(self):
|
|
|
|
"""Main method"""
|
|
|
|
succeeded_packages = []
|
|
|
|
succeeded_packages = self.get_build_succeeded_packages(self.from_prj)
|
|
|
|
if not len(succeeded_packages) > 0:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'No build succeeded package in {self.from_prj}')
|
2015-08-14 05:47:59 +08:00
|
|
|
return
|
|
|
|
|
|
|
|
# randomize the list
|
|
|
|
random.shuffle(succeeded_packages)
|
|
|
|
# get souce packages from target
|
|
|
|
target_packages = self.get_source_packages(self.to_prj)
|
2016-08-12 15:06:43 +08:00
|
|
|
deleted_packages = self.get_deleted_packages(self.to_prj)
|
2018-12-05 20:30:50 +08:00
|
|
|
if self.to_prj.startswith("openSUSE:"):
|
2020-02-18 22:47:52 +08:00
|
|
|
for prd in OPENSUSE_RELEASED_VERSION:
|
|
|
|
deleted_packages = deleted_packages + self.get_deleted_packages(prd)
|
2015-08-14 13:53:11 +08:00
|
|
|
|
2018-08-17 22:23:09 -05:00
|
|
|
pseudometa_project, pseudometa_package = project_pseudometa_package(self.apiurl, 'openSUSE:Factory')
|
|
|
|
skip_pkgs_list = self.load_skip_pkgs_list(pseudometa_project, pseudometa_package).splitlines()
|
2017-02-16 18:17:11 +08:00
|
|
|
|
2022-02-18 16:39:16 +01:00
|
|
|
ms_packages = [] # collect multi specs packages
|
2015-08-18 19:34:29 +08:00
|
|
|
|
2015-08-14 13:53:11 +08:00
|
|
|
for i in range(0, min(int(self.submit_limit), len(succeeded_packages))):
|
2015-08-14 05:47:59 +08:00
|
|
|
package = succeeded_packages[i]
|
2017-03-10 18:39:43 +08:00
|
|
|
submit_ok = True
|
2015-08-19 17:58:33 +08:00
|
|
|
|
2016-08-12 15:06:43 +08:00
|
|
|
if package in deleted_packages:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'{package} has been dropped from {self.to_prj}, ignore it!')
|
2017-03-10 18:39:43 +08:00
|
|
|
submit_ok = False
|
2016-08-12 15:06:43 +08:00
|
|
|
|
2015-08-19 17:58:33 +08:00
|
|
|
if self.is_sle_base_pkgs(package) is True:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'{package} origin from SLE base, skip for now!')
|
2017-03-10 18:39:43 +08:00
|
|
|
submit_ok = False
|
2015-08-19 17:58:33 +08:00
|
|
|
|
2015-08-24 19:35:55 +08:00
|
|
|
# make sure it is new package
|
|
|
|
new_pkg = self.is_new_package(self.to_prj, package)
|
|
|
|
if new_pkg is not True:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'{package} is not a new package, do not submit.')
|
2017-03-10 18:39:43 +08:00
|
|
|
submit_ok = False
|
2015-08-24 19:35:55 +08:00
|
|
|
|
2015-08-14 13:53:11 +08:00
|
|
|
multi_specs = self.check_multiple_specfiles(self.factory, package)
|
2016-08-11 18:40:41 +08:00
|
|
|
if multi_specs is None:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'{package} does not exist in openSUSE:Factory')
|
2017-03-10 18:39:43 +08:00
|
|
|
submit_ok = False
|
2016-08-11 18:40:41 +08:00
|
|
|
|
2016-08-08 16:19:50 +08:00
|
|
|
if multi_specs:
|
2017-03-10 18:39:43 +08:00
|
|
|
if multi_specs['linkinfo']:
|
2022-02-18 17:44:32 +01:00
|
|
|
logging.info('%s in %s is sub-package of %s, skip it!' %
|
|
|
|
(package, 'openSUSE:Factory', multi_specs['linkinfo']))
|
2017-03-10 18:39:43 +08:00
|
|
|
ms_packages.append(package)
|
|
|
|
submit_ok = False
|
|
|
|
|
|
|
|
for spec in multi_specs['specs']:
|
|
|
|
if spec not in succeeded_packages:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'{spec} is sub-pacakge of {package} but build failed, skip it!')
|
2017-03-10 18:39:43 +08:00
|
|
|
submit_ok = False
|
|
|
|
|
|
|
|
if not submit_ok:
|
2015-08-14 06:09:08 +08:00
|
|
|
continue
|
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
# make sure the package non-exist in target yet ie. expand=False
|
|
|
|
if package not in target_packages:
|
|
|
|
# make sure there is no request against same package
|
|
|
|
request = self.get_request_list(package)
|
|
|
|
if request:
|
2022-02-18 17:44:32 +01:00
|
|
|
logging.debug("There is a request to %s / %s already or it has been declined/revoked, skip!" %
|
|
|
|
(package, self.to_prj))
|
2015-08-14 05:47:59 +08:00
|
|
|
else:
|
2019-11-27 11:08:06 +01:00
|
|
|
logging.info("%d - Preparing submit %s to %s" % (i, package, self.to_prj))
|
2015-08-18 19:18:56 +08:00
|
|
|
# get devel project
|
2018-01-17 18:10:01 -06:00
|
|
|
devel_prj, devel_pkg = devel_project_get(self.apiurl, self.factory, package)
|
2015-08-18 19:18:56 +08:00
|
|
|
# check devel project does not in the skip list
|
|
|
|
if devel_prj in self.skip_devel_project_list:
|
2015-08-21 21:10:06 +08:00
|
|
|
# check the except packages list
|
2015-08-22 03:51:17 +08:00
|
|
|
match = None
|
2015-08-21 21:10:06 +08:00
|
|
|
for elem in self.except_pkgs_list:
|
|
|
|
m = re.search(elem, package)
|
|
|
|
if m is not None:
|
|
|
|
match = True
|
|
|
|
|
|
|
|
if match is not True:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'{devel_prj}/{package} is in the skip list, do not submit.')
|
2015-08-21 21:10:06 +08:00
|
|
|
continue
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
2015-08-18 21:36:10 +08:00
|
|
|
# check package does not in the skip list
|
2015-08-22 03:51:17 +08:00
|
|
|
match = None
|
2017-02-16 18:17:11 +08:00
|
|
|
for elem in skip_pkgs_list:
|
2020-02-18 22:47:52 +08:00
|
|
|
m = re.search(str(elem), package)
|
2015-08-21 21:10:06 +08:00
|
|
|
if m is not None:
|
|
|
|
match = True
|
|
|
|
|
|
|
|
if match is True:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'{package} is in the skip list, do not submit.')
|
2015-08-18 21:36:10 +08:00
|
|
|
continue
|
2015-08-21 21:10:06 +08:00
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
res = self.create_submitrequest(package)
|
2015-08-18 18:57:49 +08:00
|
|
|
if res and res is not None:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.info(f'Created request {res} for {package}')
|
2015-08-14 05:47:59 +08:00
|
|
|
else:
|
|
|
|
logging.error('Error occurred when creating submit request')
|
|
|
|
else:
|
2024-05-07 17:55:17 +02:00
|
|
|
logging.debug(f'{package} is exist in {self.to_prj}, skip!')
|
2020-02-18 22:47:52 +08:00
|
|
|
time.sleep(5)
|
2015-08-14 05:47:59 +08:00
|
|
|
|
2015-08-18 19:34:29 +08:00
|
|
|
# dump multi specs packages
|
2016-08-08 16:19:50 +08:00
|
|
|
print("Multi-specfile packages:")
|
2015-08-18 19:34:29 +08:00
|
|
|
if ms_packages:
|
|
|
|
for pkg in ms_packages:
|
2019-04-20 21:16:50 +02:00
|
|
|
print(pkg)
|
2015-08-18 19:34:29 +08:00
|
|
|
else:
|
2019-04-20 21:16:50 +02:00
|
|
|
print('None')
|
2015-08-18 19:34:29 +08:00
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
|
|
|
|
def main(args):
|
|
|
|
# Configure OSC
|
|
|
|
osc.conf.get_config(override_apiurl=args.apiurl)
|
|
|
|
osc.conf.config['debug'] = args.debug
|
|
|
|
|
2016-08-05 15:47:52 +08:00
|
|
|
if args.freeze:
|
2024-05-07 17:55:17 +02:00
|
|
|
print(f'freezing {FCC}')
|
2016-08-05 15:47:52 +08:00
|
|
|
freezer = FccFreezer()
|
|
|
|
freezer.freeze()
|
|
|
|
else:
|
|
|
|
uc = FccSubmitter(args.from_prj, args.to_prj, args.submit_limit)
|
|
|
|
if args.list_packages:
|
|
|
|
uc.list_pkgs()
|
|
|
|
else:
|
|
|
|
uc.crawl()
|
2015-08-14 05:47:59 +08:00
|
|
|
|
2022-02-18 17:11:46 +01:00
|
|
|
|
2015-08-14 05:47:59 +08:00
|
|
|
if __name__ == '__main__':
|
2018-01-12 17:29:29 +08:00
|
|
|
description = 'Create SR from FactoryCandidates to '\
|
2017-02-14 21:03:03 +08:00
|
|
|
'openSUSE Leap project for new build succeded packages.'
|
2015-08-14 05:47:59 +08:00
|
|
|
parser = argparse.ArgumentParser(description=description)
|
|
|
|
parser.add_argument('-A', '--apiurl', metavar='URL', help='API URL')
|
|
|
|
parser.add_argument('-d', '--debug', action='store_true',
|
|
|
|
help='print info useful for debuging')
|
|
|
|
parser.add_argument('-f', '--from', dest='from_prj', metavar='PROJECT',
|
2024-05-07 17:55:17 +02:00
|
|
|
help=f'project where to check (default: {FCC})',
|
2015-08-14 05:47:59 +08:00
|
|
|
default=FCC)
|
|
|
|
parser.add_argument('-t', '--to', dest='to_prj', metavar='PROJECT',
|
2024-05-07 17:55:17 +02:00
|
|
|
help=f'project where to submit the packages (default: {OPENSUSE})',
|
2015-08-14 05:47:59 +08:00
|
|
|
default=OPENSUSE)
|
2016-08-05 15:47:52 +08:00
|
|
|
parser.add_argument('-r', '--freeze', dest='freeze', action='store_true', help='rebase FCC project')
|
|
|
|
parser.add_argument('-s', '--list', dest='list_packages', action='store_true', help='list build succeeded packages')
|
2022-02-18 17:44:32 +01:00
|
|
|
parser.add_argument('-l', '--limit', dest='submit_limit', metavar='NUMBERS',
|
|
|
|
help='limit numbers packages to submit (default: 100)', default=100)
|
2015-08-14 05:47:59 +08:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Set logging configuration
|
|
|
|
logging.basicConfig(level=logging.DEBUG if args.debug
|
|
|
|
else logging.INFO)
|
|
|
|
|
|
|
|
sys.exit(main(args))
|