summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/dos2unix/package.py
blob: bf76004e231814415b5d10d24834b3ca77aa3f3a (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
# 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 Dos2unix(MakefilePackage):
    """DOS/Mac to Unix and vice versa text file format converter."""

    homepage = "https://waterlan.home.xs4all.nl/dos2unix.html"
    url = "https://waterlan.home.xs4all.nl/dos2unix/dos2unix-7.3.4.tar.gz"

    maintainers("cessenat")

    version("7.4.2", sha256="6035c58df6ea2832e868b599dfa0d60ad41ca3ecc8aa27822c4b7a9789d3ae01")
    version("7.3.4", sha256="8ccda7bbc5a2f903dafd95900abb5bf5e77a769b572ef25150fde4056c5f30c5")

    depends_on("gettext")

    executables = [r"^dos2unix$"]

    @property
    def build_targets(self):
        targets = [
            "LDFLAGS_USER=-L{0} {1}".format(
                self.spec["gettext"].prefix.lib, self.spec["gettext"].libs.link_flags
            ),
        ]
        return targets

    def install(self, spec, prefix):
        make("prefix={0}".format(prefix), "install")

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