mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 17:16:23 +01:00
- aggregatepac: new command, similar to linkpac. Patch from Pavol Rusnak.
- prjresults: for newly added packages, build status may be missing. Cope with that.
This commit is contained in:
parent
420b9cf25c
commit
675901bc5d
@ -436,6 +436,36 @@ class Osc(cmdln.Cmdln):
|
||||
return 1
|
||||
link_pac(src_project, src_package, dst_project, dst_package)
|
||||
|
||||
def do_aggregatepac(self, subcmd, opts, *args):
|
||||
"""${cmd_name}: "Aggregate" a package to another package
|
||||
|
||||
The DESTPAC name is optional; the source packages' name will be used if
|
||||
DESTPAC is omitted.
|
||||
|
||||
usage:
|
||||
osc aggregatepac SOURCEPRJ SOURCEPAC DESTPRJ [DESTPAC]
|
||||
${cmd_option_list}
|
||||
"""
|
||||
|
||||
args = slash_split(args)
|
||||
|
||||
if not args or len(args) < 3:
|
||||
print >>sys.stderr, 'Incorrect number of argument.'
|
||||
self.do_help([None, 'aggregatepac'])
|
||||
return 2
|
||||
|
||||
src_project = args[0]
|
||||
src_package = args[1]
|
||||
dst_project = args[2]
|
||||
if len(args) > 3:
|
||||
dst_package = args[3]
|
||||
else:
|
||||
dst_package = src_package
|
||||
|
||||
if src_project == dst_project and src_package == dst_package:
|
||||
print >>sys.stderr, 'Error: source and destination are the same.'
|
||||
return 1
|
||||
aggregate_pac(src_project, src_package, dst_project, dst_package)
|
||||
|
||||
@cmdln.option('-t', '--to-apiurl', metavar='URL',
|
||||
help='URL of destination api server. Default is the source api server.')
|
||||
|
46
osc/core.py
46
osc/core.py
@ -1423,6 +1423,50 @@ def link_pac(src_project, src_package, dst_project, dst_package):
|
||||
http_PUT(u, data=link_template)
|
||||
print 'Done.'
|
||||
|
||||
def aggregate_pac(src_project, src_package, dst_project, dst_package):
|
||||
"""
|
||||
aggregate package
|
||||
- "src" is the original package
|
||||
- "dst" is the "aggregate" package that we are creating here
|
||||
"""
|
||||
|
||||
src_meta = show_package_meta(conf.config['apiurl'], src_project, src_package)
|
||||
|
||||
# replace package name and username
|
||||
# using a string buffer
|
||||
# and create the package
|
||||
tree = ET.parse(StringIO(''.join(src_meta)))
|
||||
root = tree.getroot()
|
||||
root.set('name', dst_package)
|
||||
root.set('project', dst_project)
|
||||
tree.find('person').set('userid', conf.config['user'])
|
||||
buf = StringIO()
|
||||
tree.write(buf)
|
||||
src_meta = buf.getvalue()
|
||||
|
||||
edit_meta('pkg',
|
||||
path_args=(dst_project, dst_package),
|
||||
data=src_meta)
|
||||
|
||||
# create the _aggregate file
|
||||
# but first, make sure not to overwrite an existing one
|
||||
if '_aggregate' in meta_get_filelist(conf.config['apiurl'], dst_project, dst_package):
|
||||
print >>sys.stderr
|
||||
print >>sys.stderr, '_aggregate file already exists...! Aborting'
|
||||
sys.exit(1)
|
||||
|
||||
print 'Creating _aggregate...',
|
||||
aggregate_template = """\
|
||||
<aggregatelist>
|
||||
<aggregate project="%s">
|
||||
<package>%s</package>
|
||||
</aggregate>
|
||||
</aggregatelist>
|
||||
""" % (src_project, src_package)
|
||||
|
||||
u = makeurl(conf.config['apiurl'], ['source', dst_project, dst_package, '_aggregate'])
|
||||
http_PUT(u, data=aggregate_template)
|
||||
print 'Done.'
|
||||
|
||||
def copy_pac(src_apiurl, src_project, src_package,
|
||||
dst_apiurl, dst_project, dst_package):
|
||||
@ -1625,6 +1669,8 @@ def get_prj_results(apiurl, prj, show_legend=False):
|
||||
line = []
|
||||
line.append(' ')
|
||||
for pac in pacs[startpac:startpac+max_pacs]:
|
||||
if not status.has_key(pac): # for newly added packages, status may be missing
|
||||
status[pac] = '?'
|
||||
line.append(status[pac])
|
||||
line.append(' ')
|
||||
line.append(' %s %s' % (target['repo'], target['arch']))
|
||||
|
Loading…
Reference in New Issue
Block a user