Skip to content
Snippets Groups Projects
Commit 2cf5b016 authored by Lukáš Krupčík's avatar Lukáš Krupčík
Browse files

Merge branch 'it4i-anselm'

parents be72a19f 0fb9c3b2
No related branches found
No related tags found
No related merge requests found
##
# Copyright 2009-2017 Ghent University
# Copyright 2009-2018 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
......@@ -8,7 +8,7 @@
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# http://github.com/hpcugent/easybuild
# https://github.com/easybuilders/easybuild
#
# EasyBuild is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -37,10 +37,12 @@ import os
import shutil
import stat
from distutils.version import LooseVersion
from easybuild.easyblocks.generic.packedbinary import PackedBinary
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import adjust_permissions, read_file, write_file
from easybuild.tools.filetools import adjust_permissions, change_dir, read_file, write_file
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import get_shared_lib_ext
......@@ -52,8 +54,7 @@ class EB_MATLAB(PackedBinary):
"""Add extra config options specific to MATLAB."""
super(EB_MATLAB, self).__init__(*args, **kwargs)
self.comp_fam = None
self.configfile1 = os.path.join(self.builddir, 'my_installer_input1.txt')
self.configfile2 = os.path.join(self.builddir, 'my_installer_input2.txt')
self.configfile = os.path.join(self.builddir, 'my_installer_input.txt')
@staticmethod
def extra_options():
......@@ -65,9 +66,18 @@ class EB_MATLAB(PackedBinary):
def configure_step(self):
"""Configure MATLAB installation: create license file."""
# create license file
licserv = self.cfg['license_server']
if licserv is None:
licserv = os.getenv('EB_MATLAB_LICENSE_SERVER', 'license.example.com')
licport = self.cfg['license_server_port']
if licport is None:
licport = os.getenv('EB_MATLAB_LICENSE_SERVER_PORT', '00000')
key = self.cfg['key']
if key is None:
key = os.getenv('EB_MATLAB_KEY', '00000-00000-00000-00000-00000-00000-00000-00000-00000-00000')
# create license file
lictxt = '\n'.join([
"SERVER %s 000000000000 %s" % (licserv, licport),
"USE_SERVER",
......@@ -77,10 +87,8 @@ class EB_MATLAB(PackedBinary):
write_file(licfile, lictxt)
try:
shutil.copyfile(os.path.join(self.cfg['start_dir'], 'installer_input.txt'), self.configfile1)
shutil.copyfile(os.path.join(self.cfg['start_dir'], 'installer_input.txt'), self.configfile2)
config1 = read_file(self.configfile1)
config2 = read_file(self.configfile2)
shutil.copyfile(os.path.join(self.cfg['start_dir'], 'installer_input.txt'), self.configfile)
config = read_file(self.configfile)
regdest = re.compile(r"^# destinationFolder=.*", re.M)
regkey = re.compile(r"^# fileInstallationKey=.*", re.M)
......@@ -88,28 +96,18 @@ class EB_MATLAB(PackedBinary):
regmode = re.compile(r"^# mode=.*", re.M)
reglicpath = re.compile(r"^# licensePath=.*", re.M)
config1 = regdest.sub("destinationFolder=%s" % self.installdir, config1)
key1 = self.cfg['exts_defaultclass']
config1 = regkey.sub("fileInstallationKey=%s" % key1, config1)
config1 = regagree.sub("agreeToLicense=Yes", config1)
config1 = regmode.sub("mode=silent", config1)
config1 = reglicpath.sub("licensePath=%s" % licfile, config1)
config2 = regdest.sub("destinationFolder=%s" % self.installdir, config2)
key2 = self.cfg['key']
config2 = regkey.sub("fileInstallationKey=%s" % key2, config2)
config2 = regagree.sub("agreeToLicense=Yes", config2)
config2 = regmode.sub("mode=silent", config2)
config2 = reglicpath.sub("licensePath=%s" % licfile, config2)
config = regdest.sub("destinationFolder=%s" % self.installdir, config)
config = regkey.sub("fileInstallationKey=%s" % key, config)
config = regagree.sub("agreeToLicense=Yes", config)
config = regmode.sub("mode=silent", config)
config = reglicpath.sub("licensePath=%s" % licfile, config)
write_file(self.configfile1, config1)
write_file(self.configfile2, config2)
write_file(self.configfile, config)
except IOError, err:
raise EasyBuildError("Failed to create installation config file %s: %s", self.configfile1, err)
raise EasyBuildError("Failed to create installation config file %s: %s", self.configfile, err)
self.log.debug('configuration file written to %s:\n %s', self.configfile1, config1)
self.log.debug('configuration file written to %s:\n %s', self.configfile2, config2)
self.log.debug('configuration file written to %s:\n %s', self.configfile, config)
def install_step(self):
"""MATLAB install procedure using 'install' command."""
......@@ -119,31 +117,45 @@ class EB_MATLAB(PackedBinary):
# make sure install script is executable
adjust_permissions(src, stat.S_IXUSR)
if LooseVersion(self.version) >= LooseVersion('2016b'):
jdir = os.path.join(self.cfg['start_dir'], 'sys', 'java', 'jre', 'glnxa64', 'jre', 'bin')
for perm_dir in [os.path.join(self.cfg['start_dir'], 'bin', 'glnxa64'), jdir]:
adjust_permissions(perm_dir, stat.S_IXUSR)
# make sure $DISPLAY is not defined, which may lead to (hard to trace) problems
# this is a workaround for not being able to specify --nodisplay to the install scripts
if 'DISPLAY' in os.environ:
os.environ.pop('DISPLAY')
if not '_JAVA_OPTIONS' in self.cfg['preinstallopts']:
self.cfg['preinstallopts'] = ('export _JAVA_OPTIONS="%s" && ' % self.cfg['java_options']) + self.cfg['preinstallopts']
cmd = "%s ./install -v -inputFile %s %s" % (self.cfg['preinstallopts'], self.configfile1, self.cfg['installopts'])
run_cmd(cmd, log_all=True, simple=True)
cmd = "%s ./install -v -inputFile %s %s" % (self.cfg['preinstallopts'], self.configfile2, self.cfg['installopts'])
run_cmd(cmd, log_all=True, simple=True)
if '_JAVA_OPTIONS' not in self.cfg['preinstallopts']:
java_opts = 'export _JAVA_OPTIONS="%s" && ' % self.cfg['java_options']
self.cfg['preinstallopts'] = java_opts + self.cfg['preinstallopts']
if LooseVersion(self.version) >= LooseVersion('2016b'):
change_dir(self.builddir)
cmd = "%s %s -v -inputFile %s %s" % (self.cfg['preinstallopts'], src, self.configfile, self.cfg['installopts'])
(out, _) = run_cmd(cmd, log_all=True, simple=False)
# check installer output for known signs of trouble
patterns = [
"Error: You have entered an invalid File Installation Key",
]
for pattern in patterns:
regex = re.compile(pattern, re.I)
if regex.search(out):
raise EasyBuildError("Found error pattern '%s' in output of installation command '%s': %s",
regex.pattern, cmd, out)
def sanity_check_step(self):
"""Custom sanity check for MATLAB."""
custom_paths = {
'files': ["bin/matlab"],
'dirs': ["java/jar", "toolbox/compiler"],
'dirs': ["java/jar"],
}
super(EB_MATLAB, self).sanity_check_step(custom_paths=custom_paths)
def make_module_extra(self):
"""Extend PATH and set proper _JAVA_OPTIONS (e.g., -Xmx)."""
java_path = os.environ.get('EBROOTJAVA')
java_path += '/jre'
txt = super(EB_MATLAB, self).make_module_extra()
txt += self.module_generator.set_environment('_JAVA_OPTIONS', self.cfg['java_options'])
txt += self.module_generator.set_environment('MATLAB_JAVA', java_path)
return txt
##
# Copyright 2009-2017 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# http://github.com/hpcugent/easybuild
#
# EasyBuild is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation v2.
#
# EasyBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>.
##
"""
EasyBuild support for installing MATLAB, implemented as an easyblock
@author: Stijn De Weirdt (Ghent University)
@author: Dries Verdegem (Ghent University)
@author: Kenneth Hoste (Ghent University)
@author: Pieter De Baets (Ghent University)
@author: Jens Timmerman (Ghent University)
@author: Fotis Georgatos (Uni.Lu, NTUA)
"""
import re
import os
import shutil
import stat
from easybuild.easyblocks.generic.packedbinary import PackedBinary
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.filetools import adjust_permissions, read_file, write_file
from easybuild.tools.run import run_cmd
from easybuild.tools.systemtools import get_shared_lib_ext
class EB_MATLAB(PackedBinary):
"""Support for installing MATLAB."""
def __init__(self, *args, **kwargs):
"""Add extra config options specific to MATLAB."""
super(EB_MATLAB, self).__init__(*args, **kwargs)
self.comp_fam = None
self.configfile1 = os.path.join(self.builddir, 'my_installer_input1.txt')
self.configfile2 = os.path.join(self.builddir, 'my_installer_input2.txt')
@staticmethod
def extra_options():
extra_vars = {
'java_options': ['-Xmx256m', "$_JAVA_OPTIONS value set for install and in module file.", CUSTOM],
}
return PackedBinary.extra_options(extra_vars)
def configure_step(self):
"""Configure MATLAB installation: create license file."""
# create license file
licserv = self.cfg['license_server']
licport = self.cfg['license_server_port']
lictxt = '\n'.join([
"SERVER %s 000000000000 %s" % (licserv, licport),
"USE_SERVER",
])
licfile = os.path.join(self.builddir, 'matlab.lic')
write_file(licfile, lictxt)
try:
shutil.copyfile(os.path.join(self.cfg['start_dir'], 'installer_input.txt'), self.configfile1)
shutil.copyfile(os.path.join(self.cfg['start_dir'], 'installer_input.txt'), self.configfile2)
config1 = read_file(self.configfile1)
config2 = read_file(self.configfile2)
regdest = re.compile(r"^# destinationFolder=.*", re.M)
regkey = re.compile(r"^# fileInstallationKey=.*", re.M)
regagree = re.compile(r"^# agreeToLicense=.*", re.M)
regmode = re.compile(r"^# mode=.*", re.M)
reglicpath = re.compile(r"^# licensePath=.*", re.M)
config1 = regdest.sub("destinationFolder=%s" % self.installdir, config1)
key1 = self.cfg['exts_defaultclass']
config1 = regkey.sub("fileInstallationKey=%s" % key1, config1)
config1 = regagree.sub("agreeToLicense=Yes", config1)
config1 = regmode.sub("mode=silent", config1)
config1 = reglicpath.sub("licensePath=%s" % licfile, config1)
config2 = regdest.sub("destinationFolder=%s" % self.installdir, config2)
key2 = self.cfg['key']
config2 = regkey.sub("fileInstallationKey=%s" % key2, config2)
config2 = regagree.sub("agreeToLicense=Yes", config2)
config2 = regmode.sub("mode=silent", config2)
config2 = reglicpath.sub("licensePath=%s" % licfile, config2)
write_file(self.configfile1, config1)
write_file(self.configfile2, config2)
except IOError, err:
raise EasyBuildError("Failed to create installation config file %s: %s", self.configfile1, err)
self.log.debug('configuration file written to %s:\n %s', self.configfile1, config1)
self.log.debug('configuration file written to %s:\n %s', self.configfile2, config2)
def install_step(self):
"""MATLAB install procedure using 'install' command."""
src = os.path.join(self.cfg['start_dir'], 'install')
# make sure install script is executable
adjust_permissions(src, stat.S_IXUSR)
# make sure $DISPLAY is not defined, which may lead to (hard to trace) problems
# this is a workaround for not being able to specify --nodisplay to the install scripts
if 'DISPLAY' in os.environ:
os.environ.pop('DISPLAY')
if not '_JAVA_OPTIONS' in self.cfg['preinstallopts']:
self.cfg['preinstallopts'] = ('export _JAVA_OPTIONS="%s" && ' % self.cfg['java_options']) + self.cfg['preinstallopts']
cmd = "%s ./install -v -inputFile %s %s" % (self.cfg['preinstallopts'], self.configfile1, self.cfg['installopts'])
run_cmd(cmd, log_all=True, simple=True)
cmd = "%s ./install -v -inputFile %s %s" % (self.cfg['preinstallopts'], self.configfile2, self.cfg['installopts'])
run_cmd(cmd, log_all=True, simple=True)
def sanity_check_step(self):
"""Custom sanity check for MATLAB."""
custom_paths = {
'files': ["bin/matlab"],
'dirs': ["java/jar", "toolbox/compiler"],
}
super(EB_MATLAB, self).sanity_check_step(custom_paths=custom_paths)
def make_module_extra(self):
"""Extend PATH and set proper _JAVA_OPTIONS (e.g., -Xmx)."""
java_path = os.environ.get('EBROOTJAVA')
java_path += '/jre'
txt = super(EB_MATLAB, self).make_module_extra()
txt += self.module_generator.set_environment('_JAVA_OPTIONS', self.cfg['java_options'])
txt += self.module_generator.set_environment('MATLAB_JAVA', java_path)
return txt
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment