-
-
Save jaen/a46ed2e3e3cb2f266a84298addd0f0d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/opt/brother/Printers/mfcj3930dw/lpd/brmfcj3930dwfilter b/opt/brother/Printers/mfcj3930dw/lpd/brmfcj3930dwfilter | |
| index 64114ab..6216f8b 100755 | |
| Binary files a/opt/brother/Printers/mfcj3930dw/lpd/brmfcj3930dwfilter and b/opt/brother/Printers/mfcj3930dw/lpd/brmfcj3930dwfilter differ | |
| diff --git a/opt/brother/Printers/mfcj3930dw/lpd/filter_mfcj3930dw b/opt/brother/Printers/mfcj3930dw/lpd/filter_mfcj3930dw | |
| index 3ae6723..1c49cfa 100755 | |
| --- a/opt/brother/Printers/mfcj3930dw/lpd/filter_mfcj3930dw | |
| +++ b/opt/brother/Printers/mfcj3930dw/lpd/filter_mfcj3930dw | |
| @@ -14,7 +14,7 @@ my $offset=""; | |
| my $HWMARGINS="yes"; | |
| -my $PRINTER = $0; | |
| +my $PRINTER = $ENV{PRINTER}; | |
| my $INPUT_TEMP=''; | |
| my $FILE_TYPE="PostScript"; | |
| my $LOGFILE = "/tmp/br_lpdfilter_ink.log"; | |
| @@ -45,7 +45,7 @@ sub logprint { | |
| -my $BR_PRT_PATH = Cwd::realpath ($0); | |
| +my $BR_PRT_PATH = Cwd::realpath ($ENV{BR_PRT_PATH}); | |
| $BR_PRT_PATH =~ s/$PRINTER\/lpd\/.*$/$PRINTER\//g; | |
| @@ -172,7 +172,7 @@ elsif ( $resolution eq "300" ){ | |
| logprint(1, "size_gs = $size_gs ,size_br = $size_br \n"); | |
| -my $GHOST_SCRIPT=`which gs`; | |
| +my $GHOST_SCRIPT="gs"; | |
| chomp($GHOST_SCRIPT); | |
| #my $OUTPUT_TYPE="bit"; | |
| @@ -227,13 +227,13 @@ elsif ( $DEBUG eq '2' ){ | |
| logprint(1, "file type = <$FILE_TYPE>\n"); | |
| if ( $FILE_TYPE eq "PDF\n" ){ | |
| - logprint(1, "/usr/bin/pdf2ps $INPUT_TEMP $TMP_PS\n"); | |
| + logprint(1, "pdf2ps $INPUT_TEMP $TMP_PS\n"); | |
| `cp $INPUT_TEMP /tmp/tmp.pdf`; | |
| $TMP_PS="/tmp/tmp.ps"; | |
| - `/usr/bin/pdf2ps $INPUT_TEMP $TMP_PS`; | |
| + `pdf2ps $INPUT_TEMP $TMP_PS`; | |
| `cat $TMP_PS| sed s/'%%HiResBoundingBox:'/'%HiResBoundingBox:'/g >> /tmp/br_lpdfilter_ink_gsout.dat`; | |
| logprint(1, " echo '<</ImagingBBox [$left $top $right $bottom] /PageOffset [-$left $top]>> setpagedevice' > /tmp/br_lpdfilter_ink_gsout.dat\n"); | |
| - logprint(1, " /usr/bin/pdf2ps $INPUT_TEMP $TMP_PS| cat $TMP_PS| sed s/'%%HiResBoundingBox:'/'%HiResBoundingBox:'/g > /tmp/br_lpdfilter_ink_gsout.dat\n"); | |
| + logprint(1, " pdf2ps $INPUT_TEMP $TMP_PS| cat $TMP_PS| sed s/'%%HiResBoundingBox:'/'%HiResBoundingBox:'/g > /tmp/br_lpdfilter_ink_gsout.dat\n"); | |
| }else{ | |
| `cat $INPUT_TEMP >> /tmp/br_lpdfilter_ink_gsout.dat`; | |
| @@ -272,7 +272,7 @@ else{ | |
| # `cp $INPUT_TEMP /tmp/tmp".pdf`; | |
| # `cp $INPUT_TEMP $TMP_PDF`; | |
| # $TMP_PS="/tmp/tmp.ps"; | |
| - `/usr/bin/pdf2ps $INPUT_TEMP $TMP_PS`; | |
| + `pdf2ps $INPUT_TEMP $TMP_PS`; | |
| `cat $TMP_PS| sed s/'%%HiResBoundingBox:'/'%HiResBoundingBox:'/g >>$TMP_PS1`; | |
| }else{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| lib, | |
| stdenv, | |
| fetchurl, | |
| makeWrapper, | |
| dpkg, | |
| cups, | |
| perl, | |
| coreutils, | |
| gnused, | |
| gnugrep, | |
| pkgs, | |
| mfcj3930dw-lpr | |
| }: | |
| let | |
| model = "mfcj3930dw"; | |
| wrapperDir = "opt/brother/Printers/${ model }/cupswrapper"; | |
| in | |
| stdenv.mkDerivation rec { | |
| pname = "${ model }-cupswrapper"; | |
| version = "1.0.1-0"; | |
| src = fetchurl { | |
| url = "https://download.brother.com/welcome/dlf103038/${ model }cupswrapper-${version}.i386.deb"; | |
| sha256 = "sha256-oAmM4tnWGzQ79yyxkxIV3SLrE3PL+VAQJ7dtU+lxTPI="; | |
| }; | |
| unpackCmd = "mkdir -p ./deb/; ${ dpkg }/bin/dpkg-deb -x $curSrc ./deb/"; | |
| nativeBuildInputs = [ makeWrapper ]; | |
| buildInputs = [ cups perl coreutils gnused gnugrep mfcj3930dw-lpr ]; | |
| patches = [ ./printer-regex.patch ]; | |
| patchPhase = '' | |
| patchPhase | |
| pushd "${ wrapperDir }" | |
| substituteInPlace "cupswrapper${ model }" \ | |
| --replace /usr/share/cups/model "$out/share/cups/model" \ | |
| --replace /usr/share/ppd "$out/share/ppd" \ | |
| --replace /usr/lib/cups/filter "$out/lib/cups/filter" \ | |
| --replace /usr/lib64/cups/filter "$out/lib64/cups/filter" \ | |
| --replace /opt "$out/opt" \ | |
| --replace /usr "$out/usr" \ | |
| --replace /etc "$out/etc" \ | |
| --replace "cp " "\cp -p " | |
| popd | |
| ''; | |
| installPhase = '' | |
| mkdir -p $out | |
| cp -a . $out | |
| sed -i '/\$DEBUG=0;/c\$DEBUG=1;' $out/${ wrapperDir }/brother_lpdwrapper_${ model } | |
| wrapProgram "$out/${ wrapperDir }/brother_lpdwrapper_${ model }" \ | |
| --inherit-argv0 \ | |
| --prefix PATH ":" ${ lib.makeBinPath [ coreutils gnugrep mfcj3930dw-lpr ] } | |
| # Link LPR things | |
| ln -s ${ mfcj3930dw-lpr }/opt/brother/Printers/mfcj3930dw/lpd $out/opt/brother/Printers/mfcj3930dw/lpd | |
| ln -s ${ mfcj3930dw-lpr }/opt/brother/Printers/mfcj3930dw/inf $out/opt/brother/Printers/mfcj3930dw/inf | |
| mkdir -p $out/share/cups/model/Brother/ | |
| ln -s $out/${ wrapperDir }/brother_${ model }_printer_en.ppd $out/share/cups/model/Brother/ | |
| mkdir -p $out/lib/cups/filter/ | |
| ln -s "$out/${ wrapperDir }/brother_lpdwrapper_${ model }" "$out/lib/cups/filter/" | |
| ''; | |
| meta = with lib; { | |
| homepage = "https://www.brother.com/"; | |
| description = "Brother MFC-J3930DW CUPS wrapper driver"; | |
| license = licenses.gpl2Only; | |
| platforms = platforms.linux; | |
| downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=${ model }_all&os=128&autolayerclose=1"; | |
| # maintainers = with maintainers; [ svavs ]; | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| lib, | |
| stdenv_32bit, | |
| fetchurl, | |
| glibc, | |
| cups, | |
| dpkg, | |
| ghostscript, | |
| a2ps, | |
| coreutils, | |
| gnused, | |
| gawk, | |
| file, | |
| gnugrep, | |
| makeWrapper, | |
| perl, | |
| buildFHSEnv | |
| }: | |
| let | |
| stdenv = stdenv_32bit; | |
| version = "1.0.1-0"; | |
| model = "mfcj3930dw"; | |
| driverDir = "opt/brother/Printers/${ model }"; | |
| debSrc = fetchurl { | |
| url = "https://download.brother.com/welcome/dlf103014/${ model }lpr-${ version }.i386.deb"; | |
| sha256 = "sha256-l3ViK3dJOXNhw6VsathXY/89x4NWHeZJ13qRK0RMAEc="; | |
| }; | |
| lpr-pkg = stdenv.mkDerivation rec { | |
| inherit version; | |
| pname = "${ model }-lpr-pkg"; | |
| src = debSrc; | |
| nativeBuildInputs = [ makeWrapper dpkg ]; | |
| buildInputs = [ cups perl ghostscript a2ps gnused coreutils ]; | |
| unpackCmd = "mkdir -p ./deb/; dpkg-deb -x $curSrc ./deb/"; | |
| installPhase = '' | |
| mkdir -p $out/${ driverDir } | |
| cp -a ${ driverDir }/. $out/${ driverDir }/ | |
| mkdir -p $out/bin | |
| cp -a usr/bin/. $out/bin/ | |
| ''; | |
| }; | |
| # The binary filter is a tool and has hardcoded paths to /opt/brother/Printers/ | |
| # So we just wrap it in FHS and call it a day | |
| infFhs = buildFHSEnv rec { | |
| name = "${ model }-lpd-inf-fhs"; | |
| targetPkgs = pkgs: with pkgs; [ | |
| lpr-pkg | |
| cups perl ghostscript a2ps gnused coreutils file | |
| ]; | |
| }; | |
| lpr = stdenv.mkDerivation rec { | |
| inherit version; | |
| pname = "${ model }-lpr"; | |
| src = debSrc; | |
| nativeBuildInputs = [ makeWrapper dpkg ]; | |
| buildInputs = [ cups perl ghostscript a2ps ]; | |
| unpackCmd = "mkdir -p ./deb/; dpkg-deb -x $curSrc ./deb/"; | |
| patches = [ ./fixups.patch ]; | |
| patchPhase = '' | |
| INTERPRETER="${ stdenv.cc.bintools.dynamicLinker }" | |
| patchPhase | |
| # Fix the driver binary | |
| patchelf \ | |
| --set-rpath "${ stdenv.cc.cc.lib }/lib" \ | |
| --set-interpreter "$INTERPRETER" \ | |
| ${ driverDir }/lpd/br${ model }filter | |
| # Fix brprintconf | |
| # TODO: there are strings in the file referring to /opt/brother/Printers/%s/inf/br | |
| # that would need fixing | |
| mkdir bin/ | |
| mv usr/bin/brprintconf_${ model } bin/ | |
| rm -rf usr/bin | |
| patchelf \ | |
| --set-rpath ${ stdenv.cc.cc.lib }/lib \ | |
| --set-interpreter "$INTERPRETER" \ | |
| bin/brprintconf_${ model } | |
| ''; | |
| installPhase = '' | |
| mkdir -p $out/${ driverDir }/lpd | |
| cp -a ${ driverDir }/lpd/. $out/${ driverDir }/lpd | |
| # Link inf directory | |
| ln -s ${ lpr-pkg }/opt/brother/Printers/mfcj3930dw/inf $out/opt/brother/Printers/mfcj3930dw/inf | |
| mkdir $out/bin | |
| cat > "$out/bin/brprintconf_${ model }" <<EOSH | |
| #!/bin/sh | |
| set -x | |
| exec "${ infFhs }/bin/${ model }-lpd-inf-fhs" -c "set -x; exec -a "brprintconf_${ model }" brprintconf_${ model } \"\\\$@\"" -- "\$@" | |
| EOSH | |
| chmod +x "$out/bin/brprintconf_mfcj3930dw" | |
| # Link bin | |
| ln -s ${ lpr-pkg }/bin $out/bin | |
| wrapProgram "$out/${ driverDir }/lpd/filter_${ model }" \ | |
| --set PRINTER "${ model }" \ | |
| --set BR_PRT_PATH "$out/${ driverDir }/lpd/filter_${ model }" \ | |
| --prefix PATH ":" ${ lib.makeBinPath [ ghostscript a2ps file gnused gnugrep coreutils ] } | |
| FILTER_FHS_WRAPPER="$out/${ driverDir }/lpd/br${ model }filter" | |
| FILTER_BINARY="$out/${ driverDir }/lpd/.br${ model }filter-wrapped" | |
| mv "$FILTER_FHS_WRAPPER" "$FILTER_BINARY" | |
| cat > "$FILTER_FHS_WRAPPER" <<EOSH | |
| #!/bin/sh | |
| set -x | |
| exec "${ infFhs }/bin/${ model }-lpd-inf-fhs" -c "set -x; exec -a "br${ model }filter" $FILTER_BINARY \"\\\$@\"" -- "\$@" | |
| EOSH | |
| chmod +x "$FILTER_FHS_WRAPPER" | |
| ''; | |
| meta = with lib; { | |
| homepage = "https://www.brother.com/"; | |
| description = "Brother MFC-J3930DW LPR driver"; | |
| license = licenses.unfree; | |
| platforms = platforms.linux; | |
| downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=${ model }_all&os=128&autolayerclose=1"; | |
| # maintainers = with maintainers; [ svavs ]; | |
| }; | |
| }; | |
| in | |
| lpr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/opt/brother/Printers/mfcj3930dw/cupswrapper/brother_lpdwrapper_mfcj3930dw b/opt/brother/Printers/mfcj3930dw/cupswrapper/brother_lpdwrapper_mfcj3930dw | |
| index 29b788d..1fc9861 100755 | |
| --- a/opt/brother/Printers/mfcj3930dw/cupswrapper/brother_lpdwrapper_mfcj3930dw | |
| +++ b/opt/brother/Printers/mfcj3930dw/cupswrapper/brother_lpdwrapper_mfcj3930dw | |
| @@ -85,7 +85,7 @@ if ( @ARGV >= 6 ){ | |
| } | |
| -$PRINTER =~ s/^\/opt\/.*\/Printers\///g; | |
| +$PRINTER =~ s/^(\/.*?)?\/opt\/.*\/Printers\///g; | |
| $PRINTER =~ s/\/cupswrapper//g; | |
| $PRINTER =~ s/\///g; | |
| @@ -507,7 +507,12 @@ unlink $LATESTINFO; | |
| my $TEMPRC = "/tmp/br".$PRINTER."rc_".$$; | |
| -`cp $basedir/inf/br${PRINTER}rc $TEMPRC`; | |
| +if( defined $ENV{BRPRINTERRCFILE} ) { | |
| + `cp $ENV{BRPRINTERRCFILE} $TEMPRC`; | |
| +} else { | |
| + `cp $basedir/inf/br${PRINTER}rc $TEMPRC`; | |
| +} | |
| + | |
| $ENV{BRPRINTERRCFILE} = $TEMPRC; | |
| logprint( 0 , "TEMPRC = $TEMPRC\n"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment