# Copyright 2013-2021 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)

from spack import *


class Xfsprogs(AutotoolsPackage):
    """XFS User Tools."""

    homepage = "http://oss.sgi.com/projects/xfs/"
    url      = "http://kernel.org/pub/linux/utils/fs/xfs/xfsprogs/xfsprogs-4.17.0.tar.xz"

    version('5.8.0', sha256='8ef46ed9e6bb927f407f541dc4324857c908ddf1374265edc910d23724048c6b')
    version('5.7.0', sha256='8f2348a68a686a3f4491dda5d62dd32d885fbc52d32875edd41e2c296e7b4f35')
    version('5.6.0', sha256='0aba2aac5d80d07646dde868437fc337af2c7326edadcc6d6a7c0bfd3190c1e6')

    version('4.20.0', sha256='beafdfd080352a8c9d543491e0874d0e8809cb643a3b9d352d5feed38d77022a')

    depends_on('gettext')
    depends_on('uuid')
    depends_on('util-linux')

    def setup_build_environment(self, env):
        env.append_path('C_INCLUDE_PATH',
                        self.spec['util-linux'].prefix.include.blkid)

    def configure_args(self):
        args = ['LDFLAGS=-lintl']
        return args

    def install(self, spec, prefix):
        make('install')
        make('install-dev')

    def setup_run_environment(self, env):
        env.prepend_path('PATH', self.prefix.sbin)

# Copyright 2013-2021 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)

from spack import *


class Xfsprogs(AutotoolsPackage):
    """XFS User Tools."""

    homepage = "http://oss.sgi.com/projects/xfs/"
    url      = "http://kernel.org/pub/linux/utils/fs/xfs/xfsprogs/xfsprogs-4.17.0.tar.xz"

    version('5.8.0', sha256='8ef46ed9e6bb927f407f541dc4324857c908ddf1374265edc910d23724048c6b')
    version('5.7.0', sha256='8f2348a68a686a3f4491dda5d62dd32d885fbc52d32875edd41e2c296e7b4f35')
    version('5.6.0', sha256='0aba2aac5d80d07646dde868437fc337af2c7326edadcc6d6a7c0bfd3190c1e6')

    version('4.20.0', sha256='beafdfd080352a8c9d543491e0874d0e8809cb643a3b9d352d5feed38d77022a')

    depends_on('gettext')
    depends_on('uuid')
    depends_on('util-linux')

    def setup_build_environment(self, env):
        env.append_path('C_INCLUDE_PATH',
                        self.spec['util-linux'].prefix.include.blkid)

    def configure_args(self):
        args = ['LDFLAGS=-lintl',
                "--with-systemd-unit-dir=" +
                self.spec['xfsprogs'].prefix.lib.systemd.system]
        return args

    def install(self, spec, prefix):
        make('install')
        make('install-dev')

    def setup_run_environment(self, env):
        env.prepend_path('PATH', self.prefix.sbin)

add --with-systemd-unit-dir option (#22075)