mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-25 22:36:13 +01:00
Merge pull request #1009 from dmach/aggregatepac-flavor
Support flavors in aggregatepac
This commit is contained in:
commit
a223dd085a
@ -3014,7 +3014,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
DESTPAC is omitted.
|
DESTPAC is omitted.
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
osc aggregatepac SOURCEPRJ SOURCEPAC DESTPRJ [DESTPAC]
|
osc aggregatepac SOURCEPRJ SOURCEPAC[:FLAVOR] DESTPRJ [DESTPAC]
|
||||||
${cmd_option_list}
|
${cmd_option_list}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
51
osc/core.py
51
osc/core.py
@ -5339,19 +5339,28 @@ def link_pac(src_project, src_package, dst_project, dst_package, force, rev='',
|
|||||||
http_PUT(u, data=link_template)
|
http_PUT(u, data=link_template)
|
||||||
print('Done.')
|
print('Done.')
|
||||||
|
|
||||||
def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map = {}, disable_publish = False, nosources = False):
|
|
||||||
|
def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map=None,
|
||||||
|
disable_publish=False, nosources=False, repo_check=True):
|
||||||
"""
|
"""
|
||||||
aggregate package
|
aggregate package
|
||||||
- "src" is the original package
|
- "src" is the original package
|
||||||
- "dst" is the "aggregate" package that we are creating here
|
- "dst" is the "aggregate" package that we are creating here
|
||||||
- "map" is a dictionary SRC => TARGET repository mappings
|
- "map" is a dictionary SRC => TARGET repository mappings
|
||||||
|
- "repo_check" determines if presence of repos in the source and destination repos is checked
|
||||||
"""
|
"""
|
||||||
meta_change = False
|
meta_change = False
|
||||||
dst_meta = ''
|
dst_meta = ''
|
||||||
apiurl = conf.config['apiurl']
|
apiurl = conf.config['apiurl']
|
||||||
|
repo_map = repo_map or {}
|
||||||
|
|
||||||
|
# we need to remove :flavor from the package names when accessing meta
|
||||||
|
src_package_meta = src_package.split(":")[0]
|
||||||
|
dst_package_meta = dst_package.split(":")[0]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dst_meta = meta_exists(metatype='pkg',
|
dst_meta = meta_exists(metatype='pkg',
|
||||||
path_args=(quote_plus(dst_project), quote_plus(dst_package)),
|
path_args=(quote_plus(dst_project), quote_plus(dst_package_meta)),
|
||||||
template_args=None,
|
template_args=None,
|
||||||
create_new=False, apiurl=apiurl)
|
create_new=False, apiurl=apiurl)
|
||||||
root = ET.fromstring(parse_meta_to_string(dst_meta))
|
root = ET.fromstring(parse_meta_to_string(dst_meta))
|
||||||
@ -5363,9 +5372,37 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map =
|
|||||||
raise
|
raise
|
||||||
meta_change = True
|
meta_change = True
|
||||||
|
|
||||||
|
if repo_check:
|
||||||
|
src_repos = set(get_repositories_of_project(apiurl, src_project))
|
||||||
|
dst_repos = set(get_repositories_of_project(apiurl, dst_project))
|
||||||
|
|
||||||
|
if repo_map:
|
||||||
|
map_from = set(repo_map.keys())
|
||||||
|
map_to = set(repo_map.values())
|
||||||
|
|
||||||
|
# only repos that do not exist in src/dst remain
|
||||||
|
delta_from = map_from - src_repos
|
||||||
|
delta_to = map_to - dst_repos
|
||||||
|
|
||||||
|
if delta_from or delta_to:
|
||||||
|
msg = ["The following repos in repo map do not exist"]
|
||||||
|
if delta_from:
|
||||||
|
msg += [" Source repos: " + ", ".join(sorted(delta_from))]
|
||||||
|
if delta_to:
|
||||||
|
msg += [" Destination repos: " + ", ".join(sorted(delta_to))]
|
||||||
|
raise oscerr.OscBaseError("\n".join(msg))
|
||||||
|
else:
|
||||||
|
# no overlap between src and dst repos leads to the 'broken: missing repositories: <src_project>' message
|
||||||
|
if not src_repos & dst_repos:
|
||||||
|
msg = [
|
||||||
|
"The source and the destination project do not have any repository names in common.",
|
||||||
|
"Use repo map to specify actual repository mapping.",
|
||||||
|
]
|
||||||
|
raise oscerr.OscBaseError("\n".join(msg))
|
||||||
|
|
||||||
if meta_change:
|
if meta_change:
|
||||||
src_meta = show_package_meta(apiurl, src_project, src_package)
|
src_meta = show_package_meta(apiurl, src_project, src_package_meta)
|
||||||
dst_meta = replace_pkg_meta(src_meta, dst_package, dst_project)
|
dst_meta = replace_pkg_meta(src_meta, dst_package_meta, dst_project)
|
||||||
meta_change = True
|
meta_change = True
|
||||||
|
|
||||||
if disable_publish:
|
if disable_publish:
|
||||||
@ -5379,12 +5416,12 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map =
|
|||||||
dst_meta = ET.tostring(root, encoding=ET_ENCODING)
|
dst_meta = ET.tostring(root, encoding=ET_ENCODING)
|
||||||
if meta_change:
|
if meta_change:
|
||||||
edit_meta('pkg',
|
edit_meta('pkg',
|
||||||
path_args=(dst_project, dst_package),
|
path_args=(dst_project, dst_package_meta),
|
||||||
data=dst_meta)
|
data=dst_meta)
|
||||||
|
|
||||||
# create the _aggregate file
|
# create the _aggregate file
|
||||||
# but first, make sure not to overwrite an existing one
|
# but first, make sure not to overwrite an existing one
|
||||||
if '_aggregate' in meta_get_filelist(apiurl, dst_project, dst_package):
|
if '_aggregate' in meta_get_filelist(apiurl, dst_project, dst_package_meta):
|
||||||
print(file=sys.stderr)
|
print(file=sys.stderr)
|
||||||
print('_aggregate file already exists...! Aborting', file=sys.stderr)
|
print('_aggregate file already exists...! Aborting', file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -5413,7 +5450,7 @@ def aggregate_pac(src_project, src_package, dst_project, dst_package, repo_map =
|
|||||||
</aggregatelist>
|
</aggregatelist>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
u = makeurl(apiurl, ['source', dst_project, dst_package, '_aggregate'])
|
u = makeurl(apiurl, ['source', dst_project, dst_package_meta, '_aggregate'])
|
||||||
http_PUT(u, data=aggregate_template)
|
http_PUT(u, data=aggregate_template)
|
||||||
print('Done.')
|
print('Done.')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user