1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

- slightly modified version of David Greaves' <david@dgreaves.com> patch to add a --map-repo option to aggregatepac

This commit is contained in:
Marcus Hüwe 2009-07-31 14:31:20 +00:00
parent 2d1126b847
commit 365be249c3
2 changed files with 23 additions and 3 deletions

View File

@ -952,6 +952,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
link_pac(src_project, src_package, dst_project, dst_package, opts.force, rev, opts.cicount)
@cmdln.option('-m', '--map-repo', metavar='SRC=TARGET[,SRC=TARGET]',
help='Allows repository mapping(s) to be given as SRC=TARGET[,SRC=TARGET]')
def do_aggregatepac(self, subcmd, opts, *args):
"""${cmd_name}: "Aggregate" a package to another package
@ -988,7 +990,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
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)
repo_map = {}
if opts.map_repo:
for pair in opts.map_repo.split(','):
src_tgt = pair.split('=')
if len(src_tgt) != 2:
print >>sys.stderr, 'map "%s" must be SRC=TARGET[,SRC=TARGET]' % opts.map_repo
return 1
repo_map[src_tgt[0]] = src_tgt[1]
aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map)
@cmdln.option('-c', '--client-side-copy', action='store_true',

View File

@ -2723,11 +2723,12 @@ def link_pac(src_project, src_package, dst_project, dst_package, force, rev='',
http_PUT(u, data=link_template)
print 'Done.'
def aggregate_pac(src_project, src_package, dst_project, dst_package):
def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map = {}):
"""
aggregate package
- "src" is the original package
- "dst" is the "aggregate" package that we are creating here
- "map" is a dictionary SRC => TARGET repository mappings
"""
src_meta = show_package_meta(conf.config['apiurl'], src_project, src_package)
@ -2748,10 +2749,17 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package):
aggregate_template = """\
<aggregatelist>
<aggregate project="%s">
""" % (src_project)
for tgt, src in repo_map.iteritems():
aggregate_template += """\
<repository target="%s" source="%s" />
""" % (tgt, src)
aggregate_template += """\
<package>%s</package>
</aggregate>
</aggregatelist>
""" % (src_project, src_package)
""" % ( src_package)
u = makeurl(conf.config['apiurl'], ['source', dst_project, dst_package, '_aggregate'])
http_PUT(u, data=aggregate_template)