mirror of
https://github.com/openSUSE/osc.git
synced 2025-10-05 17:09:19 +02:00
submitrequest: old not anymore used maintenance code got removed. It is possible now
to create one request to submit all changed packages of an project in one request. Just run "osc sr" in the checked out project directory.
This commit is contained in:
3
NEWS
3
NEWS
@@ -1,5 +1,8 @@
|
|||||||
0.138
|
0.138
|
||||||
- add support to remove repositories recursively (mostly only usefull for admins)
|
- add support to remove repositories recursively (mostly only usefull for admins)
|
||||||
|
- submitrequest: old not anymore used maintenance code got removed. It is possible now
|
||||||
|
to create one request to submit all changed packages of an project in
|
||||||
|
one request. Just run "osc sr" in the checked out project directory.
|
||||||
|
|
||||||
0.137
|
0.137
|
||||||
- support single binary download via getbinaries command
|
- support single binary download via getbinaries command
|
||||||
|
@@ -823,6 +823,8 @@ class Osc(cmdln.Cmdln):
|
|||||||
@cmdln.option('--nodevelproject', action='store_true',
|
@cmdln.option('--nodevelproject', action='store_true',
|
||||||
help='do not follow a defined devel project ' \
|
help='do not follow a defined devel project ' \
|
||||||
'(primary project where a package is developed)')
|
'(primary project where a package is developed)')
|
||||||
|
@cmdln.option('--seperate-requests', action='store_true',
|
||||||
|
help='Create multiple request instead of a single one (when command is used for entire project)')
|
||||||
@cmdln.option('--cleanup', action='store_true',
|
@cmdln.option('--cleanup', action='store_true',
|
||||||
help='remove package if submission gets accepted (default for home:<id>:branch projects)')
|
help='remove package if submission gets accepted (default for home:<id>:branch projects)')
|
||||||
@cmdln.option('--no-cleanup', action='store_true',
|
@cmdln.option('--no-cleanup', action='store_true',
|
||||||
@@ -870,6 +872,10 @@ class Osc(cmdln.Cmdln):
|
|||||||
elif opts.no_update:
|
elif opts.no_update:
|
||||||
src_update = "noupdate"
|
src_update = "noupdate"
|
||||||
|
|
||||||
|
myreqs = []
|
||||||
|
if opts.supersede:
|
||||||
|
myreqs = [opts.supersede]
|
||||||
|
|
||||||
args = slash_split(args)
|
args = slash_split(args)
|
||||||
|
|
||||||
# remove this block later again
|
# remove this block later again
|
||||||
@@ -889,94 +895,74 @@ class Osc(cmdln.Cmdln):
|
|||||||
if len(args) > 4:
|
if len(args) > 4:
|
||||||
raise oscerr.WrongArgs('Too many arguments.')
|
raise oscerr.WrongArgs('Too many arguments.')
|
||||||
|
|
||||||
if len(args) > 0 and len(args) <= 2 and is_project_dir(os.getcwd()):
|
if len(args) == 2 and is_project_dir(os.getcwd()):
|
||||||
sys.exit('osc submitrequest from project directory is only working without target specs and for source linked files\n')
|
sys.exit('You can not specify a target package when submitting an entire project\n')
|
||||||
|
|
||||||
apiurl = self.get_api_url()
|
apiurl = self.get_api_url()
|
||||||
|
|
||||||
if len(args) == 0 and is_project_dir(os.getcwd()):
|
if len(args) < 2 and is_project_dir(os.getcwd()):
|
||||||
import cgi
|
import cgi
|
||||||
# submit requests for multiple packages are currently handled via multiple requests
|
|
||||||
# They could be also one request with multiple actions, but that avoids to accepts parts of it.
|
|
||||||
project = store_read_project(os.curdir)
|
project = store_read_project(os.curdir)
|
||||||
|
|
||||||
sr_ids = []
|
sr_ids = []
|
||||||
pi = []
|
# for single request
|
||||||
pac = []
|
actionxml = ""
|
||||||
targetprojects = []
|
options_block=""
|
||||||
|
if src_update:
|
||||||
|
options_block="""<options><sourceupdate>%s</sourceupdate></options> """ % (src_update)
|
||||||
|
|
||||||
# loop via all packages for checking their state
|
# loop via all packages for checking their state
|
||||||
for p in meta_get_packagelist(apiurl, project):
|
for p in meta_get_packagelist(apiurl, project):
|
||||||
if p.startswith("_patchinfo:") or p.startswith("patchinfo"):
|
print "XXX", p
|
||||||
pi.append(p)
|
# get _link info from server, that knows about the local state ...
|
||||||
else:
|
u = makeurl(apiurl, ['source', project, p])
|
||||||
# get _link info from server, that knows about the local state ...
|
f = http_GET(u)
|
||||||
u = makeurl(apiurl, ['source', project, p])
|
root = ET.parse(f).getroot()
|
||||||
f = http_GET(u)
|
if len(args) == 1:
|
||||||
root = ET.parse(f).getroot()
|
target_project = args[0]
|
||||||
linkinfo = root.find('linkinfo')
|
linkinfo = root.find('linkinfo')
|
||||||
if linkinfo == None:
|
if linkinfo == None:
|
||||||
print "Package ", p, " is not a source link."
|
if len(args) < 1:
|
||||||
|
print "Package ", p, " is not a source link and no target specified."
|
||||||
sys.exit("This is currently not supported.")
|
sys.exit("This is currently not supported.")
|
||||||
|
else:
|
||||||
if linkinfo.get('error'):
|
if linkinfo.get('error'):
|
||||||
print "Package ", p, " is a broken source link."
|
print "Package ", p, " is a broken source link."
|
||||||
sys.exit("Please fix this first")
|
sys.exit("Please fix this first")
|
||||||
t = linkinfo.get('project')
|
t = linkinfo.get('project')
|
||||||
if t:
|
if t:
|
||||||
|
if target_project == None:
|
||||||
|
target_project = t
|
||||||
if len(root.findall('entry')) > 1: # This is not really correct, but should work mostly
|
if len(root.findall('entry')) > 1: # This is not really correct, but should work mostly
|
||||||
# Real fix is to ask the api if sources are modificated
|
# Real fix is to ask the api if sources are modificated
|
||||||
# but there is no such call yet.
|
# but there is no such call yet.
|
||||||
targetprojects.append(t)
|
|
||||||
pac.append(p)
|
|
||||||
print "Submitting package ", p
|
print "Submitting package ", p
|
||||||
else:
|
else:
|
||||||
print " Skipping package ", p
|
print " Skipping not modified package ", p
|
||||||
|
next
|
||||||
else:
|
else:
|
||||||
print "Skipping package ", p, " since it is a source link pointing inside the project."
|
print "Skipping package ", p, " since it is a source link pointing inside the project."
|
||||||
serviceinfo = root.find('serviceinfo')
|
next
|
||||||
if serviceinfo != None:
|
|
||||||
if serviceinfo.get('code') != "succeeded":
|
|
||||||
print "Package ", p, " has a ", serviceinfo.get('code'), " source service"
|
|
||||||
sys.exit("Please fix this first")
|
|
||||||
if serviceinfo.get('error'):
|
|
||||||
print "Package ", p, " contains a failed source service."
|
|
||||||
sys.exit("Please fix this first")
|
|
||||||
|
|
||||||
# was this project created by clone request ?
|
serviceinfo = root.find('serviceinfo')
|
||||||
u = makeurl(apiurl, ['source', project, '_attribute', 'OBS:RequestCloned'])
|
if serviceinfo != None:
|
||||||
f = http_GET(u)
|
if serviceinfo.get('code') != "succeeded":
|
||||||
root = ET.parse(f).getroot()
|
print "Package ", p, " has a ", serviceinfo.get('code'), " source service"
|
||||||
value = root.findtext('attribute/value')
|
sys.exit("Please fix this first")
|
||||||
myreqs = {}
|
if serviceinfo.get('error'):
|
||||||
if value:
|
print "Package ", p, " contains a failed source service."
|
||||||
myreqs = [ value ]
|
sys.exit("Please fix this first")
|
||||||
|
|
||||||
if not opts.yes:
|
# submitting this package
|
||||||
if pi:
|
if opts.seperate_requests:
|
||||||
print "Submitting patchinfo ", ', '.join(pi), " to ", ', '.join(targetprojects)
|
# create a single request
|
||||||
repl = raw_input('\nEverything fine? Can we create the requests ? (y/n) ')
|
result = create_submit_request(apiurl, project, p)
|
||||||
if repl.lower() != 'y':
|
if not result:
|
||||||
print >>sys.stderr, 'Aborted...'
|
sys.exit("submit request creation failed")
|
||||||
raise oscerr.UserAbort()
|
sr_ids.append(result)
|
||||||
|
else:
|
||||||
|
|
||||||
# loop via all packages to do the action
|
|
||||||
for p in pac:
|
|
||||||
result = create_submit_request(apiurl, project, p)
|
|
||||||
if not result:
|
|
||||||
# sys.exit(result)
|
|
||||||
sys.exit("submit request creation failed")
|
|
||||||
sr_ids.append(result)
|
|
||||||
|
|
||||||
# create submit requests for all found patchinfos
|
|
||||||
actionxml=""
|
|
||||||
options_block=""
|
|
||||||
if src_update:
|
|
||||||
options_block="""<options><sourceupdate>%s</sourceupdate></options> """ % (src_update)
|
|
||||||
|
|
||||||
for p in pi:
|
|
||||||
for t in targetprojects:
|
|
||||||
s = """<action type="submit"> <source project="%s" package="%s" /> <target project="%s" package="%s" /> %s </action>""" % \
|
s = """<action type="submit"> <source project="%s" package="%s" /> <target project="%s" package="%s" /> %s </action>""" % \
|
||||||
(project, p, t, p, options_block)
|
(project, p, t, p, options_block)
|
||||||
actionxml += s
|
actionxml += s
|
||||||
|
|
||||||
if actionxml != "":
|
if actionxml != "":
|
||||||
@@ -988,18 +974,26 @@ class Osc(cmdln.Cmdln):
|
|||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
sr_ids.append(root.get('id'))
|
sr_ids.append(root.get('id'))
|
||||||
|
|
||||||
print "Requests created: ",
|
print "Request created: ",
|
||||||
for i in sr_ids:
|
for i in sr_ids:
|
||||||
print i,
|
print i,
|
||||||
|
|
||||||
repl = ''
|
# was this project created by clone request ?
|
||||||
if len(myreqs) > 0 and not opts.supersede:
|
u = makeurl(apiurl, ['source', project, '_attribute', 'OBS:RequestCloned'])
|
||||||
|
f = http_GET(u)
|
||||||
|
root = ET.parse(f).getroot()
|
||||||
|
value = root.findtext('attribute/value')
|
||||||
|
if value:
|
||||||
|
repl = ''
|
||||||
print '\n\nThere are already following submit request: %s.' % \
|
print '\n\nThere are already following submit request: %s.' % \
|
||||||
', '.join([str(i) for i in myreqs ])
|
', '.join([str(i) for i in myreqs ])
|
||||||
repl = raw_input('\nSupersede the old requests? (y/n) ')
|
repl = raw_input('\nSupersede the old requests? (y/n) ')
|
||||||
if repl.lower() == 'y':
|
if repl.lower() == 'y':
|
||||||
for req in myreqs:
|
myreqs += [ value ]
|
||||||
change_request_state(apiurl, str(req), 'superseded',
|
|
||||||
|
if len(myreqs) > 0:
|
||||||
|
for req in myreqs:
|
||||||
|
change_request_state(apiurl, str(req), 'superseded',
|
||||||
'superseded by %s' % result, result)
|
'superseded by %s' % result, result)
|
||||||
|
|
||||||
sys.exit('Successfully finished')
|
sys.exit('Successfully finished')
|
||||||
|
Reference in New Issue
Block a user