evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / mf / mfc9140cdncupswrapper / package.nix
blobc38b5261865155fdf365ba57dc93a0ae5277f9d4
1 { lib
2 , stdenv
3 , fetchurl
4 , dpkg
5 , makeWrapper
6 , coreutils
7 , gnugrep
8 , gnused
9 , mfc9140cdnlpr
10 , pkgsi686Linux
11 , psutils
14 stdenv.mkDerivation rec {
15   pname = "mfc9140cdncupswrapper";
16   version = "1.1.4-0";
18   src = fetchurl {
19     url = "https://download.brother.com/welcome/dlf100407/${pname}-${version}.i386.deb";
20     sha256 = "18aramgqgra1shdhsa75i0090hk9i267gvabildwsk52kq2b96c6";
21   };
23   unpackPhase = ''
24     dpkg-deb -x $src $out
25   '';
27   nativeBuildInputs = [
28     dpkg
29     makeWrapper
30   ];
32   dontBuild = true;
34   installPhase = ''
35     lpr=${mfc9140cdnlpr}/opt/brother/Printers/mfc9140cdn
36     dir=$out/opt/brother/Printers/mfc9140cdn
38     interpreter=${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2
39     patchelf --set-interpreter "$interpreter" "$dir/cupswrapper/brcupsconfpt1"
41     substituteInPlace $dir/cupswrapper/cupswrappermfc9140cdn \
42       --replace "mkdir -p /usr" ": # mkdir -p /usr" \
43       --replace '/opt/brother/''${device_model}/''${printer_model}/lpd/filter''${printer_model}' "$lpr/lpd/filtermfc9140cdn" \
44       --replace '/usr/share/ppd/Brother/brother_''${printer_model}_printer_en.ppd' "$dir/cupswrapper/brother_mfc9140cdn_printer_en.ppd" \
45       --replace '/usr/share/cups/model/Brother/brother_''${printer_model}_printer_en.ppd' "$dir/cupswrapper/brother_mfc9140cdn_printer_en.ppd" \
46       --replace '/opt/brother/Printers/''${printer_model}/' "$lpr/" \
47       --replace 'nup="psnup' "nup=\"${psutils}/bin/psnup" \
48       --replace '/usr/bin/psnup' "${psutils}/bin/psnup"
50     mkdir -p $out/lib/cups/filter
51     mkdir -p $out/share/cups/model
53     ln $dir/cupswrapper/cupswrappermfc9140cdn $out/lib/cups/filter
54     ln $dir/cupswrapper/brother_mfc9140cdn_printer_en.ppd $out/share/cups/model
56     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
57     sed -i "/#! \/bin\/sh/a PATH=${lib.makeBinPath [ coreutils gnused gnugrep ]}:\$PATH" $out/lib/cups/filter/brother_lpdwrapper_mfc9140cdn
58     chmod +x $out/lib/cups/filter/brother_lpdwrapper_mfc9140cdn
59     '';
61   meta = with lib; {
62     description = "Brother MFC-9140CDN CUPS wrapper driver";
63     homepage = "http://www.brother.com/";
64     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
65     license = licenses.gpl2Plus;
66     platforms = platforms.linux;
67     maintainers = with maintainers; [ hexa ];
68   };