Commit bfcc3444 authored by Lorenz Hüdepohl's avatar Lorenz Hüdepohl
Browse files

Fix mpcdf_sync_projects

- Had old logic for distribution
- Removed '--all' flag to disentangle functionality
  Use mpcdf_setup_subproject if you want to re-create all enabled
  repositories for all packages
parent e8eea7a3
Pipeline #72175 passed with stage
in 14 seconds
......@@ -865,10 +865,7 @@ def set_as_branch(api_url, my_project, my_package, main_project, main_package):
return True
def sync_projects(api_url, package=None, from_project="software", to_projects=None, redo_all=False, add_to_maintainers=True, verbose=False):
if package is not None and redo_all:
raise osc.oscerr.WrongArgs('Cannot specify `redo_all` and package')
def sync_projects(api_url, package=None, from_project="software", to_projects=None, add_to_maintainers=True, verbose=False):
if to_projects is None:
to_projects = [p for p in osc.core.meta_get_project_list(api_url)
if p.startswith("software:") and not (p == "software:dist" or p == "software:images")]
......@@ -880,15 +877,16 @@ def sync_projects(api_url, package=None, from_project="software", to_projects=No
if package is None:
from_packages = osc.core.meta_get_packagelist(api_url, from_project)
if not redo_all:
from_packages = list(sorted(set(from_packages) - set(to_packages)))
from_packages = [package]
def non_system_package(package):
enable_repos = get_attribute_values(api_url, from_project, package, "MPCDF:enable_repositories")
if enable_repos == ["system"]:
print("Not branching package {0}, is only enabled for 'System'".format(package))
if len(enable_repos) == 0:
print("Not branching package {0}, is disabled".format(package))
return False
elif enable_repos == ["system"]:
print("Not branching package {0}, is only enabled for 'system'".format(package))
return False
return True
......@@ -930,18 +928,6 @@ def sync_projects(api_url, package=None, from_project="software", to_projects=No
to_meta.insert(2, person)
osc.core.edit_meta("pkg", (to_project, orig_package), data=ElementTree.tostring(to_meta), apiurl=api_url)
if package is None and redo_all:
# Check if distribution is already set in to_project
to_prj_meta = project_meta(api_url, to_project)
some_repo = to_prj_meta.find('./repository')
if some_repo is None:
distribution = project_meta(api_url, from_project).find('./repository/path[@project="software"]').get("repository")
distribution = some_repo.find('./path[@project="distributions"]').get("repository")
print("Creating repository configuration")
mpcdf_setup_subproject(api_url, to_project, distribution=distribution)
for orig_package in from_packages:
mpcdf_enable_repositories(api_url, to_project, orig_package, verbose=verbose)
......@@ -8,8 +8,6 @@ import osc.core
import osc.cmdln
@osc.cmdln.option('-a', '--all', action="store_true",
help="Update all packages in the target repository, not only new ones")
@osc.cmdln.option('-f', '--from', default="software",
help="Source project")
@osc.cmdln.option('-t', '--to',
......@@ -23,7 +21,6 @@ def do_mpcdf_sync_projects(self, subcmd, opts, *args):
osc mpcdf_sync_projects
osc mpcdf_sync_projects PACKAGE
osc mpcdf_sync_projects --all-packages
- Sync all new packages from software into all software: sub-projects
......@@ -32,8 +29,8 @@ def do_mpcdf_sync_projects(self, subcmd, opts, *args):
- Sync the package foobar_1_2 into all software: sub-projects
#> osc mpcdf_sync_projects foobar_1_2
- Sync all packages from software to software:SLE_12_SP3:skylake
#> osc mpcdf_sync_projects --all-packages --to software:SLE_12_SP3:skylake
- Update project software:SLE_12_SP3:skylake with all new packages from software
#> osc mpcdf_sync_projects --to software:SLE_12_SP3:skylake
......@@ -41,8 +38,6 @@ def do_mpcdf_sync_projects(self, subcmd, opts, *args):
if len(args) > 1:
raise osc.oscerr.WrongArgs("Too many arguments")
elif len(args) == 1 and opts.all:
raise osc.oscerr.WrongArgs('Cannot specify `--all` and PACKAGE')
elif len(args) == 1:
package, = args
......@@ -56,5 +51,5 @@ def do_mpcdf_sync_projects(self, subcmd, opts, *args):
to_projects = None
mpcdf_common.sync_projects(api_url, package,
from_project=from_project, to_projects=to_projects, redo_all=opts.all,
from_project=from_project, to_projects=to_projects,
add_to_maintainers=not opts.private)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment