Commit 5ef9a048 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Option to temporarily disable repos in mpcdf_setup_repos

parent f6e781d4
......@@ -142,10 +142,13 @@ def remove_attribute(api_url, project, package, attribute_name):
raise osc.oscerr.APIError("Could not remove attribute")
def mpcdf_enable_repositories(api_url, project, package, verbose=False):
def mpcdf_enable_repositories(api_url, project, package, verbose=False, filter_repos=None):
from itertools import product
import sys
if filter_repos is None:
filter_repos = ()
root = ElementTree.fromstringlist(osc.core.show_package_meta(api_url, project, package))
build = root.find("./build")
if build is None:
......@@ -178,6 +181,8 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False):
default_cudas = try_get_attribute(None, "default_cuda")
def enable(name):
if any(filtered_repo in name for filtered_repo in filter_repos):
return
node = ElementTree.Element("enable")
node.set("repository", name)
node.tail = "\n "
......@@ -251,7 +256,7 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False):
return True
def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, packages=None, dry_run=False):
def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, packages=None, dry_run=False, filter_repos=None):
if parent:
for attribute in ["compiler_modules", "default_compiler", "mpi_modules", "default_mpi", "cuda_modules", "default_cuda"]:
print("Copying attribute 'MPCDF:{0}' from parent project".format(attribute))
......@@ -400,7 +405,7 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p
packages = osc.core.meta_get_packagelist(api_url, project)
for package in packages:
print("Updating repositories for", package)
if not mpcdf_enable_repositories(api_url, project, package):
if not mpcdf_enable_repositories(api_url, project, package, filter_repos=filter_repos):
print("ATTENTION: Not changing unmanaged package {0}".format(package))
# Update repositories
......
......@@ -16,6 +16,8 @@ import osc.cmdln
help="Setup the repositories to be based on the upstream project PARENT (e.g. for home: projects)")
@osc.cmdln.option('--distribution',
help="Base distribution, necessary argument unless set previously for this project")
@osc.cmdln.option('--disable-repo', metavar="REPO", action="append",
help="Temporarily disable all repositories containing REPO")
@osc.cmdln.alias("mpcdf_setup_repos")
def do_mpcdf_setup_repositories(self, subcmd, opts, *args):
"""${cmd_name}: Create all repository combinations for an MPCDF project
......@@ -41,4 +43,4 @@ def do_mpcdf_setup_repositories(self, subcmd, opts, *args):
else:
raise osc.oscerr.WrongArgs("Too many arguments")
mpcdf_setup_repositories(self.get_api_url(), project, opts.distribution, parent=opts.parent, dry_run=opts.dry_run)
mpcdf_setup_repositories(self.get_api_url(), project, opts.distribution, parent=opts.parent, dry_run=opts.dry_run, filter_repos=opts.disable_repo)
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