From 67b7676d3fa6ce56255d837db9ce32409ce57eb5 Mon Sep 17 00:00:00 2001
From: Sebastian Achilles <s.achilles@fz-juelich.de>
Date: Tue, 14 Dec 2021 17:04:49 +0100
Subject: [PATCH] Hook: Add Lmod conflict for side compilers

---
 Custom_Hooks/eb_hooks.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Custom_Hooks/eb_hooks.py b/Custom_Hooks/eb_hooks.py
index d22b53ee2..9cbe59156 100644
--- a/Custom_Hooks/eb_hooks.py
+++ b/Custom_Hooks/eb_hooks.py
@@ -236,6 +236,8 @@ def parse_hook(ec, *args, **kwargs):
 
     ec = tweak_moduleclass(ec)
 
+    ec = tweak_module_conflict_side_compilers(ec)
+
     # If we are parsing we are not searching, in this case if the easyconfig is
     # located in the search path, warn that it's dependencies will (most probably)
     # not be resolved
@@ -295,6 +297,21 @@ def tweak_moduleclass(ec):
     return ec
 
 
+def tweak_module_conflict_side_compilers(ec):
+    if ec['name'] in SIDECOMPILERS:
+        key = "modluafooter"
+        value = 'conflict(%s)' % ','.join('"'+x+'"' for x in SIDECOMPILERS)
+        if key in ec_dict:
+            if not value in ec_dict[key]:
+                ec[key] = "\n".join([ec_dict[key], value])
+        else:
+            ec[key] = value
+        ec.log.info(
+            "[parse hook] Injecting Lmod conflict property for SIDECOMPILERS")
+
+    return ec
+
+
 def inject_site_contact_and_user_labels(ec):
     ec_dict = ec.asdict()
     # Check where installations are going to go and add appropriate site contact
-- 
GitLab