Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dcp385c-cupswrapper: init at 1.1.2 #367380

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/licenses.nix
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ lib.mapAttrs mkLicense ({
fullName = "Boost Software License 1.0";
};

brotherEula = {
fullName = "Brother License Agreement";
url = "https://support.brother.com/g/s/agreement/English_eula/agree.html";
free = false;
redistributable = true;
};

beerware = {
spdxId = "Beerware";
fullName = "Beerware License";
Expand Down
7 changes: 7 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13747,6 +13747,13 @@
githubId = 30194994;
name = "Felix Nilles";
};
marcin-serwin = {
name = "Marcin Serwin";
github = "marcin-serwin";
githubId = 12128106;
email = "[email protected]";
keys = [ { fingerprint = "F311 FA15 1A66 1875 0C4D A88D 82F5 C70C DC49 FD1D"; } ];
};
marcovergueira = {
email = "[email protected]";
github = "marcovergueira";
Expand Down
37 changes: 37 additions & 0 deletions pkgs/by-name/dc/dcp385c-brprintconf/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
lib,
stdenv,
fetchFromSourcehut,
dcp385c-lpr,
}:
stdenv.mkDerivation {
pname = "dcp385c-brprintconf";
version = "1.1.2+1";

src = fetchFromSourcehut {
owner = "~marcin-serwin";
repo = "brprintconf";
rev = "6a1b9bf9de86ca15ca030a6a962ae5d9c2db8ad4";
hash = "sha256-hgVcFDAnHT3+0Yj276tcwD6xp8YNWN7S0WW8QGCy2hI=";
};

postPatch = ''
reldir='local/Brother/Printer/%s/inf'

substituteInPlace brprintconf_dcp385c.c \
--replace-fail "/usr/$reldir/br%sfunc" "${dcp385c-lpr}/$reldir/br%sfunc" \
--replace-fail "/usr/$reldir/br%src" "/var/cache/cups/br%src"
'';

installFlags = [ "PREFIX=$(out)" ];

meta = {
homepage = "https://git.sr.ht/~marcin-serwin/brprintconf";
description = "Decompiled source of brprintconf_dcp385c";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about having this in Nixpkgs — decompiled proprietary software is pretty legally dubious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EULA explicitly grants us the right to "modify, alter, translate or otherwise prepare derivative works of the Software and to reproduce and distribute [...] derivative works for any purpose." IANAL but I think decompilation should be covered by this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's very interesting, and not at all what I want expecting from a EULA, although the presence of the GPL below might explain some things.

In that case, what was it about the EULA that you identified as non-free?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The drivers distributed under the EULA typically do not have their source code available and it states that the license should not "be construed as Brother's implied agreement or undertakings to disclose and/or distribute the source code of the Software."

Moreover there is no mention whether the user may sell the software, which is usually present in similar licenses, though perhaps "distribute" covers this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The drivers distributed under the EULA typically do not have their source code available and it states that the license should not "be construed as Brother's implied agreement or undertakings to disclose and/or distribute the source code of the Software."

That's true, but is sort of orthogonal to license. I can license a binary under the MIT license without providing source code, and while that makes my software non-free, it doesn't make the MIT license a non-free license.

Moreover there is no mention whether the user may sell the software, which is usually present in similar licenses, though perhaps "distribute" covers this.

Hmm yeah, I'm not sure. Would be good to get another opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, but is sort of orthogonal to license. I can license a binary under the MIT license without providing source code, and while that makes my software non-free, it doesn't make the MIT license a non-free license.

Yeah, I noticed that but, as I understand it, the nixpkgs ecosystem doesn't have a way to express the "freeness"/source availability of a given package irrespective of its license. The dcp385c-lpr is definitely non-free software but if we change the EULA to be a free license it will be marked as free.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can additionally be marked with lib.licenses.unfree.

Copy link
Contributor Author

@marcin-serwin marcin-serwin Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but that just seems like a workaround to me since there are no unfree licenses present in the package. This would also be needed by nearly every package using this license since its purpose is to distribute proprietary software.

Personally, I'd rather leave it as unfree regardless of the unclear commercial rights. It's not approved by FSF or OSI and it will likely never be. We can add a comment near it which summarizes this conversation. If someone needs to override this then it's always possible to do brotherEula // { free = true; } and this will be less work than adding lib.licenses.unfree everywhere else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not sure. I'd like to hear more opinions on what to do here.

license = with lib.licenses; [
cc0
brotherEula
];
platforms = lib.platforms.linux;
};
}
70 changes: 70 additions & 0 deletions pkgs/by-name/dc/dcp385c-cupswrapper/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
stdenv,
lib,
fetchzip,
makeWrapper,
gnused,
gnugrep,
coreutils,
dcp385c-lpr,
dcp385c-brprintconf,
}:
let
version = "1.1.2";
model = "dcp385c";
installscript = "SCRIPT/cupswrapperdcp385c";
in
stdenv.mkDerivation {
pname = "${model}-cupswrapper";
inherit version;

src = fetchzip {
url = "https://download.brother.com/welcome/dlf006678/brcups_ink4_src_1.1.2-x.tar.gz";
hash = "sha256-2XzBF3weIlZ2g2IXFv2PE8jVXkhybrMni6jtNjkmF7I=";
};

nativeBuildInputs = [ makeWrapper ];
unpackPhase = ''
tar xzf $src/cupswrapperdcp385c_src-1.1.2-2.tar.gz
sourceRoot=cupswrapperdcp385c_src
'';

patchPhase = ''
patch ${installscript} ${./replace-absolute-paths.patch}
substituteInPlace ${installscript} \
--subst-var out \
--subst-var-by lpr ${dcp385c-lpr} \
'';

buildPhase = ''
$CC brcupsconfigpt1/brcupsconfig.c -o brcupsconfig
'';

installPhase = ''
install -D brcupsconfig $out/local/Brother/Printer/dcp385c/cupswrapper/brcupsconfpt1

mkdir -p $out/share/cups/model
mkdir -p $out/lib/cups/filter
sh ${installscript}
'';

fixupPhase = ''
wrapProgram $out/lib/cups/filter/brlpdwrapperdcp385c \
--prefix PATH ":" ${
lib.makeBinPath [
gnused
gnugrep
coreutils
dcp385c-brprintconf
]
}
'';

meta = {
homepage = "http://www.brother.com/";
description = "Brother ${model} printer CUPS wrapper driver";
license = lib.licenses.gpl2Plus;
platforms = lib.platforms.linux;
downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=gb&lang=en&prod=${model}_all&os=128";
};
}
162 changes: 162 additions & 0 deletions pkgs/by-name/dc/dcp385c-cupswrapper/replace-absolute-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
--- cupswrapperdcp385c.orig 2008-11-18 10:31:13.000000000 +0100
+++ cupswrapperdcp385c 2024-06-22 21:09:26.993494135 +0200
@@ -25,11 +25,11 @@
device_model="Printer"
if [ "$1" = '-e' ]; then
lpadmin -x ${printer_name}
- rm -f /usr/share/cups/model/br${printer_model}.ppd
- rm -f /usr/share/ppd/br${printer_model}.ppd
- rm -f /usr/lib/cups/filter/brlpdwrapper${printer_model}
- rm -f /usr/lib64/cups/filter/brlpdwrapper${printer_model}
- rm -f /usr/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1
+ rm -f @lpr@/share/cups/model/br${printer_model}.ppd
+ rm -f @lpr@/share/ppd/br${printer_model}.ppd
+ rm -f @out@/lib/cups/filter/brlpdwrapper${printer_model}
+ rm -f @out@/lib64/cups/filter/brlpdwrapper${printer_model}
+ rm -f @out@/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1
if [ -e /etc/init.d/cups ]; then
/etc/init.d/cups restart
elif [ -e /etc/init.d/cupsys ]; then
@@ -55,21 +55,21 @@
echo ' -r : remove printer'
exit 0
fi
-#mkdir -p /usr/local/Brother/${device_model}/${printer_model}/filter
-#mkdir -p /usr/lib/cups/filter
+#mkdir -p @lpr@/local/Brother/${device_model}/${printer_model}/filter
+#mkdir -p @lpr@/lib/cups/filter

