From e9da8d16336ea01aa78548d70cf4f6691f2e9947 Mon Sep 17 00:00:00 2001 From: iarspider Date: Fri, 16 Oct 2020 23:28:31 +0200 Subject: [PATCH] Add external package support to bzip2 (#19343) * Add external package support to bzip2 * Flake-8 * Flake-8 part 2 Co-authored-by: iarspider --- var/spack/repos/builtin/packages/bzip2/package.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/var/spack/repos/builtin/packages/bzip2/package.py b/var/spack/repos/builtin/packages/bzip2/package.py index e46b9e4dfc..901326258b 100644 --- a/var/spack/repos/builtin/packages/bzip2/package.py +++ b/var/spack/repos/builtin/packages/bzip2/package.py @@ -3,6 +3,8 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import re + from spack import * @@ -16,6 +18,8 @@ class Bzip2(Package, SourcewarePackage): homepage = "https://sourceware.org/bzip2/" sourceware_mirror_path = "bzip2/bzip2-1.0.8.tar.gz" + executables = [r'^bzip2$'] + version('1.0.8', sha256='ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269') version('1.0.7', sha256='e768a87c5b1a79511499beb41500bcc4caf203726fff46a6f5f9ad27fe08ab2b') version('1.0.6', sha256='a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd') @@ -24,6 +28,13 @@ class Bzip2(Package, SourcewarePackage): depends_on('diffutils', type='build') + @classmethod + def determine_version(cls, exe): + output = Executable(exe)('--help', output=str, error=str) + match = re.search(r'bzip2, a block-sorting file compressor.' + ' Version ([^,]+)', output) + return match.group(1) if match else None + # override default implementation @property def libs(self): @@ -95,8 +106,8 @@ def install(self, spec, prefix): install(lib3, join_path(prefix.lib, lib3)) with working_dir(prefix.lib): - for l in (lib, lib1, lib2): - symlink(lib3, l) + for libname in (lib, lib1, lib2): + symlink(lib3, libname) with working_dir(prefix.bin): force_remove('bunzip2', 'bzcat')