2021-01-15 13:21:58 +00:00
|
|
|
{ lib, stdenv, fetchurl, makeWrapper, cups, perl, coreutils, gnused, gnugrep
|
2016-04-16 04:50:05 +01:00
|
|
|
, brgenml1lpr, debugLvl ? "0"}:
|
2016-03-06 00:34:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
[Setup instructions](http://support.brother.com/g/s/id/linux/en/instruction_prn1a.html).
|
|
|
|
|
|
|
|
URI example
|
|
|
|
~ `lpd://BRW0080927AFBCE/binary_p1`
|
|
|
|
|
|
|
|
Logging
|
|
|
|
-------
|
2016-05-04 11:08:35 +01:00
|
|
|
|
2016-03-06 00:34:08 +00:00
|
|
|
`/tmp/br_cupswrapper_ml1.log` when `DEBUG > 0` in `brother_lpdwrapper_BrGenML1`.
|
|
|
|
Note that when `DEBUG > 1` the wrapper stops performing its function. Better
|
|
|
|
keep `DEBUG == 1` unless this is desirable.
|
|
|
|
|
|
|
|
Now activable through this package's `debugLvl` parameter whose value is to be
|
|
|
|
used to establish `DEBUG`.
|
|
|
|
|
|
|
|
Issues
|
|
|
|
------
|
|
|
|
|
|
|
|
1. > Error: /tmp/brBrGenML1rc_15642 :cannot open file !!
|
|
|
|
|
2016-04-16 04:50:05 +01:00
|
|
|
Fixed.
|
2016-03-06 00:34:08 +00:00
|
|
|
|
|
|
|
2. > touch: cannot touch '/tmp/BrGenML1_latest_print_info': Permission denied
|
|
|
|
|
2016-04-16 04:50:05 +01:00
|
|
|
Fixed.
|
2016-03-06 00:34:08 +00:00
|
|
|
|
|
|
|
3. > perl: warning: Falling back to the standard locale ("C").
|
2016-05-04 11:08:35 +01:00
|
|
|
|
2016-03-06 00:34:08 +00:00
|
|
|
are supported and installed on your system.
|
|
|
|
LANG = "en_US.UTF-8"
|
|
|
|
LC_ALL = (unset),
|
|
|
|
LANGUAGE = (unset),
|
|
|
|
perl: warning: Please check that your locale settings:
|
|
|
|
perl: warning: Setting locale failed.
|
|
|
|
|
|
|
|
TODO: Address.
|
2016-04-16 04:50:05 +01:00
|
|
|
|
|
|
|
4. Since nixos 16.03 release, in `brother_lpdwrapper_BrGenML1`:
|
|
|
|
|
|
|
|
> sh: grep: command not found
|
|
|
|
sh: chmod: command not found
|
|
|
|
sh: cp: command not found
|
|
|
|
Error: /tmp/brBrGenML1rc_1850 :cannot open file !!
|
|
|
|
sh: sed: command not found
|
|
|
|
|
|
|
|
Fixed by use of a wrapper that brings `coreutils`, `gnused`, `gnugrep`
|
|
|
|
in `PATH`.
|
2016-03-06 00:34:08 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
|
|
|
|
name = "brgenml1cupswrapper-3.1.0-1";
|
|
|
|
src = fetchurl {
|
2018-06-28 19:43:35 +01:00
|
|
|
url = "https://download.brother.com/welcome/dlf101125/${name}.i386.deb";
|
2016-03-06 00:34:08 +00:00
|
|
|
sha256 = "0kd2a2waqr10kfv1s8is3nd5dlphw4d1343srdsbrlbbndja3s6r";
|
|
|
|
};
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
ar x $src
|
|
|
|
tar xfvz data.tar.gz
|
|
|
|
'';
|
|
|
|
|
2016-04-16 04:50:05 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [ cups perl coreutils gnused gnugrep brgenml1lpr ];
|
|
|
|
|
2016-05-04 11:08:35 +01:00
|
|
|
dontBuild = true;
|
2016-03-06 00:34:08 +00:00
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
WRAPPER=opt/brother/Printers/BrGenML1/cupswrapper/brother_lpdwrapper_BrGenML1
|
2016-05-04 11:08:35 +01:00
|
|
|
PAPER_CFG=opt/brother/Printers/BrGenML1/cupswrapper/paperconfigml1
|
2016-03-06 00:34:08 +00:00
|
|
|
|
|
|
|
substituteInPlace $WRAPPER \
|
|
|
|
--replace "basedir =~" "basedir = \"${brgenml1lpr}/opt/brother/Printers/BrGenML1\"; #" \
|
|
|
|
--replace "PRINTER =~" "PRINTER = \"BrGenML1\"; #" \
|
|
|
|
--replace "\$DEBUG=0;" "\$DEBUG=${debugLvl};"
|
|
|
|
|
2016-04-16 04:50:05 +01:00
|
|
|
# Fixing issue #1 and #2.
|
2016-03-06 00:34:08 +00:00
|
|
|
substituteInPlace $WRAPPER \
|
|
|
|
--replace "\`cp " "\`cp -p " \
|
|
|
|
--replace "\$TEMPRC\`" "\$TEMPRC; chmod a+rw \$TEMPRC\`" \
|
|
|
|
--replace "\`mv " "\`cp -p "
|
|
|
|
|
|
|
|
# This config script make this assumption that the *.ppd are found in a global location `/etc/cups/ppd`.
|
|
|
|
substituteInPlace $PAPER_CFG \
|
|
|
|
--replace "/etc/cups/ppd" "$out/share/cups/model"
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
2016-04-16 04:50:05 +01:00
|
|
|
installPhase = ''
|
|
|
|
CUPSFILTER_DIR=$out/lib/cups/filter
|
|
|
|
CUPSPPD_DIR=$out/share/cups/model
|
|
|
|
CUPSWRAPPER_DIR=opt/brother/Printers/BrGenML1/cupswrapper
|
|
|
|
|
|
|
|
mkdir -p $out/$CUPSWRAPPER_DIR
|
|
|
|
cp -rp $CUPSWRAPPER_DIR/* $out/$CUPSWRAPPER_DIR
|
|
|
|
|
|
|
|
mkdir -p $CUPSFILTER_DIR
|
|
|
|
# Fixing issue #4.
|
|
|
|
makeWrapper \
|
|
|
|
$out/$CUPSWRAPPER_DIR/brother_lpdwrapper_BrGenML1 \
|
|
|
|
$CUPSFILTER_DIR/brother_lpdwrapper_BrGenML1 \
|
|
|
|
--prefix PATH : ${coreutils}/bin \
|
|
|
|
--prefix PATH : ${gnused}/bin \
|
|
|
|
--prefix PATH : ${gnugrep}/bin
|
|
|
|
|
|
|
|
mkdir -p $CUPSPPD_DIR
|
|
|
|
ln -s $out/$CUPSWRAPPER_DIR/brother-BrGenML1-cups-en.ppd $CUPSPPD_DIR
|
2016-03-06 00:34:08 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
dontPatchELF = true;
|
2016-04-16 04:50:05 +01:00
|
|
|
dontStrip = true;
|
2016-03-06 00:34:08 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Brother BrGenML1 CUPS wrapper driver";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "http://www.brother.com";
|
2021-01-15 13:21:58 +00:00
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
license = lib.licenses.gpl2Plus;
|
|
|
|
maintainers = with lib.maintainers; [ jraygauthier ];
|
2016-03-06 00:34:08 +00:00
|
|
|
};
|
|
|
|
}
|