From 2771ec9bbfa74c6f9f7022b1a9d13acdad6e27ec Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Tue, 19 Sep 2017 21:55:17 +0200 Subject: [PATCH 1/4] add symlinks for cc/c++/f77/f95 in post_install step of GCC easyblock + enhance sanity check --- easybuild/easyblocks/g/gcc.py | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/easybuild/easyblocks/g/gcc.py b/easybuild/easyblocks/g/gcc.py index 7550e085f3..8e742ba512 100644 --- a/easybuild/easyblocks/g/gcc.py +++ b/easybuild/easyblocks/g/gcc.py @@ -45,10 +45,11 @@ from easybuild.easyblocks.generic.configuremake import ConfigureMake from easybuild.framework.easyconfig import CUSTOM from easybuild.tools.build_log import EasyBuildError -from easybuild.tools.filetools import write_file +from easybuild.tools.filetools import change_dir, symlink, write_file from easybuild.tools.modules import get_software_root from easybuild.tools.run import run_cmd -from easybuild.tools.systemtools import check_os_dependency, get_os_name, get_os_type, get_shared_lib_ext, get_platform_name +from easybuild.tools.systemtools import check_os_dependency, get_os_name, get_os_type, get_platform_name +from easybuild.tools.systemtools import get_shared_lib_ext class EB_GCC(ConfigureMake): @@ -507,6 +508,32 @@ def build_step(self): # make install is just standard install_step, nothing special there + def post_install_step(self, *args, **kwargs): + """ + Post-processing after installation: add symlinks for cc, c++, f77, f95 + """ + super(EB_GCC, self).post_install_step(*args, **kwargs) + + comp_cmd_symlinks = { + 'cc': 'gcc', + 'c++': 'g++', + 'f77': 'gfortran', + 'f95': 'gfortran', + } + bindir = os.path.join(self.installdir, 'bin') + cwd = change_dir(bindir) + for key in comp_cmd_symlinks: + src = os.path.join(bindir, comp_cmd_symlinks[key]) + target = os.path.join(bindir, key) + if os.path.exists(target): + self.log.info("'%s' already exists in %s, not replacing it with symlink to '%s'", + key, bindir, os.path.basename(src)) + elif os.path.exists(src): + symlink(os.path.basename(src), key) + else: + raise EasyBuildError("Can't link '%s' to non-existing location %s", target, src) + change_dir(cwd) + def sanity_check_step(self): """ Custom sanity check for GCC @@ -570,8 +597,10 @@ def sanity_check_step(self): libdirs = ['libexec', 'lib'] libexec_files = [tuple([os.path.join(libdir, common_infix, x) for libdir in libdirs]) for x in libexec_files] + old_cmds = [os.path.join('bin', x) for x in ['cc', 'c++', 'f77', 'f95']] + custom_paths = { - 'files': bin_files + lib_files + libexec_files, + 'files': bin_files + lib_files + libexec_files + old_cmds, 'dirs': dirs, } From e0bb6fb368892b6944022674ab92a02f4adf20c3 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Tue, 19 Sep 2017 22:07:39 +0200 Subject: [PATCH 2/4] don't use absolute path when symlinking cc (& co) to gcc (& co) --- easybuild/easyblocks/g/gcc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/g/gcc.py b/easybuild/easyblocks/g/gcc.py index 8e742ba512..a1e70806d9 100644 --- a/easybuild/easyblocks/g/gcc.py +++ b/easybuild/easyblocks/g/gcc.py @@ -529,7 +529,7 @@ def post_install_step(self, *args, **kwargs): self.log.info("'%s' already exists in %s, not replacing it with symlink to '%s'", key, bindir, os.path.basename(src)) elif os.path.exists(src): - symlink(os.path.basename(src), key) + symlink(os.path.basename(src), key, use_abspath_source=False) else: raise EasyBuildError("Can't link '%s' to non-existing location %s", target, src) change_dir(cwd) From a995b76584512d78789f618e0247fbbd9f152c77 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 20 Sep 2017 15:33:36 +0200 Subject: [PATCH 3/4] avoid cd'ing into /bin to create cc & co symlinks for GCC --- easybuild/easyblocks/g/gcc.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/easybuild/easyblocks/g/gcc.py b/easybuild/easyblocks/g/gcc.py index a1e70806d9..5b87f429a9 100644 --- a/easybuild/easyblocks/g/gcc.py +++ b/easybuild/easyblocks/g/gcc.py @@ -45,7 +45,7 @@ from easybuild.easyblocks.generic.configuremake import ConfigureMake from easybuild.framework.easyconfig import CUSTOM from easybuild.tools.build_log import EasyBuildError -from easybuild.tools.filetools import change_dir, symlink, write_file +from easybuild.tools.filetools import symlink, write_file from easybuild.tools.modules import get_software_root from easybuild.tools.run import run_cmd from easybuild.tools.systemtools import check_os_dependency, get_os_name, get_os_type, get_platform_name @@ -521,18 +521,16 @@ def post_install_step(self, *args, **kwargs): 'f95': 'gfortran', } bindir = os.path.join(self.installdir, 'bin') - cwd = change_dir(bindir) for key in comp_cmd_symlinks: - src = os.path.join(bindir, comp_cmd_symlinks[key]) + src = comp_cmd_symlinks[key] target = os.path.join(bindir, key) if os.path.exists(target): self.log.info("'%s' already exists in %s, not replacing it with symlink to '%s'", - key, bindir, os.path.basename(src)) - elif os.path.exists(src): - symlink(os.path.basename(src), key, use_abspath_source=False) + key, bindir, src) + elif os.path.exists(os.path.join(bindir, src)): + symlink(src, target, use_abspath_source=False) else: - raise EasyBuildError("Can't link '%s' to non-existing location %s", target, src) - change_dir(cwd) + raise EasyBuildError("Can't link '%s' to non-existing location %s", target, os.path.join(bindir, src)) def sanity_check_step(self): """ From 33beb7b5d59122a8be9a9eee180987c459549156 Mon Sep 17 00:00:00 2001 From: Kenneth Hoste Date: Wed, 20 Sep 2017 16:30:38 +0200 Subject: [PATCH 4/4] use global constant for symlink commands in GCC easyblock --- easybuild/easyblocks/g/gcc.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/easybuild/easyblocks/g/gcc.py b/easybuild/easyblocks/g/gcc.py index 5b87f429a9..6d5e6824af 100644 --- a/easybuild/easyblocks/g/gcc.py +++ b/easybuild/easyblocks/g/gcc.py @@ -52,6 +52,14 @@ from easybuild.tools.systemtools import get_shared_lib_ext +COMP_CMD_SYMLINKS = { + 'cc': 'gcc', + 'c++': 'g++', + 'f77': 'gfortran', + 'f95': 'gfortran', +} + + class EB_GCC(ConfigureMake): """ Self-contained build of GCC. @@ -514,15 +522,9 @@ def post_install_step(self, *args, **kwargs): """ super(EB_GCC, self).post_install_step(*args, **kwargs) - comp_cmd_symlinks = { - 'cc': 'gcc', - 'c++': 'g++', - 'f77': 'gfortran', - 'f95': 'gfortran', - } bindir = os.path.join(self.installdir, 'bin') - for key in comp_cmd_symlinks: - src = comp_cmd_symlinks[key] + for key in COMP_CMD_SYMLINKS: + src = COMP_CMD_SYMLINKS[key] target = os.path.join(bindir, key) if os.path.exists(target): self.log.info("'%s' already exists in %s, not replacing it with symlink to '%s'", @@ -595,7 +597,7 @@ def sanity_check_step(self): libdirs = ['libexec', 'lib'] libexec_files = [tuple([os.path.join(libdir, common_infix, x) for libdir in libdirs]) for x in libexec_files] - old_cmds = [os.path.join('bin', x) for x in ['cc', 'c++', 'f77', 'f95']] + old_cmds = [os.path.join('bin', x) for x in COMP_CMD_SYMLINKS.keys()] custom_paths = { 'files': bin_files + lib_files + libexec_files + old_cmds,