Add external package support to bzip2 (#19343)

* Add external package support to bzip2

* Flake-8

* Flake-8 part 2

Co-authored-by: iarspider <iarpsider@gmail.com>
This commit is contained in:
iarspider 2020-10-16 23:28:31 +02:00 committed by GitHub
parent a612be1c98
commit e9da8d1633
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,8 @@
# #
# SPDX-License-Identifier: (Apache-2.0 OR MIT) # SPDX-License-Identifier: (Apache-2.0 OR MIT)
import re
from spack import * from spack import *
@ -16,6 +18,8 @@ class Bzip2(Package, SourcewarePackage):
homepage = "https://sourceware.org/bzip2/" homepage = "https://sourceware.org/bzip2/"
sourceware_mirror_path = "bzip2/bzip2-1.0.8.tar.gz" sourceware_mirror_path = "bzip2/bzip2-1.0.8.tar.gz"
executables = [r'^bzip2$']
version('1.0.8', sha256='ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269') version('1.0.8', sha256='ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269')
version('1.0.7', sha256='e768a87c5b1a79511499beb41500bcc4caf203726fff46a6f5f9ad27fe08ab2b') version('1.0.7', sha256='e768a87c5b1a79511499beb41500bcc4caf203726fff46a6f5f9ad27fe08ab2b')
version('1.0.6', sha256='a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd') version('1.0.6', sha256='a2848f34fcd5d6cf47def00461fcb528a0484d8edef8208d6d2e2909dc61d9cd')
@ -24,6 +28,13 @@ class Bzip2(Package, SourcewarePackage):
depends_on('diffutils', type='build') 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 # override default implementation
@property @property
def libs(self): def libs(self):
@ -95,8 +106,8 @@ def install(self, spec, prefix):
install(lib3, join_path(prefix.lib, lib3)) install(lib3, join_path(prefix.lib, lib3))
with working_dir(prefix.lib): with working_dir(prefix.lib):
for l in (lib, lib1, lib2): for libname in (lib, lib1, lib2):
symlink(lib3, l) symlink(lib3, libname)
with working_dir(prefix.bin): with working_dir(prefix.bin):
force_remove('bunzip2', 'bzcat') force_remove('bunzip2', 'bzcat')