External package recognition for git. (#18010)

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
This commit is contained in:
Robert Blake 2020-08-13 23:42:53 -07:00 committed by GitHub
parent a14648ffd0
commit a9b1f22ba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,8 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import sys
import re
import os
from spack import *
@ -16,6 +18,8 @@ class Git(AutotoolsPackage):
homepage = "http://git-scm.com"
url = "https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.12.0.tar.gz"
executables = ['^git$']
# In order to add new versions here, add a new list entry with:
# * version: {version}
# * sha256: the sha256sum of the git-{version}.tar.gz
@ -206,6 +210,22 @@ class Git(AutotoolsPackage):
depends_on('m4', type='build')
depends_on('tk', type=('build', 'link'), when='+tcltk')
@classmethod
def determine_version(cls, exe):
output = Executable(exe)('--version', output=str, error=str)
match = re.search(r'git version (\S+)', output)
return match.group(1) if match else None
@classmethod
def determine_variants(cls, exes, version_str):
prefix = os.path.dirname(exes[0])
variants = ''
if 'gitk' in os.listdir(prefix):
variants += '+tcltk'
else:
variants += '~tcltk'
return variants
# See the comment in setup_build_environment re EXTLIBS.
def patch(self):
filter_file(r'^EXTLIBS =$',