summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorMosè Giordano <765740+giordano@users.noreply.github.com>2024-11-18 17:30:46 -0500
committerGitHub <noreply@github.com>2024-11-18 14:30:46 -0800
commitd0fd112006c037658069a89d80441eaa41f779de (patch)
treee29f4fb496e31556be1bb720e415db8de3dcccfe /var
parent50f43ca71dd5e97c3339490962ee956b50ad4eed (diff)
downloadspack-d0fd112006c037658069a89d80441eaa41f779de.tar.gz
spack-d0fd112006c037658069a89d80441eaa41f779de.tar.bz2
spack-d0fd112006c037658069a89d80441eaa41f779de.tar.xz
spack-d0fd112006c037658069a89d80441eaa41f779de.zip
grep: add `executables` attribute and `determine_version` method (#47438)
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/grep/package.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/grep/package.py b/var/spack/repos/builtin/packages/grep/package.py
index 1ff968569f..a8f2927469 100644
--- a/var/spack/repos/builtin/packages/grep/package.py
+++ b/var/spack/repos/builtin/packages/grep/package.py
@@ -2,6 +2,8 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+import re
+
from spack.package import *
@@ -14,6 +16,8 @@ class Grep(AutotoolsPackage):
license("GPL-3.0-or-later")
+ executables = ["^grep$"]
+
version("3.11", sha256="1db2aedde89d0dea42b16d9528f894c8d15dae4e190b59aecc78f5a951276eab")
version("3.10", sha256="24efa5b595fb5a7100879b51b8868a0bb87a71c183d02c4c602633b88af6855b")
version("3.9", sha256="abcd11409ee23d4caf35feb422e53bbac867014cfeed313bb5f488aca170b599")
@@ -29,6 +33,14 @@ class Grep(AutotoolsPackage):
depends_on("pcre2", when="@3.8:+pcre")
depends_on("pcre", when="@:3.7+pcre")
+ @classmethod
+ def determine_version(cls, exe):
+ output = Executable(exe)("--version", output=str, error=str)
+ # Example output:
+ # grep (GNU grep) 3.11
+ match = re.search(r"^grep \(GNU grep\) ([0-9.]+)", output)
+ return match.group(1) if match else None
+
def configure_args(self):
args = []