1{ lib
2, stdenv
3, fetchFromGitHub
4, coreutils
5
6, perl
7, pkg-config
8
9, json_c
10, libaio
11, liburcu
12, linuxHeaders
13, lvm2
14, readline
15, systemd
16, util-linuxMinimal
17
18, cmocka
19, nixosTests
20}:
21
22stdenv.mkDerivation rec {
23 pname = "multipath-tools";
24 version = "0.9.6";
25
26 src = fetchFromGitHub {
27 owner = "opensvc";
28 repo = "multipath-tools";
29 rev = "refs/tags/${version}";
30 sha256 = "sha256-X4sAMGn4oBMY3cQkVj1dMcrDF7FgMl8SbZeUnCCOY6Q=";
31 };
32
33 postPatch = ''
34 substituteInPlace create-config.mk \
35 --replace /bin/echo ${coreutils}/bin/echo
36
37 substituteInPlace multipathd/multipathd.service \
38 --replace /sbin/multipathd "$out/bin/multipathd"
39
40 sed -i -re '
41 s,^( *#define +DEFAULT_MULTIPATHDIR\>).*,\1 "'"$out/lib/multipath"'",
42 ' libmultipath/defaults.h
43 sed -i -e 's,\$(DESTDIR)/\(usr/\)\?,$(prefix)/,g' \
44 kpartx/Makefile libmpathpersist/Makefile
45 sed -i -e "s,GZIP,GZ," \
46 $(find * -name Makefile\*)
47
48 sed '1i#include <assert.h>' -i tests/{util,vpd}.c
49 '';
50
51 nativeBuildInputs = [
52 perl
53 pkg-config
54 ];
55 buildInputs = [
56 json_c
57 libaio
58 liburcu
59 linuxHeaders
60 lvm2
61 readline
62 systemd
63 util-linuxMinimal # for libmount
64 ];
65
66 makeFlags = [
67 "LIB=lib"
68 "prefix=$(out)"
69 "systemd_prefix=$(out)"
70 "kernel_incdir=${linuxHeaders}/include/"
71 "man8dir=$(out)/share/man/man8"
72 "man5dir=$(out)/share/man/man5"
73 "man3dir=$(out)/share/man/man3"
74 ];
75
76 doCheck = true;
77 preCheck = ''
78 # skip test attempting to access /sys/dev/block
79 substituteInPlace tests/Makefile --replace ' devt ' ' '
80 '';
81 nativeCheckInputs = [ cmocka ];
82
83 passthru.tests = { inherit (nixosTests) iscsi-multipath-root; };
84
85 meta = with lib; {
86 description = "Tools for the Linux multipathing storage driver";
87 homepage = "http://christophe.varoqui.free.fr/";
88 license = licenses.gpl2;
89 platforms = platforms.linux;
90 };
91}