summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/fzf/package.py
blob: f975d864730e164fe15d7e192b96c6474516a525 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
# 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 *


class Fzf(MakefilePackage):
    """fzf is a general-purpose command-line fuzzy finder."""

    homepage = "https://github.com/junegunn/fzf"
    url = "https://github.com/junegunn/fzf/archive/0.17.5.tar.gz"

    maintainers("alecbcs")

    executables = ["^fzf$"]

    version("0.40.0", sha256="9597f297a6811d300f619fff5aadab8003adbcc1566199a43886d2ea09109a65")

    depends_on("go@1.17:", type="build")

    variant("vim", default=False, description="Install vim plugins for fzf")

    @classmethod
    def determine_version(cls, exe):
        output = Executable(exe)("--version", output=str, error=str)
        match = re.match(r"(^[\d.]+)", output)
        return match.group(1) if match else None

    def setup_build_environment(self, env):
        # Point GOPATH at the top of the staging dir for the build step.
        env.prepend_path("GOPATH", self.stage.path)

        # Set required environment variables since we
        # are not using git to pull down the repository.
        env.set("FZF_VERSION", self.spec.version)
        env.set("FZF_REVISION", "tarball")

    def install(self, spec, prefix):
        make("install")

        mkdir(prefix.bin)
        install("bin/fzf", prefix.bin)

        mkdirp(prefix.share.fzf.shell)
        install_tree("shell", prefix.share.fzf.shell)

    @run_after("install")
    def post_install(self):
        if "+vim" in self.spec:
            mkdir(self.prefix.plugin)
            install("plugin/fzf.vim", self.prefix.plugin)