Print via Brother BR-Script3 PostScript instead of the vendor driver

The HL-4150CDN emulates PostScript 3, so CUPS converts client documents to PostScript and forwards them to socket://<ip>:9100. The official BR-Script3 PPD turns device options (tray, duplex, colour, media type, toner save, ...) into setpagedevice instructions. This drops the i386 multiarch runtime and the broken Brother vendor filter chain, and removes the unused Brother Linux packages from the repo.
This commit is contained in:
juergen committed 2026-10-18 16:54:33 +02:00
1 parent 6f3162849b
commit 30c685e085
22 files changed
+1070 -273

No files matched your search

+25 -41
View File
@@ -7,28 +7,32 @@
# printer is described by environment variables:
#
# podman run --rm --network host \
# -e PRINTER_IP=192.168.1.50 \
# -e PRINTER_IP=192.168.100.7 \
# -e PRINTER_NAME=HL-4150CDN \
# --name printserver printserver:latest
#
# PRINTER_URI can be used instead of PRINTER_IP for full control:
#
# -e PRINTER_URI=lpd://192.168.1.50/binary_p1
# -e PRINTER_URI=lpd://192.168.100.7/binary_p1
#
# The HL-4150CDN emulates BR-Script3 (PostScript 3). Jobs are converted to
# PostScript inside CUPS and forwarded to the printer unchanged; the official
# BR-Script3 PPD turns the queue's options (tray, duplex, colour, ...) into
# PostScript "setpagedevice" instructions. No Brother vendor binaries or 32-bit
# libraries are involved.
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
# --- Task 2.1 / 2.2: base system, CUPS, Avahi, DBus and i386 runtime -------
# The Brother filter binaries are 32-bit i386 ELF executables, so the i386
# architecture has to be enabled and the matching runtime libraries installed.
RUN dpkg --add-architecture i386 \
&& apt-get update \
# --- Task 3.1: base system, CUPS, Avahi, DBus and conversion filters -------
# cups-filters provides the PDF/PWG/URF -> PostScript filters used for
# driverless clients (AirPrint/IPP Everywhere). Ghostscript and Poppler supply
# the underlying converters.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
cups \
cups-client \
cups-filters \
cups-ppdc \
avahi-daemon \
avahi-utils \
libnss-mdns \
@@ -36,43 +40,23 @@ RUN dpkg --add-architecture i386 \
procps \
curl \
ghostscript \
ca-certificates \
poppler-utils \
libc6:i386 \
libstdc++6:i386 \
libgcc-s1:i386 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Make sure the 32-bit dynamic loader the Brother binaries ask for exists,
# even if the i386 libc places it only in the multiarch directory.
RUN if [ ! -e /lib/ld-linux.so.2 ] && [ -e /lib/i386-linux-gnu/ld-linux.so.2 ]; then \
ln -s /lib/i386-linux-gnu/ld-linux.so.2 /lib/ld-linux.so.2; \
fi \
&& test -e /lib/ld-linux.so.2
# --- Task 2.3: install the Brother HL-4150CDN driver packages --------------
# Copy the local driver packages from the repository into the build context and
# install them. The LPR package must be installed before the CUPS wrapper
# package, which depends on it. `--force-all` is used because the packages are
# built for i386 and have no dependency information Debian can satisfy here.
# --- Task 3.2: install the BR-Script3 PostScript PPD -----------------------
# The PPD encodes every device option (paper source, duplex, colour/mono,
# media type, toner save, resolution, secure print) as PostScript
# "setpagedevice". CUPS's pstops filter injects the selected option code and
# the PPD's JCL entries wrap the job in PJL for the printer.
# The whole assets tree is copied because the directory name contains a space,
# which some COPY implementations cannot quote.
COPY assets /tmp/assets
RUN mkdir -p /var/spool/lpd \
&& dpkg -i --force-all "/tmp/assets/Brother HL-4150CDN/lpr-driver/hl4150cdnlpr-1.1.1-5.i386.deb" \
&& dpkg -i --force-all "/tmp/assets/Brother HL-4150CDN/cupswrapper/hl4150cdncupswrapper-1.1.1-5.i386.deb" \
&& dpkg -s hl4150cdnlpr:i386 hl4150cdncupswrapper:i386 >/dev/null \
&& rm -rf /tmp/assets
# --- Task 2.4: configure CUPS and verify the driver files are in place -----
# The CUPS wrapper postinst copies the PPD into the CUPS model directory and
# creates the brlpdwrapper filter. Fail the build if anything is missing.
RUN test -f /usr/share/cups/model/brhl4150cdn.ppd \
&& test -x /usr/lib/cups/filter/brlpdwrapperhl4150cdn \
&& test -x /usr/local/Brother/Printer/hl4150cdn/lpd/brhl4150cdnfilter \
&& mkdir -p /usr/share/ppd \
&& ln -sf /usr/share/cups/model/brhl4150cdn.ppd /usr/share/ppd/brhl4150cdn.ppd \
RUN install -m 0644 \
"/tmp/assets/Brother HL-4150CDN/ppd/BR4150_2.PPD" \
/usr/share/cups/model/BR4150_2.PPD \
&& test -s /usr/share/cups/model/BR4150_2.PPD \
&& rm -rf /tmp/assets \
&& rm -f /etc/cups/printers.conf /etc/cups/printers.conf.O
COPY cupsd.conf /etc/cups/cupsd.conf
@@ -80,11 +64,11 @@ COPY cupsd.conf /etc/cups/cupsd.conf
# CUPS needs the runtime directories to exist in the image.
RUN mkdir -p /run/cups /run/dbus /run/avahi-daemon /var/spool/cups /var/log/cups
# --- Task 2.5: startup script -----------------------------------------------
# --- Task 3.5: startup script ----------------------------------------------
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod 0755 /usr/local/bin/entrypoint.sh
# --- Task 2.6: exposed ports ------------------------------------------------
# --- Task 3.6: exposed ports -----------------------------------------------
# 631/tcp CUPS administration and IPP
# 5353/udp mDNS / DNS-SD for AirPrint discovery
EXPOSE 631/tcp