randombio.com | computer notes
Tuesday, October 27, 2020

Compiling LRP-NG

An alternative to CUPS, but tricky to compile

LPR-NG is a great alternative to CUPS for printing in Linux. It adheres to the original philosophy of not requiring hundreds of printer-specific drivers, which reduces the risk of finding ourselves with a printer we can't use because there's no Linux driver. However, LPR-NG is now very tricky to compile, at least in Debian 10.5.0. Here is a step-by-step procedure that works.

  1. Turn off CUPS and disable it.
    systemctl list-units | grep cups
    systemctl stop cups.service
    systemctl disable cups.service
    If you're running without systemd, a different procedure is needed.

  2. Download and unpack LPRng-3.8.28.tgz from www.lprng.com.
    tar -xzvf LPRng-3.8.28.tgz

  3. configure --disable-werror
    This step is needed because the new compiler is more finicky than before and flags bad code formatting and formerly common practices as errors.

  4. Edit Makefile and remove the quotation marks in line 48 so it says
    SHELL=/bin/sh

    If you miss this step, it bombs out saying:

    LPRng-3.8.35$ make
    if [ "UTILS" != po -o "yes" != "no" ] ; then \
    	cd UTILS; make localedir=/usr/local/share/locale \
    		DESTDIR= all ; \
    fi
    make: "/bin/sh": Command not found
    make: *** [Makefile:123: UTILS] Error 127
    
  5. Type make
    It will run for a while, then bomb out at the link stage with many lines like this:
    LPRng-3.8.35/libtool: 1: eval: libtool_args+=: not found
    LPRng-3.8.35/libtool: 1: eval: compile_command+=: not found
    LPRng-3.8.35/libtool: 1: eval: finalize_command+=: not found

    This is caused by the fact that /bin/sh is now a link to /bin/dash, which interferes with libtool. The solution is to rename the link and set a new link to /usr/bin/bash. This is a very risky thing to do: DO NOT log out of your terminal window until the new link is made or your OS will become inoperable.

    Complicating matters is that if you set /bin/sh to /usr/bin/bash before starting, LPRng won't compile at all. You will get an entirely different set of compilation errors. So here's what you do.
    su
    cd /bin
    mv sh sh.bak   <---DON'T LOG OUT OF ROOT AFTER THIS STEP!
    ln -s /usr/bin/bash sh
    ls -l sh
    It should be pointing to /usr/bin/bash. If not, type mv sh.bak sh and get advice.
    exit
    make clean
    make
    ls -lart src
    It should show lpr, lprm, lpc, etc.

    Now change /bin/sh back to dash
    su
    cd /bin
    mv sh sh.old    <---DO NOT TAKE A COFFEE BREAK AFTER THIS STEP!
    ln -s /bin/dash sh
    ls -l sh
    Make sure it points to /bin/dash before continuing.
    exit

    Now you can type make install as usual. It puts a sample printcap in /etc and the two config files lpd.conf and lpd.perms in /etc/lpd. It also creates a sample lpd script that goes in /etc/init.d that can be used to start and stop the lpd daemon safely.

Configure those files and you should be able to print to any PDF printer, no fancy drivers needed.

What we need for situations like this is for ln to be able to change a soft link without deleting it. Or, maybe what we really need is for people to stop improving things that used to work perfectly.


On the Internet, no one can tell whether you're a dolphin or a porpoise
oct 27, 2020

back

to top