From a9b1f22ba15ecfe290131f97f456fed060162568 Mon Sep 17 00:00:00 2001 From: Robert Blake Date: Thu, 13 Aug 2020 23:42:53 -0700 Subject: External package recognition for git. (#18010) Co-authored-by: Adam J. Stewart --- var/spack/repos/builtin/packages/git/package.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/var/spack/repos/builtin/packages/git/package.py b/var/spack/repos/builtin/packages/git/package.py index 8ecedd8c89..c8c0fef40a 100644 --- a/var/spack/repos/builtin/packages/git/package.py +++ b/var/spack/repos/builtin/packages/git/package.py @@ -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 =$', -- cgit v1.2.3-70-g09d2