1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-26 12:12:11 +01:00

* patchinfo runtime fixes

* support submit requests on project level, osc is checking which
  packages have changed and submits only the changed after asking back.
* add support for _patchinfo package submissions in "osc sr" on project level
This commit is contained in:
Adrian Schröter 2009-11-13 08:58:37 +00:00
parent 601b3c3416
commit bc6f77d1da
3 changed files with 105 additions and 9 deletions

3
NEWS
View File

@ -20,6 +20,8 @@
- osc buildinfo accepts now also "prj pkg repo arch [spec/dsc]"
- osc buildconfig accepts now also "prj pkg repo arch"
- fixed warning messages regarding SSL certificate on some plattforms (Fedora)
- support submit requests on project level, osc is checking which packages
have changed and submits only the changed after asking back.
#
# Features which require OBS 1.7
#
@ -27,6 +29,7 @@
- added "osc meta attribute" for basic attribute creation, deletion, showing and value setting
- implement "osc mbranch" call to create projects with multiple source package (instances)
- new "osc patchinfo" command: basic patchinfo generation and modification support
- add support for _patchinfo package submissions in "osc sr" on project level
0.123
- IMPORTANT: ssl certificate checks are actually performed now to

View File

@ -330,6 +330,7 @@ class Osc(cmdln.Cmdln):
apiurl = Project(localdir).apiurl
else:
sys.exit('This command must be called in a checked out project.')
patchinfo = None
for p in meta_get_packagelist(apiurl, project):
if p.startswith("_patchinfo:"):
patchinfo = p
@ -337,7 +338,7 @@ class Osc(cmdln.Cmdln):
if opts.force or not patchinfo:
print "Creating initial patchinfo..."
query='cmd=createpatchinfo'
if args[0]:
if args and args[0]:
query += "&name=" + args[0]
url = makeurl(apiurl, ['source', project], query=query)
f = http_POST(url)
@ -620,6 +621,8 @@ class Osc(cmdln.Cmdln):
help='show diff only instead of creating the actual request')
@cmdln.option('-l', '--list', action='store_true',
help='show submitrequests. Same as \'osc req list -M -a -t submit -D 0\'')
@cmdln.option('--yes', action='store_true',
help='proceed without asking.')
@cmdln.alias("sr")
@cmdln.alias("submitreq")
@cmdln.alias("submitpac")
@ -678,9 +681,92 @@ class Osc(cmdln.Cmdln):
if len(args) > 4:
raise oscerr.WrongArgs('Too many arguments.')
apiurl = conf.config['apiurl']
if len(args) > 0 and 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')
if len(args) <= 2:
if len(args) == 0 and is_project_dir(os.getcwd()):
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 = Project(os.getcwd())
apiurl = project.apiurl
sr_ids = []
pi = []
pac = []
targetprojects = []
# loop via all packages for checking their state
for p in meta_get_packagelist(apiurl, project.name):
if p.startswith("_patchinfo:"):
pi.append(p)
else:
# get _link info from server, who knows about the local state ...
u = makeurl(apiurl, ['source', project.name, p])
f = http_GET(u)
root = ET.parse(f).getroot()
linkinfo = root.find('linkinfo')
if linkinfo == None:
print "Package ", p, " is not a source link."
sys.exit("This is currently not supported.")
if linkinfo.get('error'):
print "Package ", p, " is a broken source link."
sys.exit("Please fix this first")
t = linkinfo.get('project')
if t:
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
# but there is no such call yet.
targetprojects.append(t)
pac.append(p)
print "Submitting package ", p
else:
print " Skipping package ", p
else:
print "Skipping package ", p, " since it is a source link pointing inside to the project."
if not opts.yes:
if pi:
str=", "
print "Submitting patchinfo ", str.join(pi), " to ", str.join(targetprojects)
print "\nEverything fine? Can we create the requests ? [y/n]"
if sys.stdin.read(1) != "y":
sys.exit("Aborted...")
# loop via all packages to do the action
for p in pac:
result = create_submit_request(apiurl, project.name, 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>""" % \
(project.name, p, t, p, options_block)
actionxml += s
if actionxml != "":
xml = """<request> %s <state name="new"/> <description>%s</description> </request> """ % \
(actionxml, cgi.escape(opts.message or ""))
u = makeurl(apiurl, ['request'], query='cmd=create')
f = http_POST(u, data=xml)
root = ET.parse(f).getroot()
sr_ids.append(root.get('id'))
print "Requests created: ",
for i in sr_ids:
print i,
sys.exit('Successfull finished')
elif len(args) <= 2:
# try using the working copy at hand
p = findpacs(os.curdir)[0]
src_project = p.prjname

View File

@ -2419,22 +2419,30 @@ def create_change_devel_request(apiurl,
return root.get('id')
# This creates an old style submit request for server api 1.0
def create_submit_request(apiurl,
src_project, src_package,
dst_project, dst_package,
message, orev=None, src_update=None):
dst_project=None, dst_package=None,
message=None, orev=None, src_update=None):
import cgi
options_block=""
if src_update:
options_block="""<options><sourceupdate>%s</sourceupdate></options> """ % (src_update)
# Yes, this kind of xml construction is horrible
targetxml = ""
if dst_project:
packagexml = ""
if dst_package:
packagexml = """package="%s" """ %( dst_package )
targetxml = """<target project="%s" %s /> """ %( dst_project, packagexml )
# XXX: keep the old template for now in order to work with old obs instances
xml = """\
<request type="submit">
<submit>
<source project="%s" package="%s" rev="%s"/>
<target project="%s" package="%s" />
%s
%s
</submit>
<state name="new"/>
@ -2443,10 +2451,9 @@ def create_submit_request(apiurl,
""" % (src_project,
src_package,
orev or show_upstream_rev(apiurl, src_project, src_package),
dst_project,
dst_package,
targetxml,
options_block,
cgi.escape(message or ''))
cgi.escape(message or ""))
u = makeurl(apiurl, ['request'], query='cmd=create')
f = http_POST(u, data=xml)