-if [ -e "/usr/local/Brother/${device_model}/${printer_model}/lpd/filter${printer_model}" ]; then
+if [ -e "@lpr@/local/Brother/${device_model}/${printer_model}/lpd/filter${printer_model}" ]; then
:
else
echo "ERROR : Brother LPD filter is not installed."
fi
-rm -f /usr/share/cups/model/br${printer_model}.ppd
-if [ -d "/usr/share/cups/model" ]; then
- ppd_file_name=/usr/share/cups/model/br${printer_model}.ppd
+rm -f @out@/share/cups/model/br${printer_model}.ppd
+if [ -d "@out@/share/cups/model" ]; then
+ ppd_file_name=@out@/share/cups/model/br${printer_model}.ppd
else
- ppd_file_name=/usr/share/ppd/br${printer_model}.ppd
+ ppd_file_name=@out@/share/ppd/br${printer_model}.ppd
fi
-#ppd_file_name=/usr/share/cups/model/br${printer_model}.ppd
+#ppd_file_name=@out@/share/cups/model/br${printer_model}.ppd

cat <<ENDOFPPDFILE1 >$ppd_file_name
*PPD-Adobe: "4.3"
@@ -699,27 +699,27 @@

chmod 644 $ppd_file_name

-if [ -d /usr/share/ppd ]
+if [ -d @out@/share/ppd ]
then
-if [ -d /usr/share/cups/model ]
+if [ -d @out@/share/cups/model ]
then
- cp $ppd_file_name /usr/share/ppd/br${printer_model}.ppd
- chmod 644 /usr/share/ppd/br${printer_model}.ppd
+ cp $ppd_file_name @out@/share/ppd/br${printer_model}.ppd
+ chmod 644 @out@/share/ppd/br${printer_model}.ppd
fi
fi

