Saturday, December 20, 2008

Linux printing again

Clunky - Clumsy in form or manner; awkward
Unwieldy - Difficult to manage because of complexity
Bunglesome - Difficult to handle or manage
Graceful - Once it has been installed properly

Many times I have installed printing on linux and I have not thought the process to be elegant and graceful. During the process, the word clunky comes to mind most frequently.

As mentioned in this lfs hint:
"... spending endless days wading through the reams of printing documentation available on the web ... most of it is completely useless to the average user."

To pile more complexity on an already too-complex situation comes HP to supply ppd files in a non-traditional format in later revisions of hplip (at least later than hplip-1.7.1) and they require a special foomatic-rip-hplip script (somehow, I don't like that).
The Portability Reference | HPLIP states that "static PPDs included in the tar ball are not compatible with older versions of foomatic-rip", however they give no clue as to what "older" means and they tell that "The user must manually change the *cupsFilter line from foomatic-rip-hpijs to foomatic-rip for all HPIJS PPDs before make install."

However, foomatic provides ppd files for HP and others that work with the foomatic-rip script from foomatic. The only part really needed from the hplip package is the hpijs program. The foomatic-rip script is provided in the foomatic-filters-ppd package but clumsily, does not get set up correctly which necessitates either using hacker intuition, or installing the foomatic-filters-3.0 package.

Gutenprint was formerly called gimp-print, and I'll go along with that for now.

This is my latest attempt to do an un-clunky installation of printing on linux. (I do this whole thing logged on as root. If that's bad, I'm bad.)

NOTICE: Line wrap problems
Where a line ends with a backward slash \
it means the next line is part of the same line.

SOURCES=/sources

# PACKAGE NAME: cups-1.2.12
URL="ftp://anduin.linuxfromscratch.org/BLFS/\
conglomeration/cups/cups-1.2.12-source.tar.bz2"
PATCH1="http://www.linuxfromscratch.org/patches/\
blfs/6.3/cups-1.2.12-security_fixes-2.patch"
cd $SOURCES
wget -c $URL
wget -c $PATCH1
UNPACKED=$(tar -tf $(basename $URL) \
| sed -e "1 {s,/.*,,;q}")
rm -rf $UNPACKED
tar -xf $(basename $URL)
cd $UNPACKED
useradd -c "Print Service User" \
-d /dev/null -g lp -s /bin/false -u 9 lp \
|| echo "user lp already exists"
patch -Np1 -i ../cups-1.2.12-security_fixes-2.patch
./configure
make
make install
cd $SOURCES
rm -rf $UNPACKED
# I omitted installation of cups man pages for now.
# That part could be done later.
# man lp is enough for simple commands.
# Plus, the cups page localhost:631
# provides access to cups man pages.

# PACKAGE NAME: cups-bootscripts-20080816
URL="http://www.linuxfromscratch.org/blfs/downloads/\
6.3/blfs-bootscripts-20080816.tar.bz2"
cd $SOURCES
wget -c $URL
UNPACKED=$(tar -tf $(basename $URL) \
| sed -e "1 {s,/.*,,;q}")
rm -rf $UNPACKED
tar -xf $(basename $URL)
cd $UNPACKED
# Remove pre-existing weirdo cups startup stuff
find /etc/rc.d -name "*cups" -exec rm -vf {} \;
make install-cups
cd $SOURCES
rm -rf $UNPACKED

# PACKAGE NAME: espgs-8.15.4
URL="ftp://anduin.linuxfromscratch.org/BLFS/\
conglomeration/espgs/espgs-8.15.4-source.tar.bz2"
PATCH1="ftp://anduin.linuxfromscratch.org/BLFS/\
conglomeration/espgs/espgs-8.15.4-bov_fix-1.patch"
PATCH2="ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/\
fonts/ghostscript-fonts-std-8.11.tar.gz"
PATCH3="http://ftp.gnu.org/pub/gnu/ghostscript/\
gnu-gs-fonts-other-6.0.tar.gz"
cd $SOURCES
wget -c $URL
wget -c $PATCH1
wget -c $PATCH2
UNPACKED=$(tar -tf $(basename $URL) \
| sed -e "1 {s,/.*,,;q}")
rm -rf $UNPACKED
tar -xf $(basename $URL)
cd $UNPACKED
patch -Np1 -i ../espgs-8.15.4-bov_fix-1.patch
sed -i "s/bbox.dev$/x11.dev/" Makefile.in
./configure --prefix=/usr \
--enable-threads \
--without-omni
make
make so
make install
make soinstall
install -v -d -m755 /usr/include/ps
install -v -m644 src/*.h /usr/include/ps
ln -v -s ps /usr/include/ghostscript
tar -xvf ../ghostscript-fonts-std-8.11.tar.gz -C \
/usr/share/ghostscript
chown -v root:root /usr/share/ghostscript/fonts/*
cd $SOURCES
rm -rf $UNPACKED

# PACKAGE NAME: gutenprint-5.0.1
URL="http://downloads.sourceforge.net/gimp-print/\
gutenprint-5.0.1.tar.bz2"
cd $SOURCES
wget -c $URL
UNPACKED=$(tar -tf $(basename $URL) \
| sed -e "1 {s,/.*,,;q}")
rm -rf $UNPACKED
tar -xf $(basename $URL)
cd $UNPACKED
sed -i 's|$(PACKAGE)/doc|doc/$(PACKAGE)-$(VERSION)|' \
doc{,/developer}/Makefile.in
./configure --prefix=/usr
make
make install
cd $SOURCES
rm -rf $UNPACKED

# PACKAGE NAME: foomatic-filters-ppds
URL="http://www.openprinting.org/download/foomatic/\
foomatic-filters-ppds-current.tar.gz"
cd $SOURCES
wget -c $URL
UNPACKED=$(tar -tf $(basename $URL) \
| sed -e "1 {s,/.*,,;q}")
rm -rf $UNPACKED
tar -xf $(basename $URL)
cd $UNPACKED
# NOTICE: This is really wierd
# NOTICE: "./install" "--prefix" "space" "/usr"
./install --prefix /usr
cd $SOURCES
rm -rf $UNPACKED
# ./install --prefix /usr --gzip
# would be smaller 36M vs. 161M

# PACKAGE NAME: foomatic-filters-3.0
URL="http://www.openprinting.org/download/foomatic/\
foomatic-filters-3.0-current.tar.gz"
cd $SOURCES
wget -c $URL
UNPACKED=$(tar -tf $(basename $URL) \
| sed -e "1 {s,/.*,,;q}")
rm -rf $UNPACKED
tar -xf $(basename $URL)
cd $UNPACKED
./configure --prefix=/usr --sysconfdir=/etc
make
make install
cd $SOURCES
rm -rf $UNPACKED

# PACKAGE NAME: hplip-2.8.12
# just to get the hpijs
URL="http://downloads.sourceforge.net/hplip/hplip-2.8.12.tar.gz"
cd $SOURCES
wget -c $URL
UNPACKED=$(tar -tf $(basename $URL) \
| sed -e "1 {s,/.*,,;q}")
rm -rf $UNPACKED
tar -xf $(basename $URL)
cd $UNPACKED
./configure --prefix=/usr \
--sysconfdir=/etc \
--enable-hpijs-only-build \
--disable-foomatic-ppd-install \
--disable-foomatic-drv-install \
--disable-foomatic-rip-hplip-install \
--disable-network-build \
--disable-pp-build \
--disable-dbus-build \
--disable-scan-build \
--disable-gui-build \
--disable-fax-build \
--disable-doc-build
make
/usr/bin/install hpijs /usr/bin/hpijs
cd $SOURCES
rm -rf $UNPACKED

I used these scripts to build in the jhalfs custom tools method:
5040-cups
5042-cups_bootscripts
5044-espgs
5047-gutenprint
5048-foomatic-filters-ppds
5049-foomatic-filters-3.0
5051-hplip

After building everything, start or restart cups:
/etc/rc.d/init.d/cups restart

Set up hp deskjet 3320 pinter (or other printer) by pointing browser to localhost:631

ex: lynx localhost:631
but in firefox it is easier to navigate

->Add Printer
Name: hp_deskjet_3320
->Continue
Device: [dropdown box shows hp deskjet 3320 USB #1 (hp deskjet 3320)]
->Continue
Model: [dropdown box pre highlighted HP Deskjet 3320 Foomatic/hpijs (en)]
(way down in the list)
->Add Printer
Message says printer has been successfully added

Go to the Printers tab
-> Print Test Page (if desired)

Go to the Printers tab
-> Set As Default (unless another printer is default)
You will need to give username of root and root's password.
There is a way to set up a cups administrative account,
yet to be determined.

Now you can print from applications like firefox.

You can print a file with:
lp file_name

You can send to standard input of lp with a file_name of -
echo "Hello Computer." | lp -

1 Comments:

Blogger linux fan said...

May need to create a symlink foomatic-ppds in /usr/share/cups/model

cd /usr/share/cups/model
ln -s /usr/share/ppd foomatic-ppds

November 27, 2009 at 10:00 PM  

Post a Comment

Subscribe to Post Comments [Atom]

Click blog title for the latest post