about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/multipath-tools/default.nix
blob: 91363969ffe6dbcb31648cc427afbafe8bb15834 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{ lib
, stdenv
, fetchFromGitHub
, coreutils
, pkg-config
, perl
, lvm2
, libaio
, readline
, systemd
, liburcu
, json_c
, linuxHeaders
, cmocka
, nixosTests
}:

stdenv.mkDerivation rec {
  pname = "multipath-tools";
  version = "0.9.4";

  src = fetchFromGitHub {
    owner = "opensvc";
    repo = "multipath-tools";
    rev = "refs/tags/${version}";
    sha256 = "sha256-CPvtnjzkyxKXrT8+YXaIgDA548h8X61+jCxMHKFfEyg=";
  };

  postPatch = ''
    substituteInPlace create-config.mk \
      --replace /bin/echo ${coreutils}/bin/echo

    substituteInPlace multipathd/multipathd.service \
      --replace /sbin/multipathd "$out/bin/multipathd"

    sed -i -re '
      s,^( *#define +DEFAULT_MULTIPATHDIR\>).*,\1 "'"$out/lib/multipath"'",
    ' libmultipath/defaults.h
    sed -i -e 's,\$(DESTDIR)/\(usr/\)\?,$(prefix)/,g' \
      kpartx/Makefile libmpathpersist/Makefile
    sed -i -e "s,GZIP,GZ," \
      $(find * -name Makefile\*)
  '';

  nativeBuildInputs = [ pkg-config perl ];
  buildInputs = [ systemd lvm2 libaio readline liburcu json_c linuxHeaders ];

  makeFlags = [
    "LIB=lib"
    "prefix=$(out)"
    "systemd_prefix=$(out)"
    "kernel_incdir=${linuxHeaders}/include/"
    "man8dir=$(out)/share/man/man8"
    "man5dir=$(out)/share/man/man5"
    "man3dir=$(out)/share/man/man3"
  ];

  doCheck = true;
  preCheck = ''
    # skip test attempting to access /sys/dev/block
    substituteInPlace tests/Makefile --replace ' devt ' ' '
  '';
  nativeCheckInputs = [ cmocka ];

  passthru.tests = { inherit (nixosTests) iscsi-multipath-root; };

  meta = with lib; {
    description = "Tools for the Linux multipathing storage driver";
    homepage = "http://christophe.varoqui.free.fr/";
    license = licenses.gpl2;
    platforms = platforms.linux;
  };
}