summary refs log tree commit diff
path: root/pkgs/os-specific/linux/fusionio/util.nix
blob: 6327a95f39d7148a14fe7c5f1fd9e4938ed28d89 (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
{ stdenv, fetchurl, dpkg, glibc, gcc, libuuid }:

let
  srcs = import ./srcs.nix { inherit fetchurl; };
in
stdenv.mkDerivation {
  name = "fusionio-util-${srcs.version}";

  nativeBuildInputs = [ dpkg ];

  buildCommand = ''
    dpkg-deb -R ${srcs.libvsl} $TMPDIR
    dpkg-deb -R ${srcs.util} $TMPDIR

    rm $TMPDIR/usr/bin/fio-{bugreport,sanitize}

    mkdir -p $out
    cp -r $TMPDIR/{etc,usr/{bin,lib,share}} $out
    for BIN in $(find $out/bin -type f); do
      echo Patching $BIN
      patchelf --set-interpreter "${glibc.out}/lib/ld-linux-x86-64.so.2" --set-rpath "${stdenv.lib.makeLibraryPath [ glibc gcc.cc libuuid ] }:$out/lib" $BIN

      # Test our binary to see if it was correctly patched
      set +e
      $BIN --help >/dev/null 2>&1
      ST="$?"
      set -e
      if [ "$ST" -ge "10" ]; then
        echo "Failed testing $BIN"
        exit 1;
      fi
    done
  '';

  dontStrip = true;

  meta = with stdenv.lib; {
    homepage = http://fusionio.com;
    description = "Fusionio command line utilities";
    license = licenses.unfree;
    platforms = [ "x86_64-linux" ];
    broken = stdenv.hostPlatform.system != "x86_64-linux";
    maintainers = with maintainers; [ wkennington ];
  };
}