14 stdenv.mkDerivation rec {
15 pname = "mfc465cncupswrapper";
19 url = "https://download.brother.com/welcome/dlf006134/${pname}-${version}.i386.deb";
20 sha256 = "59a62ed3cf10f1565c08ace55832bd48bd5034f7067662870edf7ff3bf0cb76a";
35 lpr=${mfc465cnlpr}/usr/local/Brother/Printer/mfc465cn
36 dir=$out/usr/local/Brother/Printer/mfc465cn
37 interpreter=${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2
38 patchelf --set-interpreter "$interpreter" "$dir/cupswrapper/brcupsconfpt1"
39 substituteInPlace $dir/cupswrapper/cupswrappermfc465cn \
40 --replace "mkdir -p /usr" ": # mkdir -p /usr" \
41 --replace '/''${printer_model}' "/mfc465cn" \
42 --replace 'br''${printer_model}' "brmfc465cn" \
43 --replace 'brlpdwrapper''${printer_model}' "brlpdwrappermfc465cn" \
44 --replace 'filter''${printer_model}' "filtermfc465cn" \
45 --replace ' ''${printer_name}' " MFC465CN" \
46 --replace ' ''${device_name}' " MFC-465CN" \
47 --replace '(''${device_name}' "(MFC-465CN" \
48 --replace ':''${device_name}' ":MFC-465CN" \
49 --replace '/''${device_name}' "/MFC-465CN" \
50 --replace 'BR''${pcfilename}' "BR465" \
51 --replace '/''${device_model}' "/Printer" \
52 --replace '/usr/lib64/cups/filter/brlpdwrappermfc465cn' "$out/lib/cups/filter/brlpdwrappermfc465cn" \
53 --replace '/usr/local/Brother/Printer/mfc465cn/lpd/filtermfc465cn' "$lpr/lpd/filtermfc465cn" \
54 --replace '/usr/share/ppd/brmfc465cn.ppd' "$dir/cupswrapper/brmfc465.ppd" \
55 --replace '/usr/share/cups/model/brmfc465cn.ppd' "$dir/cupswrapper/brmfc465.ppd" \
56 --replace '/usr/lib/cups/filter/brlpdwrappermfc465cn' "$out/usr/lib/cups/filter/brlpdwrappermfc465cn" \
57 --replace 'nup="psnup' "nup=\"${psutils}/bin/psnup" \
58 --replace '/usr/bin/psnup' "${psutils}/bin/psnup" \
59 --replace '/usr/local/Brother/Printer/mfc465cn/cupswrapper/brcupsconfpt1' "$dir/cupswrapper/brcupsconfpt1" \
60 --replace '/usr/local/Brother/Printer/mfc465cn/inf' "$lpr/inf"
61 # Create the PPD file from the cupswrapper file
62 sed -n '/ENDOFPPDFILE1/,/ENDOFPPDFILE1/p' "$dir/cupswrapper/cupswrappermfc465cn" | head -n -1 | tail -n +2 > $dir/cupswrapper/brmfc465.ppd
63 sed -n '/ENDOFPPDFILE_END/,/ENDOFPPDFILE_END/p' "$dir/cupswrapper/cupswrappermfc465cn" | head -n -1 | tail -n +2 >> $dir/cupswrapper/brmfc465.ppd
64 chmod 644 $dir/cupswrapper/brmfc465.ppd
65 mkdir -p $out/lib/cups/filter
66 mkdir -p $out/share/cups/model
67 ln $dir/cupswrapper/cupswrappermfc465cn $out/lib/cups/filter
68 ln $dir/cupswrapper/brmfc465.ppd $out/share/cups/model
69 sed -n '/!ENDOFWFILTER!/,/!ENDOFWFILTER!/p' "$dir/cupswrapper/cupswrappermfc465cn" | sed '1 br; b; :r s/.*/printer_model=mfc465cn; cat <<!ENDOFWFILTER!/' | bash > $out/lib/cups/filter/brlpdwrappermfc465cn
70 sed -i "/#! \/bin\/sh/a PATH=${lib.makeBinPath [ coreutils gnused gnugrep ]}:\$PATH" $out/lib/cups/filter/brlpdwrappermfc465cn
71 chmod 755 $out/lib/cups/filter/brlpdwrappermfc465cn
75 description = "Brother MFC-465CN CUPS wrapper driver";
76 homepage = "http://www.brother.com/";
77 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
78 license = licenses.gpl2Plus;
79 platforms = platforms.linux;
80 maintainers = with maintainers; [ phrogg ];