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

Add --dry-run option to mpcdf_enable_repositories

parent 97c2a119
......@@ -358,9 +358,8 @@ def package_sort_key(string):
return (name,) + tuple(map(int, version))
def mpcdf_enable_repositories(api_url, project, package, verbose=False, ignore_repos=()):
def mpcdf_enable_repositories(api_url, project, package, verbose=False, dry_run=False, ignore_repos=()):
from itertools import product
import sys
pkg_meta = osc.core.show_package_meta(api_url, project, package)
root = ElementTree.fromstringlist(pkg_meta)
......@@ -494,7 +493,12 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False, ignore_r
new_pkg_meta = ElementTree.tostring(root, encoding=osc.core.ET_ENCODING)
if pkg_meta != new_pkg_meta:
print("Updating repositories for", package)
osc.core.edit_meta("pkg", (project, package), data=new_pkg_meta)
if dry_run:
print("osc meta pkg {0} {1} -F - <<EOF\n{2}\nEOF\n".format(project, package, new_pkg_meta))
osc.core.edit_meta("pkg", (project, package), data=new_pkg_meta)
elif dry_run:
print("Would not do anything, package meta would be unchanged")
return True
......@@ -10,6 +10,8 @@ import osc.core
import osc.cmdln
@osc.cmdln.option('-n', '--dry-run', action="store_true",
help="Do not actually perform any changes but print what would be stored")
@osc.cmdln.option('--recreate', action="store_true",
help="Re-create the set of enabled repositories from the stored attributes on the server")
@osc.cmdln.option('--compiler-modules', nargs=1,
......@@ -89,8 +91,8 @@ def do_mpcdf_enable_repositories(self, subcmd, opts, *args):
set_or_remove(opts.pgi_modules, "MPCDF:pgi_modules")
if opts.recreate or opts.set or opts.disable:
mpcdf_common.mpcdf_enable_repositories(api_url, project, package, verbose=True)
if project == "software" and opts.set != "system":
mpcdf_common.mpcdf_enable_repositories(api_url, project, package, verbose=True, dry_run=opts.dry_run)
if project == "software" and opts.set != "system" and not opts.dry_run:
mpcdf_common.sync_projects(api_url, package, verbose=True)
elif (opts.compiler_modules or opts.mpi_modules or opts.cuda_modules):
Supports Markdown
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