Skip to content

Commit

Permalink
config.guess change code from easybuilders#1938
Browse files Browse the repository at this point in the history
  • Loading branch information
edmondac committed Jan 23, 2020
1 parent 2af53f4 commit ececb3b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
13 changes: 11 additions & 2 deletions easybuild/easyblocks/generic/configuremake.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
# Copyright 2009-2019 Ghent University
# Copyright 2009-2020 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
Expand Down Expand Up @@ -147,7 +147,12 @@ def obtain_config_guess(self, download_source_path=None, search_source_paths=Non
return config_guess_path

def check_config_guess(self):
"""Check timestamp & SHA256 checksum of config.guess script."""
"""
Check timestamp & SHA256 checksum of config.guess script.
Returns True if ok (or there is no config.guess for this package) and False if it's too old
or doesn't match the checksum.
"""
# log version, timestamp & SHA256 checksum of config.guess that was found (if any)
if self.config_guess:
# config.guess includes a "timestamp='...'" indicating the version
Expand All @@ -170,10 +175,14 @@ def check_config_guess(self):
if config_guess_version != CONFIG_GUESS_VERSION:
tup = (self.config_guess, config_guess_version, CONFIG_GUESS_VERSION)
print_warning("config.guess version at %s does not match expected version: %s vs %s" % tup)
return False

if config_guess_checksum != CONFIG_GUESS_SHA256:
tup = (self.config_guess, config_guess_checksum, CONFIG_GUESS_SHA256)
print_warning("SHA256 checksum of config.guess at %s does not match expected checksum: %s vs %s" % tup)
return False

return True

def fetch_step(self, *args, **kwargs):
"""Custom fetch step for ConfigureMake so we use an updated config.guess."""
Expand Down
22 changes: 18 additions & 4 deletions easybuild/easyblocks/generic/rpackage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##
# Copyright 2009-2019 Ghent University
# Copyright 2009-2020 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
Expand Down Expand Up @@ -39,8 +39,10 @@
from easybuild.framework.easyconfig import CUSTOM
from easybuild.framework.extensioneasyblock import ExtensionEasyBlock
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import mkdir
from easybuild.tools.filetools import mkdir, copy_file
from easybuild.tools.run import run_cmd, parse_log_for_error
from easybuild.easyblocks.generic.configuremake import ConfigureMake
from easybuild.tools.build_log import print_warning


def make_R_install_option(opt, values, cmdline=False):
Expand Down Expand Up @@ -74,6 +76,7 @@ def extra_options(extra_vars=None):
extra_vars.update({
'exts_subdir': ['', "Subdirectory where R extensions should be installed info", CUSTOM],
'unpack_sources': [False, "Unpack sources before installation", CUSTOM],
'update_config_guess': [False, "Update the config.guess file(s) in this package", CUSTOM],
})
return extra_vars

Expand Down Expand Up @@ -134,7 +137,7 @@ def make_cmdline_cmd(self, prefix=None):

if self.cfg['unpack_sources']:
loc = self.start_dir
elif self.patches:
elif self.patches or self.cfg['update_config_guess']:
loc = self.ext_dir
else:
loc = self.ext_src
Expand Down Expand Up @@ -215,11 +218,22 @@ def run(self):
lib_install_prefix = os.path.join(self.installdir, self.cfg['exts_subdir'])
mkdir(lib_install_prefix, parents=True)

if self.patches:
if self.patches or self.cfg['update_config_guess']:
super(RPackage, self).run(unpack_src=True)
else:
super(RPackage, self).run()

if self.cfg['update_config_guess']:
confmake = ConfigureMake(self.cfg)
for root, _, files in os.walk(self.builddir):
for name in files:
if name == 'config.guess':
confmake.config_guess = os.path.join(root, name)
if not confmake.check_config_guess():
updated = confmake.obtain_config_guess()
print_warning("Using updated config.guess for %s", confmake.config_guess)
copy_file(updated, confmake.config_guess)

if self.src:
self.ext_src = self.src
self.log.debug("Installing R package %s version %s." % (self.name, self.version))
Expand Down

0 comments on commit ececb3b

Please sign in to comment.