diff --git a/SConstruct b/SConstruct index 70560f754..2c4a2a088 100644 --- a/SConstruct +++ b/SConstruct @@ -49,13 +49,38 @@ import os import subprocess import sys import textwrap +import time import SCons.Action sys.path.append(os.path.join('src', 'beast', 'site_scons')) import Beast -#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------ + +def parse_time(t): + return time.strptime(t, '%a %b %d %H:%M:%S %Z %Y') + +CHECK_PLATFORMS = 'Darwin', 'Debian', 'Ubuntu' +CHECK_COMMAND = 'openssl version -a' +CHECK_LINE = 'built on: ' +BUILD_TIME = 'Mon Apr 7 20:33:19 UTC 2014' +OPENSSL_ERROR = ('Your openSSL was built on %s; ' + 'rippled needs a version built on or after %s.') + +def check_openssl(): + if Beast.system.platform in CHECK_PLATFORMS: + for line in subprocess.check_output(CHECK_COMMAND.split()).splitlines(): + if line.startswith(CHECK_LINE): + line = line[len(CHECK_LINE):] + if parse_time(line) < parse_time(BUILD_TIME): + raise Exception(OPENSSL_ERROR % (line, BUILD_TIME)) + else: + break + else: + raise Exception("Didn't find any '%s' line in '$ %s'" % + (CHECK_LINE, CHECK_COMMAND)) + def import_environ(env): '''Imports environment settings into the construction environment''' @@ -187,6 +212,8 @@ def config_base(env): CXXCOMSTR='Compiling ' + Beast.blue('$SOURCES'), LINKCOMSTR='Linking ' + Beast.blue('$TARGET'), ) + check_openssl() + #git = Beast.Git(env) # TODO(TOM) if False: #git.exists: env.Append(CPPDEFINES={'GIT_COMMIT_ID' : '"%s"' % git.commit_id}) diff --git a/src/beast/site_scons/Beast.py b/src/beast/site_scons/Beast.py index 3a4ba9d00..0b096d402 100644 --- a/src/beast/site_scons/Beast.py +++ b/src/beast/site_scons/Beast.py @@ -69,6 +69,8 @@ class __System(object): else: raise Exception('Unknown system platform "' + self.name + '"') + self.platform = self.distro or self.name + def __str__(self): return self.__display