diff --git a/eb_hooks.py b/eb_hooks.py index 08eb5ea62e..950b3e06bd 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,22 @@ 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.""" + + # 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!") + + 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 +1165,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,