From 57b647aae574c73194e645ee6043bc6bd6be216f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Thu, 23 Jan 2025 15:53:28 +0100 Subject: [PATCH 1/2] raise error when install dir contains files but keeppreviousinstall is set --- eb_hooks.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/eb_hooks.py b/eb_hooks.py index 08eb5ea62e..470458d265 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -9,7 +9,7 @@ from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS from easybuild.tools.build_log import EasyBuildError, print_msg from easybuild.tools.config import build_option, update_build_option -from easybuild.tools.filetools import apply_regex_substitutions, copy_file, remove_file, symlink, which +from easybuild.tools.filetools import apply_regex_substitutions, copy_file, dir_contains_files, remove_file, symlink, which from easybuild.tools.run import run_cmd from easybuild.tools.systemtools import AARCH64, POWER, X86_64, get_cpu_architecture, get_cpu_features from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC @@ -450,6 +450,16 @@ def pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs): print_msg("Updated build option 'force' to 'True'") +def pre_install_hook(self, *args, **kwargs): + """Main pre install hook: trigger custom functions based on software name.""" + if 'keeppreviousinstall' in self.cfg and self.cfg['keeppreviousinstall']: + if dir_contains_files(self.installdir, recursive=True): + raise EasyBuildError("Parameter keeppreviousinstall is set to True, but the installation directory still contains files!") + + if self.name in PRE_INSTALL_HOOKS: + PRE_INSTALL_HOOKS[ec.name](self, *args, **kwargs) + + def post_module_hook_zen4_gcccore1220(self, *args, **kwargs): """Revert changes from pre_fetch_hook_zen4_gcccore1220""" if is_gcccore_1220_based(ecname=self.name, ecversion=self.version, tcname=self.toolchain.name, @@ -1149,6 +1159,8 @@ def post_module_hook(self, *args, **kwargs): 'Score-P': pre_configure_hook_score_p, } +PRE_INSTALL_HOOKS = {} + PRE_TEST_HOOKS = { 'ESPResSo': pre_test_hook_ignore_failing_tests_ESPResSo, 'FFTW.MPI': pre_test_hook_ignore_failing_tests_FFTWMPI, From cc79fd7f1ab09e6857f4c894f1d2c69ded67e365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 24 Jan 2025 13:10:40 +0100 Subject: [PATCH 2/2] add comment about keeppreviousinstall parameter/check --- eb_hooks.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/eb_hooks.py b/eb_hooks.py index 470458d265..950b3e06bd 100644 --- a/eb_hooks.py +++ b/eb_hooks.py @@ -452,6 +452,12 @@ def pre_fetch_hook_zen4_gcccore1220(self, *args, **kwargs): def pre_install_hook(self, *args, **kwargs): """Main pre install hook: trigger custom functions based on software name.""" + + # To work around a permission issue fo rebuilds (see https://github.com/EESSI/software-layer/issues/556), + # a solution was implemented (see https://github.com/EESSI/software-layer/issues/556) + # that removes the existing installation directory, creates a new one (with some empty top-level subdirs), + # and calls EasyBuild with --try-amend=keeppreviousinstall=True (to prevent it from removing it and recreating it once again). + # To be sure, we check here if this parameter is used, and if so, if the directory really does not contain any files anymore. if 'keeppreviousinstall' in self.cfg and self.cfg['keeppreviousinstall']: if dir_contains_files(self.installdir, recursive=True): raise EasyBuildError("Parameter keeppreviousinstall is set to True, but the installation directory still contains files!")