14 stdenv.mkDerivation rec {
15 pname = "mfc5890cncupswrapper";
19 url = "https://download.brother.com/welcome/dlf006170/${pname}-${version}.i386.deb";
20 hash = "sha256-UOCwzB09/a1/2rliY+hTrslSvO5ztVj51auisPx7OIQ=";
35 lpr=${mfc5890cnlpr}/usr/local/Brother/Printer/mfc5890cn
36 dir=$out/usr/local/Brother/Printer/mfc5890cn
38 interpreter=${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2
39 patchelf --set-interpreter "$interpreter" "$dir/cupswrapper/brcupsconfpt1"
41 #comment out lpadmin commands to prohibit changes to CUPS config by just installing this driver.
42 substituteInPlace $dir/cupswrapper/cupswrappermfc5890cn \
43 --replace "lpadmin" "#lpadmin" \
44 --replace "/usr/" "$out/usr/"
46 #mfc5890cnlpr is a dependency of this package. Link all files of mfc5890cnlpr into the $out/usr folder, as other scripts depend on these files being present.
47 #Ideally, we would use substituteInPlace for each file this package actually requires. But the scripts of Brother use variables to dynamically build the paths
48 #at runtime, making this approach more complex. Hence, the easier route of simply linking all files was choosen.
49 find "$lpr" -type f -exec sh -c "mkdir -vp \$(echo '{}' | sed 's|$lpr|$dir|g' | xargs dirname) && ln -s '{}' \$(echo '{}' | sed 's|$lpr|$dir|g')" \;
51 mkdir -p $out/usr/share/ppd/
52 mkdir -p $out/usr/lib64/cups/filter
53 sed -i '941,972d' $dir/cupswrapper/cupswrappermfc5890cn
54 $dir/cupswrapper/cupswrappermfc5890cn
56 chmod +x $out/usr/lib64/cups/filter/brlpdwrappermfc5890cn
57 wrapProgram $out/usr/lib64/cups/filter/brlpdwrappermfc5890cn --prefix PATH : ${lib.makeBinPath [coreutils psutils gnugrep gnused]}
59 mkdir -p $out/lib/cups/filter
60 mkdir -p $out/share/cups/model
61 ln $out/usr/lib64/cups/filter/brlpdwrappermfc5890cn $out/lib/cups/filter
62 ln $dir/cupswrapper/cupswrappermfc5890cn $out/lib/cups/filter
63 ln $out/usr/share/ppd/brmfc5890cn.ppd $out/share/cups/model
67 description = "Brother MFC-5890CN CUPS wrapper driver";
68 longDescription = "Brother MFC-5890CN CUPS wrapper driver. Use the connection string 'lpd://\${IP_ADDRESS}/binary_p1' when connecting to this printer via the network.";
69 homepage = "http://www.brother.com/";
70 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
71 license = licenses.gpl2Plus;
72 platforms = platforms.linux;
73 maintainers = with maintainers; [ martinramm ];