Merge pull request #214 from aplanas/master
Implement the openSUSE:XX.X:Devel workflow.
This commit is contained in:
commit
6740403295
@ -343,6 +343,7 @@ def _check_repo_group(self, id_, requests):
|
|||||||
msg = 'Builds for repo %s' % rq.goodrepo
|
msg = 'Builds for repo %s' % rq.goodrepo
|
||||||
print 'ACCEPTED', msg
|
print 'ACCEPTED', msg
|
||||||
self.checkrepo.change_review_state(rq.request_id, 'accepted', message=msg)
|
self.checkrepo.change_review_state(rq.request_id, 'accepted', message=msg)
|
||||||
|
self.checkrepo.remove_link_if_shadow_devel(rq)
|
||||||
rq.updated = True
|
rq.updated = True
|
||||||
updated[rq.request_id] = 1
|
updated[rq.request_id] = 1
|
||||||
|
|
||||||
@ -389,6 +390,8 @@ def do_check_repo(self, subcmd, opts, *args):
|
|||||||
msg = 'skip review'
|
msg = 'skip review'
|
||||||
print 'ACCEPTED', msg
|
print 'ACCEPTED', msg
|
||||||
self.checkrepo.change_review_state(id_, 'accepted', message=msg)
|
self.checkrepo.change_review_state(id_, 'accepted', message=msg)
|
||||||
|
_request = self.checkrepo.get_request(id_, internal=True)
|
||||||
|
self.checkrepo.remove_link_if_shadow_devel(_request)
|
||||||
return
|
return
|
||||||
|
|
||||||
prjs = [arg for arg in args if not arg.isdigit()]
|
prjs = [arg for arg in args if not arg.isdigit()]
|
||||||
|
@ -17,9 +17,13 @@ from xml.etree import cElementTree as ET
|
|||||||
from osc.core import checkout_package
|
from osc.core import checkout_package
|
||||||
from osc.core import http_GET
|
from osc.core import http_GET
|
||||||
from osc.core import http_POST
|
from osc.core import http_POST
|
||||||
|
# from osc.core import link_pac
|
||||||
from osc.core import makeurl
|
from osc.core import makeurl
|
||||||
|
# from osc.core import show_upstream_rev_vrev
|
||||||
from osc import cmdln
|
from osc import cmdln
|
||||||
|
|
||||||
|
from osclib.stagingapi import StagingAPI
|
||||||
|
|
||||||
|
|
||||||
# For a description of this decorator, visit
|
# For a description of this decorator, visit
|
||||||
# http://www.imdb.com/title/tt0067756/
|
# http://www.imdb.com/title/tt0067756/
|
||||||
@ -140,6 +144,15 @@ def _checker_accept_request(self, opts, id_, msg, diff=10000):
|
|||||||
print("accepted " + msg)
|
print("accepted " + msg)
|
||||||
|
|
||||||
|
|
||||||
|
class FakeAction(object):
|
||||||
|
def __init__(self, src_project, src_package, tgt_project, tgt_package, src_rev):
|
||||||
|
self.src_project = src_project
|
||||||
|
self.src_package = src_package
|
||||||
|
self.tgt_project = tgt_project
|
||||||
|
self.tgt_package = tgt_package
|
||||||
|
self.src_rev = src_rev
|
||||||
|
|
||||||
|
|
||||||
def _checker_one_request(self, rq, opts):
|
def _checker_one_request(self, rq, opts):
|
||||||
if (opts.verbose):
|
if (opts.verbose):
|
||||||
ET.dump(rq)
|
ET.dump(rq)
|
||||||
@ -183,6 +196,24 @@ def _checker_one_request(self, rq, opts):
|
|||||||
print ("\n%s %s/%s -> %s/%s" % (subm_id,
|
print ("\n%s %s/%s -> %s/%s" % (subm_id,
|
||||||
prj, pkg,
|
prj, pkg,
|
||||||
tprj, tpkg))
|
tprj, tpkg))
|
||||||
|
|
||||||
|
# Check if the package comes from openSUSE:Factory and
|
||||||
|
# have a release target (like openSUSE:13.2)
|
||||||
|
if prj == 'openSUSE:Factory' and tprj == 'openSUSE:%s' % self.api.opensuse:
|
||||||
|
fake_devel_prj = 'openSUSE:%s:Devel' % self.api.opensuse
|
||||||
|
|
||||||
|
# _rev, _vrev = show_upstream_rev_vrev(opts.apiurl, prj, pkg, revision=rev, expand=True)
|
||||||
|
# assert _rev == rev, 'Revision is not the same'
|
||||||
|
# link_pac(src_project=prj, src_package=pkg,
|
||||||
|
# dst_project=fake_devel_prj, dst_package=tpkg,
|
||||||
|
# force=True,
|
||||||
|
# rev=_rev, vrev=_vrev)
|
||||||
|
|
||||||
|
act = FakeAction(pkg, prj, tprj, tpkg, rev)
|
||||||
|
self.api.submit_to_prj(act, fake_devel_prj)
|
||||||
|
self._checker_accept_request(opts, id_, 'The request is linked to %s' % fake_devel_prj, diff=0)
|
||||||
|
continue
|
||||||
|
|
||||||
dpkg = self._checker_check_devel_package(opts, tprj, tpkg)
|
dpkg = self._checker_check_devel_package(opts, tprj, tpkg)
|
||||||
# white list
|
# white list
|
||||||
self._devel_projects['X11:Bumblebee/'] = 'x2go'
|
self._devel_projects['X11:Bumblebee/'] = 'x2go'
|
||||||
@ -294,10 +325,6 @@ def _checker_check_devel_package(self, opts, project, package):
|
|||||||
key = "%s/%s" % (project, package)
|
key = "%s/%s" % (project, package)
|
||||||
if key in self._devel_projects:
|
if key in self._devel_projects:
|
||||||
return self._devel_projects[key]
|
return self._devel_projects[key]
|
||||||
if project == 'openSUSE:13.2':
|
|
||||||
if opts.verbose:
|
|
||||||
print 'no devel project for %s found in %s, retry using Factory projects' % (package, project)
|
|
||||||
return self._checker_check_devel_package(opts, 'openSUSE:Factory', package)
|
|
||||||
|
|
||||||
|
|
||||||
@cmdln.option('-v', '--verbose', action='store_true', help="verbose output")
|
@cmdln.option('-v', '--verbose', action='store_true', help="verbose output")
|
||||||
@ -315,10 +342,10 @@ def do_check_source(self, subcmd, opts, *args):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
self._devel_projects = {}
|
self._devel_projects = {}
|
||||||
self.opensuse = opts.project
|
|
||||||
|
|
||||||
opts.apiurl = self.get_api_url()
|
opts.apiurl = self.get_api_url()
|
||||||
|
|
||||||
|
self.api = StagingAPI(opts.apiurl, opts.project)
|
||||||
|
|
||||||
if len(args) and args[0] == 'skip':
|
if len(args) and args[0] == 'skip':
|
||||||
for id_ in args[1:]:
|
for id_ in args[1:]:
|
||||||
self._checker_accept_request(opts, id_, 'skip review')
|
self._checker_accept_request(opts, id_, 'skip review')
|
||||||
@ -330,7 +357,7 @@ def do_check_source(self, subcmd, opts, *args):
|
|||||||
|
|
||||||
if not ids:
|
if not ids:
|
||||||
review = "@by_group='factory-auto'+and+@state='new'"
|
review = "@by_group='factory-auto'+and+@state='new'"
|
||||||
target = "@project='openSUSE:{}'".format(self.opensuse)
|
target = "@project='openSUSE:{}'".format(self.api.opensuse)
|
||||||
url = makeurl(opts.apiurl, ('search', 'request'),
|
url = makeurl(opts.apiurl, ('search', 'request'),
|
||||||
"match=state/@name='review'+and+review[%s]+and+target[%s]" % (review, target))
|
"match=state/@name='review'+and+review[%s]+and+target[%s]" % (review, target))
|
||||||
root = ET.parse(http_GET(url)).getroot()
|
root = ET.parse(http_GET(url)).getroot()
|
||||||
@ -338,7 +365,7 @@ def do_check_source(self, subcmd, opts, *args):
|
|||||||
self._checker_one_request(rq, opts)
|
self._checker_one_request(rq, opts)
|
||||||
else:
|
else:
|
||||||
# we have a list, use them.
|
# we have a list, use them.
|
||||||
for id_ in ids.keys():
|
for id_ in ids:
|
||||||
url = makeurl(opts.apiurl, ('request', id_))
|
url = makeurl(opts.apiurl, ('request', id_))
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
xml = ET.parse(f)
|
xml = ET.parse(f)
|
||||||
|
@ -61,10 +61,19 @@ class Request(object):
|
|||||||
self.is_partially_cached = False
|
self.is_partially_cached = False
|
||||||
self.action_type = 'submit' # assume default
|
self.action_type = 'submit' # assume default
|
||||||
self.downloads = []
|
self.downloads = []
|
||||||
|
self.is_shadow_devel = False
|
||||||
|
|
||||||
if element:
|
if element:
|
||||||
self.load(element)
|
self.load(element)
|
||||||
|
|
||||||
|
# Detect if the request comes from Factory to a openSUSE
|
||||||
|
# release, and adjust the source and target projects
|
||||||
|
_is_product = re.match(r'openSUSE:\d{2}.\d', self.tgt_project)
|
||||||
|
if self.src_project == 'openSUSE:Factory' and _is_product:
|
||||||
|
self.is_shadow_devel = True
|
||||||
|
self.org_src_project, self.src_project = self.src_project, '%s:Devel' % self.tgt_project
|
||||||
|
self.org_src_package, self.src_package = self.src_package, self.tgt_package
|
||||||
|
|
||||||
def load(self, element):
|
def load(self, element):
|
||||||
"""Load a node from a ElementTree request XML element."""
|
"""Load a node from a ElementTree request XML element."""
|
||||||
self.request_id = int(element.get('id'))
|
self.request_id = int(element.get('id'))
|
||||||
@ -89,14 +98,16 @@ class Request(object):
|
|||||||
self.missings = []
|
self.missings = []
|
||||||
|
|
||||||
def str_compact(self):
|
def str_compact(self):
|
||||||
return '#[%s](%s)' % (self.request_id, self.src_package)
|
return '#[%s](%s)%s' % (self.request_id, self.src_package,
|
||||||
|
' Shadow' if self.is_shadow_devel else '')
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '#[%s] %s/%s -> %s/%s' % (self.request_id,
|
return '#[%s] %s/%s -> %s/%s%s' % (self.request_id,
|
||||||
self.src_project,
|
self.src_project,
|
||||||
self.src_package,
|
self.src_package,
|
||||||
self.tgt_project,
|
self.tgt_project,
|
||||||
self.tgt_package)
|
self.tgt_package,
|
||||||
|
' Shadow' if self.is_shadow_devel else '')
|
||||||
|
|
||||||
|
|
||||||
class CheckRepo(object):
|
class CheckRepo(object):
|
||||||
@ -177,12 +188,14 @@ class CheckRepo(object):
|
|||||||
print('ERROR in URL %s [%s]' % (url, e))
|
print('ERROR in URL %s [%s]' % (url, e))
|
||||||
return code
|
return code
|
||||||
|
|
||||||
def get_request(self, request_id):
|
def get_request(self, request_id, internal=False):
|
||||||
"""Get a request XML onject."""
|
"""Get a request XML or internal object."""
|
||||||
request = None
|
request = None
|
||||||
try:
|
try:
|
||||||
url = makeurl(self.apiurl, ('request', str(request_id)))
|
url = makeurl(self.apiurl, ('request', str(request_id)))
|
||||||
request = ET.parse(http_GET(url)).getroot()
|
request = ET.parse(http_GET(url)).getroot()
|
||||||
|
if internal:
|
||||||
|
request = Request(element=request)
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
print('ERROR in URL %s [%s]' % (url, e))
|
print('ERROR in URL %s [%s]' % (url, e))
|
||||||
return request
|
return request
|
||||||
@ -419,7 +432,7 @@ class CheckRepo(object):
|
|||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
# This exception happends some times when there is an
|
# This exception happends some times when there is an
|
||||||
# 'error' attribute in the package information XML
|
# 'error' attribute in the package information XML
|
||||||
rq.error = "There is an error in the SPEC file." % (rq.src_project, spec)
|
rq.error = 'There is an error in the SPEC file for (%s, %s).' % (rq.src_project, spec)
|
||||||
rq.updated = True
|
rq.updated = True
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -856,3 +869,12 @@ class CheckRepo(object):
|
|||||||
# print " - WARNING: Can't found list of packages (RPM) for %s in %s (%s, %s)" % (
|
# print " - WARNING: Can't found list of packages (RPM) for %s in %s (%s, %s)" % (
|
||||||
# package, project, repository, arch)
|
# package, project, repository, arch)
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
def remove_link_if_shadow_devel(self, request):
|
||||||
|
"""If the request is a shadow_devel (the reference is to a request
|
||||||
|
that is a link from the product to Factory), remove the link
|
||||||
|
to transform it as a normal request.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if request.is_shadow_devel:
|
||||||
|
self.staging.delete_to_prj(request, request.src_project)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user