#################################################

-if [ -d /usr/lib/cups/filter ]
+if [ -d @out@/lib/cups/filter ]
then
- brotherlpdwrapper=/usr/lib/cups/filter/brlpdwrapper${printer_model}
+ brotherlpdwrapper=@out@/lib/cups/filter/brlpdwrapper${printer_model}
else
- brotherlpdwrapper=/usr/lib64/cups/filter/brlpdwrapper${printer_model}
+ brotherlpdwrapper=@out@/lib64/cups/filter/brlpdwrapper${printer_model}
fi


rm -f $brotherlpdwrapper
-#echo 'rm -f /usr/lib/cups/filter/brlpdwrapper${printer_model}'
+#echo 'rm -f @out@/lib/cups/filter/brlpdwrapper${printer_model}'


cat <<!ENDOFWFILTER! >$brotherlpdwrapper
@@ -759,7 +759,7 @@
PPDC=\`echo \$PPDC | sed -e 's/PPD=//'\`

if [ "\$PPDC" = "" ]; then
- PPDC="/usr/share/cups/model/br${printer_model}.ppd"
+ PPDC="@lpr@/share/cups/model/br${printer_model}.ppd"
fi


@@ -784,6 +784,10 @@
echo "PPD = \$PPD" >>\$LOGFILE
fi

+if ! [ -e /var/cache/cups/br${printer_model}rc ]; then
+ echo "creating rc file" >>\$LOGFILE
+ cp @lpr@/local/Brother/${device_model}/${printer_model}/inf/br${printer_model}rc /var/cache/cups/br${printer_model}rc
+fi
INPUT_TEMP_PS=\`mktemp /tmp/br_input_ps.XXXXXX\`

nup="cat"
@@ -809,7 +813,7 @@
nup="cat"
fi
echo "NUP=\$nup" >>\$LOGFILE
- if [ -e /usr/bin/psnup ]; then
+ if [ -e @lpr@/bin/psnup ]; then
if [ \$# -ge 7 ]; then
cat \$6 | \$nup > \$INPUT_TEMP_PS
else
@@ -829,25 +833,25 @@
cat > \$INPUT_TEMP_PS
fi
fi
-if [ -e "/usr/local/Brother/${device_model}/${printer_model}/lpd/filter${printer_model}" ]; then
+if [ -e "@lpr@/local/Brother/${device_model}/${printer_model}/lpd/filter${printer_model}" ]; then
:
else
- echo "ERROR: /usr/local/Brother/${device_model}/${printer_model}/lpd/filter${printer_model} does not exist" >>\$LOGFILE
+ echo "ERROR: @lpr@/local/Brother/${device_model}/${printer_model}/lpd/filter${printer_model} does not exist" >>\$LOGFILE
errorcode=30
exit
fi

CUPSOPTION=\`echo "\$5 Copies=\$4" | sed -e 's/BrMirror=OFF/MirrorPrint=OFF/' -e 's/BrMirror=ON/MirrorPrint=ON/' -e 's/BrChain/Chain/' -e 's/BrBrightness/Brightness/' -e 's/BrContrast/Contrast/' -e 's/BrHalfCut/HalfCut/' -e 's/BrAutoTapeCut/AutoCut/' -e 's/BrHalftonePattern/Halftone/' -e 's/Binary/Binary/' -e 's/Dither/Dither/' -e 's/ErrorDiffusion/ErrorDiffusion/' -e 's/PageSize/media/' -e 's/BrSheets/Sheets/' -e 's/multiple-document-handling/Collate/' -e 's/separate-documents-collated-copies/ON/' -e 's/separate-documents-uncollated-copies/OFF/'\`
-if [ -e "/usr/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1" ]; then
+if [ -e "@out@/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1" ]; then
if [ \$DEBUG = 0 ]; then
- /usr/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1 ${printer_name} \$PPDC 0 "\$CUPSOPTION" "${printer_model}">> /dev/null
+ @out@/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1 ${printer_name} \$PPDC 0 "\$CUPSOPTION" "${printer_model}">> /dev/null
else
- /usr/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1 ${printer_name} \$PPDC \$LOGCLEVEL "\$CUPSOPTION" "${printer_model}">>\$LOGFILE
+ @out@/local/Brother/${device_model}/${printer_model}/cupswrapper/brcupsconfpt1 ${printer_name} \$PPDC \$LOGCLEVEL "\$CUPSOPTION" "${printer_model}">>\$LOGFILE
fi
fi

if [ \$DEBUG -lt 10 ]; then
- cat \$INPUT_TEMP_PS | /usr/local/Brother/${device_model}/${printer_model}/lpd/filter${printer_model} "\$\$" "CUPS" "USB"
+ cat \$INPUT_TEMP_PS | @lpr@/local/Brother/${device_model}/${printer_model}/lpd/filter${printer_model} "\$\$" "CUPS" "USB"

if [ \$LOGLEVEL -gt 2 ]; then
if [ \$LOGFILE != "/dev/null" ]; then
@@ -864,12 +868,12 @@
!ENDOFWFILTER!

chmod 755 $brotherlpdwrapper
-#if [ -e /usr/lib64/cups/backend ]; then
+#if [ -e @lpr@/lib64/cups/backend ]; then
# cp $brotherlpdwrapper $brotherlpdwrapper64
#fi

-chmod a+w /usr/local/Brother/${device_model}/${printer_model}/inf/br${printer_model}rc
-chmod a+w /usr/local/Brother/${device_model}/${printer_model}/inf
+chmod a+w @lpr@/local/Brother/${device_model}/${printer_model}/inf/br${printer_model}rc
+chmod a+w @lpr@/local/Brother/${device_model}/${printer_model}/inf
if [ -e /etc/init.d/lpd ]; then
/etc/init.d/lpd stop
fi
78 changes: 78 additions & 0 deletions pkgs/by-name/dc/dcp385c-lpr/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
lib,
stdenv,
fetchurl,
makeWrapper,
pkgsi686Linux,
ghostscript,
file,
a2ps,
which,
}:

let
version = "1.1.2";
model = "dcp385c";
in
stdenv.mkDerivation {
pname = "${model}-lpr";
inherit version;

src = fetchurl {
url = "https://download.brother.com/welcome/dlf005395/${model}lpr-${version}-2.i386.deb";
hash = "sha256-Y2lBU42fYXLG9D2qeUeG/sTpIIU8iHxyPALJUeZvHEk=";
};

nativeBuildInputs = [ makeWrapper ];

unpackPhase = ''
ar x $src
tar xvzf data.tar.gz
sourceRoot=usr
'';

patchPhase = ''
substituteInPlace local/Brother/Printer/dcp385c/lpd/filterdcp385c \
--replace-fail /usr $out \
--replace-fail '$BR_PRT_PATH/inf/brPRINTERrc' '/var/cache/cups/brPRINTERrc'
'';

installPhase = ''
cp -r . $out
'';

fixupPhase = ''
wrapProgram $out/local/Brother/Printer/dcp385c/lpd/filterdcp385c \
--prefix PATH ":" ${
lib.makeBinPath [
file
a2ps
]
}

wrapProgram $out/local/Brother/Printer/dcp385c/lpd/psconvertij2 \
--prefix PATH ":" ${
lib.makeBinPath [
which
ghostscript
]
}

interpreter="${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2"

patchelf --set-interpreter $interpreter \
$out/bin/brprintconf_dcp385c

patchelf --set-interpreter $interpreter \
$out/local/Brother/Printer/dcp385c/lpd/brdcp385cfilter
'';

meta = {
homepage = "http://www.brother.com/";
description = "Brother ${model} printer driver";
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
license = lib.licenses.brotherEula;
platforms = lib.platforms.linux;
downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=gb&lang=en&prod=${model}_all&os=128";
};
}
Loading