From 4b4e7b878d871eeecc7cc9e68c5f3e5942fe9f8e Mon Sep 17 00:00:00 2001 From: "John C. Linford" Date: Wed, 12 Jul 2017 12:20:29 -0400 Subject: [PATCH] Handle leading/trailing lines on CMake version. --- packages/taucmdr/cf/software/installation.py | 36 ++++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/taucmdr/cf/software/installation.py b/packages/taucmdr/cf/software/installation.py index 921a518c49..4ff0a3122f 100644 --- a/packages/taucmdr/cf/software/installation.py +++ b/packages/taucmdr/cf/software/installation.py @@ -615,6 +615,25 @@ class CMakeInstallation(MakeInstallation): make [flags] install [options] """ + def _get_cmake(self): + cmake = util.which('cmake') + if not cmake: + raise ConfigurationError("'cmake' not found in PATH.") + try: + stdout = util.get_command_output([cmake, '--version']) + except (CalledProcessError, OSError) as err: + raise ConfigurationError("Failed to get CMake version: %s" % err) + for line in stdout.split('\n'): + if 'cmake version' in line: + verstr = (line.split('cmake version ')[1]).split('-')[0] + version = tuple(int(x) for x in verstr.split('.')) + if version < (2, 8): + raise ConfigurationError("CMake version 2.8 or higher required.") + break + else: + LOGGER.warning("Cannot determine CMake version. CMake 2.8 or higher is required.") + return cmake + def cmake(self, flags, env): """Invoke `cmake`. @@ -629,21 +648,8 @@ def cmake(self, flags, env): SoftwarePackageError: Configuration failed. """ assert self._src_prefix - cmake_path = util.which('cmake') - if not cmake_path: - raise ConfigurationError("'cmake' not found in PATH.") - try: - stdout = util.get_command_output([cmake_path, '--version']) - except (CalledProcessError, OSError) as err: - raise ConfigurationError("Failed to get CMake version: %s" % err) - verstr = (stdout.split('cmake version ')[1]).split('-')[0] - version = tuple(int(x) for x in verstr.split('.')) - if version < (2, 8): - raise ConfigurationError("CMake version 2.8 or higher required.") - LOGGER.debug("Executing CMake for %s at '%s'", self.name, self._src_prefix) - flags = list(flags) - flags.append('-DCMAKE_INSTALL_PREFIX=%s' % self.install_prefix) - cmd = [cmake_path] + flags + cmake = self._get_cmake() + cmd = [cmake, '-DCMAKE_INSTALL_PREFIX=%s' % self.install_prefix] + flags LOGGER.info("Executing CMake for %s...", self.title) if util.create_subprocess(cmd, cwd=self._src_prefix, env=env, stdout=False, show_progress=True): raise SoftwarePackageError('CMake failed for %s' %self.title)