From ae5ce9e2ebc4c122423ad26b5bba1d5664aac8cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lorenz=20H=C3=BCdepohl?= <dev@stellardeath.org>
Date: Tue, 26 Oct 2021 17:47:30 +0200
Subject: [PATCH] Fix %microarchitecture macro in home: projects

It was incorrectly set also set for the "System" repository there, which
caused software there to be built incorrectly (with the micro arch
flags) and in the wrong location
---
 mpcdf_common.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/mpcdf_common.py b/mpcdf_common.py
index 195f310..7a7430e 100644
--- a/mpcdf_common.py
+++ b/mpcdf_common.py
@@ -656,11 +656,13 @@ def mpcdf_setup_subproject(api_url, project, distribution, microarchitecture,
         prjconf_ours.append(extra_tags)
     extra_macros = dist_prjconf_macros(distribution)
 
+    if not project.startswith("home:"):
+        extra_macros = "%microarchitecture {0}\n{1}".format(microarchitecture, extra_macros)
+
     prjconf_ours.append("""
 Macros:
-%microarchitecture {0}
-{1}
-:Macros""".format(microarchitecture, extra_macros))
+{0}
+:Macros""".format(extra_macros))
     prjconf_ours.append("")
 
     # Remove existing repositories
@@ -694,6 +696,7 @@ Macros:
             p.set("repository", repo)
             p.tail = "\n    "
 
+        # TODO: Order inverted here?
         for dep_project, dep_repo in dependencies:
             path(dep_project, dep_repo)
         if parent and name != "System":
@@ -718,6 +721,8 @@ Macros:
             repoconf.append(tag)
 
         repoconf.append("Macros:")
+        if project.startswith("home:") and name != "System":
+            repoconf.append("%microarchitecture {0}".format(microarchitecture))
 
         repoconf.append("%is_compiler_repository {0}".format(1 if compiler else 0))
         repoconf.append("%is_mpi_repository {0}".format(1 if mpi else 0))
-- 
GitLab