otadump: init at 0.1.2 (#329129)
[NixPkgs.git] / pkgs / by-name / mf / mfc9140cdncupswrapper / package.nix
blob7534a623802458d26decd37c78d5c5564c790b0e
2   lib,
3   stdenv,
4   fetchurl,
5   dpkg,
6   makeWrapper,
7   coreutils,
8   gnugrep,
9   gnused,
10   mfc9140cdnlpr,
11   pkgsi686Linux,
12   psutils,
15 stdenv.mkDerivation rec {
16   pname = "mfc9140cdncupswrapper";
17   version = "1.1.4-0";
19   src = fetchurl {
20     url = "https://download.brother.com/welcome/dlf100407/${pname}-${version}.i386.deb";
21     sha256 = "18aramgqgra1shdhsa75i0090hk9i267gvabildwsk52kq2b96c6";
22   };
24   unpackPhase = ''
25     dpkg-deb -x $src $out
26   '';
28   nativeBuildInputs = [
29     dpkg
30     makeWrapper
31   ];
33   dontBuild = true;
35   installPhase = ''
36     lpr=${mfc9140cdnlpr}/opt/brother/Printers/mfc9140cdn
37     dir=$out/opt/brother/Printers/mfc9140cdn
39     interpreter=${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2
40     patchelf --set-interpreter "$interpreter" "$dir/cupswrapper/brcupsconfpt1"
42     substituteInPlace $dir/cupswrapper/cupswrappermfc9140cdn \
43       --replace "mkdir -p /usr" ": # mkdir -p /usr" \
44       --replace '/opt/brother/''${device_model}/''${printer_model}/lpd/filter''${printer_model}' "$lpr/lpd/filtermfc9140cdn" \
45       --replace '/usr/share/ppd/Brother/brother_''${printer_model}_printer_en.ppd' "$dir/cupswrapper/brother_mfc9140cdn_printer_en.ppd" \
46       --replace '/usr/share/cups/model/Brother/brother_''${printer_model}_printer_en.ppd' "$dir/cupswrapper/brother_mfc9140cdn_printer_en.ppd" \
47       --replace '/opt/brother/Printers/''${printer_model}/' "$lpr/" \
48       --replace 'nup="psnup' "nup=\"${psutils}/bin/psnup" \
49       --replace '/usr/bin/psnup' "${psutils}/bin/psnup"
51     mkdir -p $out/lib/cups/filter
52     mkdir -p $out/share/cups/model
54     ln $dir/cupswrapper/cupswrappermfc9140cdn $out/lib/cups/filter
55     ln $dir/cupswrapper/brother_mfc9140cdn_printer_en.ppd $out/share/cups/model
57     sed -n '/!ENDOFWFILTER!/,/!ENDOFWFILTER!/p' "$dir/cupswrapper/cupswrappermfc9140cdn" | sed '1 br; b; :r s/.*/printer_model=mfc9140cdn; cat <<!ENDOFWFILTER!/'  | bash > $out/lib/cups/filter/brother_lpdwrapper_mfc9140cdn
58     sed -i "/#! \/bin\/sh/a PATH=${
59       lib.makeBinPath [
60         coreutils
61         gnused
62         gnugrep
63       ]
64     }:\$PATH" $out/lib/cups/filter/brother_lpdwrapper_mfc9140cdn
65     chmod +x $out/lib/cups/filter/brother_lpdwrapper_mfc9140cdn
66   '';
68   meta = with lib; {
69     description = "Brother MFC-9140CDN CUPS wrapper driver";
70     homepage = "http://www.brother.com/";
71     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
72     license = licenses.gpl2Plus;
73     platforms = platforms.linux;
74     maintainers = with maintainers; [ hexa ];
75   };