turnon: 2.0.0 -> 2.3.1 (#370430)
[NixPkgs.git] / pkgs / by-name / ds / dsseries / package.nix
blobb49d661949340d9f22d59024c1caea60203ac2f0
2   lib,
3   stdenv,
4   fetchurl,
5   rpmextract,
6 }:
8 stdenv.mkDerivation rec {
9   pname = "libsane-dsseries";
10   version = "1.0.5-1";
12   src = fetchurl {
13     url = "https://download.brother.com/welcome/dlf100974/${pname}-${version}.x86_64.rpm";
14     sha256 = "1wfdbfbf51cc7njzikdg48kwpnpc0pg5s6p0s0y3z0q7y59x2wbq";
15   };
17   nativeBuildInputs = [ rpmextract ];
19   unpackCmd = ''
20     mkdir ${pname}-${version} && pushd ${pname}-${version}
21     rpmextract $curSrc
22     popd
23   '';
25   patchPhase = ''
26     substituteInPlace etc/udev/rules.d/50-Brother_DSScanner.rules \
27       --replace 'GROUP="users"' 'GROUP="scanner", ENV{libsane_matched}="yes"'
29     mkdir -p etc/sane.d/dll.d
30     echo "dsseries" > etc/sane.d/dll.d/dsseries.conf
31   '';
33   installPhase = ''
34     mkdir -p $out
35     cp -dr etc $out
36     cp -dr usr/lib64 $out/lib
37   '';
39   preFixup = ''
40     for f in `find $out/lib/sane/ -type f`; do
41       # Make it possible to find libstdc++.so.6
42       patchelf --set-rpath ${lib.getLib stdenv.cc.cc}/lib:$out/lib/sane $f
44       # Horrible kludge: The driver hardcodes /usr/lib/sane/ as a dlopen path.
45       # We can directly modify the binary to force a relative lookup instead.
46       # The new path is NULL-padded to the same length as the original path.
47       sed -i "s|/usr/lib/sane/%s|%s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|g" $f
48     done
49   '';
51   meta = {
52     description = "Brother DSSeries SANE backend driver";
53     homepage = "http://www.brother.com";
54     platforms = lib.platforms.linux;
55     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
56     license = lib.licenses.unfree;
57     maintainers = with lib.maintainers; [ callahad ];
58   };