1{
2 lib,
3 stdenv,
4 fetchurl,
5 cups,
6 perl,
7 ghostscript,
8 which,
9 makeWrapper,
10}:
11
12/*
13 [Setup instructions](http://support.brother.com/g/s/id/linux/en/instruction_prn1a.html).
14
15 URI example
16 ~ `lpd://BRW0080927AFBCE/binary_p1`
17
18 Logging
19 -------
20
21 `/tmp/br_lpdfilter_ml1.log` when `$ENV{LPD_DEBUG} > 0` in `filter_BrGenML1`
22 which is activated automatically when `DEBUG > 0` in `brother_lpdwrapper_BrGenML1`
23 from the cups wrapper.
24
25 Issues
26 ------
27
28 - filter_BrGenML1 ln 196 `my $GHOST_SCRIPT=`which gs`;`
29
30 `GHOST_SCRIPT` is empty resulting in an empty `/tmp/br_lpdfilter_ml1_gsout.dat` file.
31 See `/tmp/br_lpdfilter_ml1.log` for the executed command.
32
33 Notes
34 -----
35
36 - The `setupPrintcap` has totally no use in our context.
37*/
38
39let
40 myPatchElf = file: ''
41 patchelf --set-interpreter \
42 ${stdenv.cc.libc}/lib/ld-linux${lib.optionalString stdenv.hostPlatform.is64bit "-x86-64"}.so.2 \
43 ${file}
44 '';
45in
46stdenv.mkDerivation rec {
47 pname = "brgenml1lpr";
48 version = "3.1.0-1";
49
50 src = fetchurl {
51 url = "https://download.brother.com/welcome/dlf101123/brgenml1lpr-${version}.i386.deb";
52 sha256 = "0zdvjnrjrz9sba0k525linxp55lr4cyivfhqbkq1c11br2nvy09f";
53 };
54
55 unpackPhase = ''
56 ar x $src
57 tar xfvz data.tar.gz
58 '';
59
60 nativeBuildInputs = [ makeWrapper ];
61 buildInputs = [
62 cups
63 perl
64 stdenv.cc.libc
65 ghostscript
66 which
67 ];
68
69 dontBuild = true;
70
71 patchPhase = ''
72 INFDIR=opt/brother/Printers/BrGenML1/inf
73 LPDDIR=opt/brother/Printers/BrGenML1/lpd
74
75 # Setup max debug log by default.
76 substituteInPlace $LPDDIR/filter_BrGenML1 \
77 --replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$out/opt/brother/Printers/BrGenML1\"; #" \
78 --replace "PRINTER =~" "PRINTER = \"BrGenML1\"; #"
79
80 ${myPatchElf "$INFDIR/braddprinter"}
81 ${myPatchElf "$LPDDIR/brprintconflsr3"}
82 ${myPatchElf "$LPDDIR/rawtobr3"}
83 '';
84
85 installPhase = ''
86 INFDIR=opt/brother/Printers/BrGenML1/inf
87 LPDDIR=opt/brother/Printers/BrGenML1/lpd
88
89 mkdir -p $out/$INFDIR
90 cp -rp $INFDIR/* $out/$INFDIR
91 mkdir -p $out/$LPDDIR
92 cp -rp $LPDDIR/* $out/$LPDDIR
93
94 wrapProgram $out/$LPDDIR/filter_BrGenML1 \
95 --prefix PATH ":" "${ghostscript}/bin" \
96 --prefix PATH ":" "${which}/bin"
97 '';
98
99 dontPatchELF = true;
100
101 meta = {
102 description = "Brother BrGenML1 LPR driver";
103 homepage = "http://www.brother.com";
104 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
105 platforms = lib.platforms.linux;
106 license = lib.licenses.unfreeRedistributable;
107 maintainers = with lib.maintainers; [ jraygauthier ];
108 };
109}