Commit 6f68b305 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Automatically set microarchitecture in prjconf in mpcdf_setup_repositories

parent 4457c854
......@@ -9,6 +9,8 @@ from osc.util.helper import decode_it
from functools import partial
from xml.etree import ElementTree
known_microarchs = {"sandybridge", "haswell", "skylake"}
package_attributes = ["MPCDF:enable_repositories"]
config_attributes = ["MPCDF:compiler_modules", "MPCDF:cuda_modules", "MPCDF:mpi_modules", "MPCDF:pgi_modules"]
default_attributes = ["MPCDF:default_compiler", "MPCDF:default_cuda", "MPCDF:default_mpi", "MPCDF:default_python2", "MPCDF:default_python3"]
......@@ -204,6 +206,19 @@ def remove_attribute(api_url, project, package, attribute_name):
raise osc.oscerr.APIError("Could not remove attribute")
def get_microarchitecture(project):
if project == "software":
# Stupid special case
microarch = "sandybridge"
else:
microarch = project.split(":")[2]
if microarch in known_microarchs:
return microarch
else:
raise Exception("Unknown micro-architecture '{0}'".format(microarch))
def mpcdf_enable_repositories(api_url, project, package, verbose=False, filter_repos=None):
from itertools import product
import sys
......@@ -343,7 +358,8 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False, filter_r
return True
def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, packages=None, dry_run=False, filter_repos=None, only_project=False, remove_old=False):
def mpcdf_setup_repositories(api_url, project, microarchitecture=None, distribution=None, parent=None,
packages=None, dry_run=False, filter_repos=None, only_project=False, remove_old=False):
import threading
if parent:
......@@ -374,6 +390,9 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p
raise osc.oscerr.WrongArgs("No repository '{0}' is defined in project 'distributions' on the server".format(distribution))
architectures = list(arch.text for arch in dist_repo.findall("./arch"))
if microarchitecture is None:
microarchitecture = get_microarchitecture(project)
root = project_meta(api_url, project)
prjconf = list(map(decode_it, osc.core.show_project_conf(api_url, project)))
......@@ -391,6 +410,15 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p
prjconf_tail = "".join(prjconf[end + 1:])
prjconf = [start_marker]
prjconf.append("Constraint: hostlabel {0}".format(microarchitecture))
prjconf.append(
"""
%if %_repository != System
Macros:
%microarchitecture {0}
:Macros
%endif""".format(microarchitecture))
prjconf.append("")
prjconf.append("Prefer: mpcdf_python2_" + default_python2)
prjconf.append("Prefer: mpcdf_python3_" + default_python3)
prjconf.append("")
......@@ -653,7 +681,7 @@ def sync_projects(api_url, package=None, from_project="software", to_projects=No
distribution = sys_repo.find('./path[@project="distributions"]').get("repository")
print("Creating repository configuration")
mpcdf_setup_repositories(api_url, to_project, distribution)
mpcdf_setup_repositories(api_url, to_project, distribution=distribution)
else:
for orig_package in from_packages:
if not mpcdf_enable_repositories(api_url, to_project, orig_package):
......
......@@ -22,6 +22,8 @@ import osc.cmdln
help="Only change project metadata 'prj' and 'prjconf', leave individual packages unchanged")
@osc.cmdln.option('--remove-old', action="store_true", default=False,
help="Remove all obsolete repositories instead of only disabling builds for packages there")
@osc.cmdln.option('--microarchitecture', metavar="ARCH", nargs=1,
help="Configure project to use ARCH as microarchitecture")
@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
......@@ -48,6 +50,6 @@ def do_mpcdf_setup_repositories(self, subcmd, opts, *args):
raise osc.oscerr.WrongArgs("Too many arguments")
mpcdf_setup_repositories(self.get_api_url(),
project, opts.distribution,
project, microarchitecture=opts.microarchitecture, distribution=opts.distribution,
parent=opts.parent, dry_run=opts.dry_run, filter_repos=opts.disable_repo,
only_project=opts.only_project, remove_old=opts.remove_old)
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