1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 lvm2,
7}:
8
9stdenv.mkDerivation rec {
10 pname = "dmraid";
11 version = "1.0.0.rc16";
12
13 src = fetchurl {
14 url = "https://people.redhat.com/~heinzm/sw/dmraid/src/old/dmraid-${version}.tar.bz2";
15 sha256 = "0m92971gyqp61darxbiri6a48jz3wq3gkp8r2k39320z0i6w8jgq";
16 };
17
18 patches =
19 [
20 ./hardening-format.patch
21 ./fix-dmevent_tool.patch
22 ]
23 ++ lib.optionals stdenv.hostPlatform.isMusl [
24 (fetchpatch {
25 url = "https://raw.githubusercontent.com/void-linux/void-packages/fceed4b8e96b3c1da07babf6f67b6ed1588a28b2/srcpkgs/dmraid/patches/006-musl-libc.patch";
26 sha256 = "1j8xda0fpz8lxjxnqdidy7qb866qrzwpbca56yjdg6vf4x21hx6w";
27 stripLen = 2;
28 extraPrefix = "1.0.0.rc16/";
29 })
30 (fetchpatch {
31 url = "https://raw.githubusercontent.com/void-linux/void-packages/fceed4b8e96b3c1da07babf6f67b6ed1588a28b2/srcpkgs/dmraid/patches/007-fix-loff_t-musl.patch";
32 sha256 = "0msnq39qnzg3b1pdksnz1dgqwa3ak03g41pqh0lw3h7w5rjc016k";
33 stripLen = 2;
34 extraPrefix = "1.0.0.rc16/";
35 })
36 ];
37
38 postPatch =
39 ''
40 sed -i 's/\[\[[^]]*\]\]/[ "''$''${n##*.}" = "so" ]/' */lib/Makefile.in
41 ''
42 + lib.optionalString stdenv.hostPlatform.isMusl ''
43 NIX_CFLAGS_COMPILE+=" -D_GNU_SOURCE"
44 '';
45
46 preConfigure = "cd */";
47
48 buildInputs = [ lvm2 ];
49
50 # Hand-written Makefile does not have full dependencies to survive
51 # parallel build:
52 # tools/dmraid.c:12:10: fatal error: dmraid/dmraid.h: No such file
53 enableParallelBuilding = false;
54
55 meta = {
56 description = "Old-style RAID configuration utility";
57 longDescription = ''
58 Old RAID configuration utility (still under development, though).
59 It is fully compatible with modern kernels and mdadm recognizes
60 its volumes. May be needed for rescuing an older system or nuking
61 the metadata when reformatting.
62 '';
63 maintainers = [ lib.maintainers.raskin ];
64 platforms = lib.platforms.linux;
65 license = lib.licenses.gpl2Plus;
66 };
67}