Skip to content
Snippets Groups Projects
Commit 8ee5d62f authored by Lorenz Hüdepohl's avatar Lorenz Hüdepohl
Browse files

Option '--remove-old-matching' for subproject setup

parent 0267c7fc
No related branches found
No related tags found
No related merge requests found
...@@ -611,7 +611,8 @@ def parse_prjconf(api_url, project): ...@@ -611,7 +611,8 @@ def parse_prjconf(api_url, project):
def mpcdf_setup_subproject(api_url, project, distribution, microarchitecture, def mpcdf_setup_subproject(api_url, project, distribution, microarchitecture,
parent=None, dry_run=False, diff=False, remove_old=False, all_possible=False, only_project=False): parent=None, dry_run=False, diff=False, remove_old=False, remove_old_matching=None, all_possible=False, only_project=False):
import re
if parent and not dry_run: if parent and not dry_run:
for attribute in config_attributes: for attribute in config_attributes:
...@@ -666,6 +667,10 @@ Macros: ...@@ -666,6 +667,10 @@ Macros:
if remove_old: if remove_old:
for oldrepo in root.findall("./repository"): for oldrepo in root.findall("./repository"):
root.remove(oldrepo) root.remove(oldrepo)
if remove_old_matching:
for oldrepo in root.findall("./repository"):
if re.search(remove_old_matching, oldrepo.attrib["name"]):
root.remove(oldrepo)
def repo(name, dependencies, compiler=False, mpi=False, cuda=False, cuda_mpi=False, cuda_aware_mpi=False, additional_tags=(), **macros): def repo(name, dependencies, compiler=False, mpi=False, cuda=False, cuda_mpi=False, cuda_aware_mpi=False, additional_tags=(), **macros):
old_repos.discard(name) old_repos.discard(name)
... ...
......
...@@ -13,6 +13,8 @@ import osc.cmdln ...@@ -13,6 +13,8 @@ import osc.cmdln
help="Do not actually run anything but output the resulting XML configuration") help="Do not actually run anything but output the resulting XML configuration")
@osc.cmdln.option('--remove-old', action="store_true", default=False, @osc.cmdln.option('--remove-old', action="store_true", default=False,
help="Remove all obsolete repositories instead of only disabling builds for packages there") help="Remove all obsolete repositories instead of only disabling builds for packages there")
@osc.cmdln.option('--remove-old-matching', default=None,
help="Remove all obsolete repositories matching this regular expression")
@osc.cmdln.option('--distribution', metavar="DIST", nargs=1, @osc.cmdln.option('--distribution', metavar="DIST", nargs=1,
help="Base distribution, necessary argument unless set previously for this project. " help="Base distribution, necessary argument unless set previously for this project. "
"Valid arguments are the names of any repository in the 'software' project.") "Valid arguments are the names of any repository in the 'software' project.")
...@@ -78,4 +80,7 @@ def do_mpcdf_setup_home_project(self, subcmd, opts, *args): ...@@ -78,4 +80,7 @@ def do_mpcdf_setup_home_project(self, subcmd, opts, *args):
mpcdf_setup_subproject(api_url, mpcdf_setup_subproject(api_url,
project, distribution, microarchitecture, project, distribution, microarchitecture,
parent=parent, dry_run=opts.dry_run, remove_old=opts.remove_old) parent=parent,
dry_run=opts.dry_run, diff=opts.diff,
remove_old=opts.remove_old, remove_old_matching=opts.remove_old_matching,
only_project=opts.only_project)
...@@ -17,6 +17,8 @@ import osc.cmdln ...@@ -17,6 +17,8 @@ import osc.cmdln
help="Only change project metadata, do not iterate over packages and change their enabled repositories") help="Only change project metadata, do not iterate over packages and change their enabled repositories")
@osc.cmdln.option('--remove-old', action="store_true", default=False, @osc.cmdln.option('--remove-old', action="store_true", default=False,
help="Remove all obsolete repositories instead of only disabling builds for packages there") help="Remove all obsolete repositories instead of only disabling builds for packages there")
@osc.cmdln.option('--remove-old-matching', default=None,
help="Remove all obsolete repositories matching this regular expression")
@osc.cmdln.alias("mpcdf_setup_sub") @osc.cmdln.alias("mpcdf_setup_sub")
def do_mpcdf_setup_subproject(self, subcmd, opts, *args): def do_mpcdf_setup_subproject(self, subcmd, opts, *args):
"""${cmd_name}: Setup a software: sub-project """${cmd_name}: Setup a software: sub-project
...@@ -53,4 +55,6 @@ def do_mpcdf_setup_subproject(self, subcmd, opts, *args): ...@@ -53,4 +55,6 @@ def do_mpcdf_setup_subproject(self, subcmd, opts, *args):
mpcdf_setup_subproject(self.get_api_url(), mpcdf_setup_subproject(self.get_api_url(),
project, distribution, microarchitecture, project, distribution, microarchitecture,
dry_run=opts.dry_run, diff=opts.diff, remove_old=opts.remove_old, only_project=opts.only_project) dry_run=opts.dry_run, diff=opts.diff,
remove_old=opts.remove_old, remove_old_matching=opts.remove_old_matching,
only_project=opts.only_project)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment