ryujinx-greemdev: init at 1.2.76 (#353897)
[NixPkgs.git] / pkgs / by-name / cu / cups-brother-hl3170cdw / package.nix
blobffc6b6832d600004e23d7cf90e8c883aeaa3f741
2   lib,
3   stdenv,
4   fetchurl,
5   dpkg,
6   makeWrapper,
7   gnused,
8   coreutils,
9   psutils,
10   gnugrep,
11   ghostscript,
12   file,
13   a2ps,
14   gawk,
15   which,
16   pkgsi686Linux,
19 stdenv.mkDerivation rec {
20   pname = "cups-brother-${model}";
21   version = "1.1.4-0";
22   lprVersion = "1.1.2-1";
24   model = "hl3170cdw";
25   cupsFileNo = "006743";
26   lprFileNo = "007056";
28   src = fetchurl {
29     url = "https://download.brother.com/welcome/dlf${cupsFileNo}/${model}_cupswrapper_GPL_source_${version}.tar.gz";
30     hash = "sha256-E3GSwiMRkuiCIJYkDozoYUPfOqvopPqPPQt1uaMDEAU=";
31   };
33   lprdeb = fetchurl {
34     url = "https://download.brother.com/welcome/dlf${lprFileNo}/${model}lpr-${lprVersion}.i386.deb";
35     hash = "sha256-N1GjQHth5k4qhbfWLInzub9DcNsee4gKc3EW2WIfrko=";
36   };
38   nativeBuildInputs = [
39     makeWrapper
40     dpkg
41   ];
43   preUnpack = ''
44     dpkg-deb -x ${lprdeb} $out
45   '';
47   prePatch = ''
48     substituteInPlace brcupsconfig/brcups_commands.h \
49       --replace-fail "brprintconf[30]=\"" "brprintconf[130]=\"$out/usr/bin/"
51     substituteInPlace brcupsconfig/brcupsconfig.c \
52       --replace-fail "exec[300]" "exec[400]"
53   '';
55   makeFlags = [ "-C brcupsconfig" ];
57   installPhase = ''
58     runHook preInstall
60     # cups install
61     dir=$out/opt/brother/Printers/${model}
63     # Extract the true brother_lpdwrapper_MODEL filter embedded in cupswrapperMODEL by
64     # slicing out the relevant parts for the writing the embedded file, then running that.
65     sed -n -e '/tmp_filter=/c\tmp_filter=lpdwrapper'  -e ' 1,/device_model=/p ; /<<!ENDOFWFILTER/,/!ENDOFWFILTER/p ; ' \
66       cupswrapper/cupswrapper${model} > lpdwrapperbuilder
67     sh lpdwrapperbuilder
68     chmod +x lpdwrapper
69     mkdir -p $out/lib/cups/filter
70     cp lpdwrapper $out/lib/cups/filter/brother_lpdwrapper_${model}
72     mkdir -p $out/share/cups/model/Brother
73     cp PPD/brother_${model}_printer_en.ppd $out/share/cups/model/Brother/brother_${model}_printer_en.ppd
75     mkdir -p $dir/cupswrapper/
76     cp brcupsconfig/brcupsconfpt1 $dir/cupswrapper/
78     runHook postInstall
79   '';
81   preFixup = ''
82     # lpr fixup
83     interpreter=${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2
85     substituteInPlace $dir/lpd/filter${model} \
86       --replace-fail /opt "$out/opt"
87     substituteInPlace $dir/inf/setupPrintcapij \
88       --replace-fail /opt "$out/opt" \
89       --replace-fail printcap.local printcap
91     wrapProgram $dir/lpd/filter${model} \
92       --prefix PATH ":" ${
93         lib.makeBinPath [
94           ghostscript
95           a2ps
96           file
97           gnused
98           coreutils
99         ]
100       }
102     wrapProgram $dir/inf/setupPrintcapij \
103       --prefix PATH ":" ${
104         lib.makeBinPath [
105           coreutils
106           gnused
107         ]
108       }
110     wrapProgram $dir/lpd/psconvertij2 \
111       --prefix PATH ":" ${
112         lib.makeBinPath [
113           ghostscript
114           gnused
115           coreutils
116           gawk
117           which
118         ]
119       }
121     patchelf --set-interpreter "$interpreter" "$dir/lpd/br${model}filter"
122     patchelf --set-interpreter "$interpreter" "$out/usr/bin/brprintconf_${model}"
124     wrapProgram $dir/lpd/br${model}filter \
125       --set LD_PRELOAD "${pkgsi686Linux.libredirect}/lib/libredirect.so" \
126       --set NIX_REDIRECTS "/opt=$out/opt"
128     wrapProgram $out/usr/bin/brprintconf_${model} \
129       --set LD_PRELOAD "${pkgsi686Linux.libredirect}/lib/libredirect.so" \
130       --set NIX_REDIRECTS "/opt=$out/opt"
132     # cups fixup
133     substituteInPlace $out/lib/cups/filter/brother_lpdwrapper_${model} \
134       --replace-fail /opt/brother/Printers/${model} "$dir" \
135       --replace-fail /usr/bin/psnup "${psutils}/bin/psnup" \
136       --replace-fail /usr/share/cups/model/Brother "$out/share/cups/model/Brother"
138     wrapProgram $out/lib/cups/filter/brother_lpdwrapper_${model} \
139       --prefix PATH ":" ${
140         lib.makeBinPath [
141           coreutils
142           psutils
143           gnused
144           gnugrep
145         ]
146       }
147   '';
149   meta = with lib; {
150     homepage = "https://www.brother.com/";
151     description = "Brother ${model} printer driver";
152     sourceProvenance = with sourceTypes; [
153       binaryNativeCode
154       fromSource
155     ];
156     license = with licenses; [
157       unfree
158       gpl2Plus
159     ];
160     platforms = [
161       "x86_64-linux"
162       "i686-linux"
163     ];
164     downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=${model}_all&os=128";
165     maintainers = with maintainers; [ luna_1024 ];
166   };