python313Packages.traits: fix build (#373698)
[NixPkgs.git] / pkgs / misc / cups / drivers / brgenml1lpr / default.nix
blobc0dc26a5dfdc67701e4c906ad12ceea185cb901f
2   lib,
3   stdenv,
4   fetchurl,
5   cups,
6   perl,
7   ghostscript,
8   which,
9   makeWrapper,
13     [Setup instructions](http://support.brother.com/g/s/id/linux/en/instruction_prn1a.html).
15     URI example
16      ~  `lpd://BRW0080927AFBCE/binary_p1`
18     Logging
19     -------
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.
25     Issues
26     ------
28      -  filter_BrGenML1 ln 196 `my $GHOST_SCRIPT=`which gs`;`
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.
33     Notes
34     -----
36      -  The `setupPrintcap` has totally no use in our context.
39 let
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   '';
46 stdenv.mkDerivation rec {
47   pname = "brgenml1lpr";
48   version = "3.1.0-1";
50   src = fetchurl {
51     url = "https://download.brother.com/welcome/dlf101123/brgenml1lpr-${version}.i386.deb";
52     sha256 = "0zdvjnrjrz9sba0k525linxp55lr4cyivfhqbkq1c11br2nvy09f";
53   };
55   unpackPhase = ''
56     ar x $src
57     tar xfvz data.tar.gz
58   '';
60   nativeBuildInputs = [ makeWrapper ];
61   buildInputs = [
62     cups
63     perl
64     stdenv.cc.libc
65     ghostscript
66     which
67   ];
69   dontBuild = true;
71   patchPhase = ''
72     INFDIR=opt/brother/Printers/BrGenML1/inf
73     LPDDIR=opt/brother/Printers/BrGenML1/lpd
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\"; #"
80     ${myPatchElf "$INFDIR/braddprinter"}
81     ${myPatchElf "$LPDDIR/brprintconflsr3"}
82     ${myPatchElf "$LPDDIR/rawtobr3"}
83   '';
85   installPhase = ''
86     INFDIR=opt/brother/Printers/BrGenML1/inf
87     LPDDIR=opt/brother/Printers/BrGenML1/lpd
89     mkdir -p $out/$INFDIR
90     cp -rp $INFDIR/* $out/$INFDIR
91     mkdir -p $out/$LPDDIR
92     cp -rp $LPDDIR/* $out/$LPDDIR
94     wrapProgram $out/$LPDDIR/filter_BrGenML1 \
95       --prefix PATH ":" "${ghostscript}/bin" \
96       --prefix PATH ":" "${which}/bin"
97   '';
99   dontPatchELF = true;
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   };