···
19
+
stdenvNoCC.mkDerivation (finalAttrs: {
20
+
pname = "cups-brother-dcpt310";
24
+
url = "https://download.brother.com/welcome/dlf103618/dcpt310pdrv-${finalAttrs.version}-0.i386.deb";
25
+
sha256 = "0g9hylmpgmzd6k9lxjy32c7pxbzj6gr9sfaahxj3xzqyar05amdx";
28
+
nativeBuildInputs = [
38
+
pkgsi686Linux.stdenv.cc.cc.lib
54
+
cp -pr usr/bin "$out/bin"
55
+
rm "$out/opt/brother/Printers/dcpt310/cupswrapper/cupswrapperdcpt310"
57
+
mkdir -p "$out/lib/cups/filter" "$out/share/cups/model"
59
+
ln -s "../../../opt/brother/Printers/dcpt310/cupswrapper/brother_lpdwrapper_dcpt310" \
60
+
"$out/lib/cups/filter/brother_lpdwrapper_dcpt310"
61
+
ln -s "../../../opt/brother/Printers/dcpt310/cupswrapper/brother_dcpt310_printer_en.ppd" \
62
+
"$out/share/cups/model/brother_dcpt310_printer_en.ppd"
67
+
# Fix global references and replace auto discovery mechanism
68
+
# with hardcoded values.
70
+
# The configuration binary 'brprintconf_dcpt310' and lpd filter
71
+
# 'brdcpt310filter' has hardcoded /opt format strings. There isn't
72
+
# sufficient space in the binaries to substitute a path in the store, so use
73
+
# libredirect to get it to see the correct path. The configuration binary
74
+
# also uses this format string to print configuration locations. Here the
75
+
# wrapper output is processed to point into the correct location in the
79
+
interpreter=${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2
81
+
substituteInPlace $out/opt/brother/Printers/dcpt310/lpd/filter_dcpt310 \
82
+
--replace "my \$BR_PRT_PATH =" "my \$BR_PRT_PATH = \"$out/opt/brother/Printers/dcpt310/\"; #" \
83
+
--replace /usr/bin/pdf2ps "${ghostscript}/bin/pdf2ps" \
84
+
--replace "my \$GHOST_SCRIPT" "my \$GHOST_SCRIPT = \"${ghostscript}/bin/gs\"; #" \
85
+
--replace "PRINTER =~" "PRINTER = \"dcpt310\"; #"
87
+
substituteInPlace $out/opt/brother/Printers/dcpt310/cupswrapper/brother_lpdwrapper_dcpt310 \
88
+
--replace "PRINTER =~" "PRINTER = \"dcpt310\"; #" \
89
+
--replace "my \$basedir = \`readlink \$0\`" "my \$basedir = \"$out/opt/brother/Printers/dcpt310/\"" \
90
+
--replace "my \$lpdconf = \$LPDCONFIGEXE.\$PRINTER;" "my \$lpdconf = \"$out/bin/brprintconf_dcpt310\";"
93
+
patchelf --set-interpreter "$interpreter" "$out/opt/brother/Printers/dcpt310/lpd/brdcpt310filter" \
94
+
--set-rpath ${lib.makeLibraryPath [ pkgsi686Linux.stdenv.cc.cc ]}
95
+
patchelf --set-interpreter "$interpreter" "$out/bin/brprintconf_dcpt310"
98
+
wrapProgram $out/bin/brprintconf_dcpt310 \
99
+
--set LD_PRELOAD "${pkgsi686Linux.libredirect}/lib/libredirect.so" \
100
+
--set NIX_REDIRECTS /opt=$out/opt
102
+
wrapProgram $out/opt/brother/Printers/dcpt310/lpd/brdcpt310filter \
111
+
--set LD_PRELOAD "${pkgsi686Linux.libredirect}/lib/libredirect.so" \
112
+
--set NIX_REDIRECTS /opt=$out/opt
115
+
$out/opt/brother/Printers/dcpt310/cupswrapper/brother_lpdwrapper_dcpt310 \
116
+
$out/opt/brother/Printers/dcpt310/lpd/filter_dcpt310 \
130
+
substituteInPlace $out/bin/brprintconf_dcpt310 \
131
+
--replace \"\$"@"\" \"\$"@\" | LD_PRELOAD= ${gnused}/bin/sed -E '/^(function list :|resource file :).*/{s#/opt#$out/opt#}'"
135
+
description = "Brother DCP-T310 printer driver";
136
+
license = with lib.licenses; [
140
+
sourceProvenance = with lib.sourceTypes; [
144
+
maintainers = with lib.maintainers; [ inexcode ];
149
+
homepage = "https://www.brother.com/";
150
+
downloadPage = "https://support.brother.com/g/b/downloadhowto.aspx?c=us_ot&lang=en&prod=dcpt310_all&os=128&dlid=dlf103618_000&flang=4&type3=10283";