Gentoo Printing Guide John P. Davis Phil Bordelon A comprehensive printing guide for Gentoo Linux. This document covers both local and network printing. 1.0.2 8 August 2002 Local Printing Using CUPS
Installation Using CUPS

Setting up printing in Gentoo Linux is relatively easy, as all of the packages required can be found in the portage tree as of 8 August 2002. All that we have to do is configure the actual printer and make sure that it interprets Postscript correctly. The first step is installing the necessary software.

The next steps assume that we are setting up printing in GNOME2. This may work in KDE, as CUPS is environment-independent. TODO: guide for setup in KDE.
 
# emerge net-print/cups  
# emerge gnome-base/gnome-print 
# emerge gnome-base/libgnomeprint 
# emerge media-gfx/gimp-print 
# emerge net-print/gimp-print-cups 

Since the packages are now installed with their appropriate dependencies, it is time to install the printer itself.

This document deals mostly with USB Hewlett Packard printers, but configuring a parallel-port printer is not much different from USB configuration. Non-HP printers are not covered as of yet, so finding and installing drivers for them will not be an identical process.

Unless you already have USB printer support compiled into the kernel, it will have to be compiled in. You need to have USB core support and USB printer support enabled either as modules or built in. I chose to modularize both because I can lsmod and see that the support is actually up and running, but that is just personal preference.

If you are using a parallel port printer, make sure to enable the parallel port kernel options instead of the USB options. If you are not sure on how to compile the kernel, the official Linux Kernel-HOWTO can be found here.

Now that the appropriate kernel options are installed, it is time to see if the printer is detected and dealt with appropriately. Once everything is restarted, load the printer modules.

If you have USB built into your kernel, you don't have to load the USB modules. If you are using a parallel port printer, substitute the appropriate modules as needed.
 
# insmod usbcore 
# insmod printer 

After the modules have loaded successfully, plug in the printer, and check /var/log/messages to see if it is detected.

 
# tail /var/log/messages 

You should see something like this:

hub.c: USB new device connect on bus2/2, assigned device number 2  
printer.c: usblp0: USB bidirectional printer dev 2 if 0 alt 1 proto 2 vid 0x03F0 pid 0x1104 
If you are using a parallel port printer, make sure that it is plugged in before you reboot. Once the system is up, issue a dmesg and look for evidence of the kernel detecting your printer.

Before setting up the printer using CUPS, it is possible to test your printer using cat.

# touch test.txt
# echo "Hello World" > test.txt
# cat test.txt > /dev/usb/lp0 

 Alternatively, for parallel port printers: 
# cat test.txt > /dev/lp0 
PPD File Configuration

Now it is time to configure the printer and CUPS. If you are using an HP Inkjet printer, it is necessary to install the hpijs printer driver. This driver handles all of the Postscript interpretation necessary to make the HP printer work. If you are using a non-HP printer, it may be necessary to locate the third party drivers for it.

The hpijs driver is for HP Inkjet printers only. If you are using a HP Laserjet, support may already be available via the GNOME printing system. If you are using a non HP Inkjet printer, skip down below to the configuration process.
 
# emerge net-print/hpijs 
The documentation from HP for the hpijs driver is in /usr/share/doc/hpijs-1.1. It is highly recommend reading.

In order for your printer to interpret Postscipt correctly, CUPS needs a PPD (Printer Postscript Definition) file. The easiest way to generate a PPD is through foomatic. The foomatic configuration scripts are available here. There is an ebuild in development for Gentoo, but it is not in the current Portage tree. Once foomatic is configured and installed, issue these commands to configure your printer, then move the PPD to the correct location. This example uses the hpijs driver for an HP printer.

For the printer ID, foomatic is expecting an ID out of its database located in /usr/share/foomatic/db/source/printer. You must find your printer ID, and use its exact name. Remember that it is case sensitive.
# foomatic-configure -s cups -p printer ID -c print_device -n queue name -d hpijs 
# mv /etc/foomatic/your.new.ppd /etc/cups/ppd 
If you are using a non-HP printer, you will still be able to use foomatic to generate your PPD. Please refer to the foomatic documentation here and the linuxprinting.org homepage for more information.
CUPS Configuration

Since the printer itself is now configured, now CUPS must be setup to handle the printer queueing. CUPS can be accessed via web browser on port 631 of the printer machine, which makes it very handy.

CUPS has a builtin configuration file for the daemon that should, but does not have to, be modified. You might want to take a gander at it, it is /etc/cups/cupsd.conf.
# rc-update add cupsd default
# /etc/init.d/cupsd start

The CUPS daemon should now be running, so open up your favorite browser and point it to here. Hopefully, you will be greeted with the CUPS configuration mainscreen. Click on the administration tab at the top of the page, and enter root for the username and your root password for the password. Once authenticated, click on the Add Printer tab under the printers section. Enter the necessary name, description, and location of your printer. You must make your printer name exactly the same name of your printer queue that you specified for foomatic. You now need to select the device that you printer is connected to. Select the make of the printer, and continue on. On the next page choose your printer from the list. For example, I have a HP Deskjet 952C, so I would pick the HP DeskJet 900 Series, CUPS+GIMP-print v4.2.1 (en). Configuration is done! Click on the name of your printer, then try printing a test page. Voila, your printer is setup is completed!

If the printer does not work for some reason, go to the directory where you told your CUPS logs to be stored, and look through error_log.
Configuring The GIMP, OpenOffice.org1.0, and Abiword to print using CUPS.
The GIMP

First, let's setup The GIMP, just because it is cool and worth it. Open up The GIMP, and open an existing picture, or just some blank pic, it really doesn't matter because all we are looking for is the File menu. RIght click on the image and go to File/Print The dialog for printing should come up, and when it does, click on new printer. If your printer is not already listed, type in the name of your printer, then select your printer type. Ok, you are now setup to print from The GIMP. Play with the settings and have some fun.

OpenOffice.org1.0

Printing with OpenOffice.org1.0 is not much more difficult. Goto OpenOffice.org1.0/program , and run spadmin. Make a new printer, and when presented with the Choose a Driver screen, click on import and browse to the location of your printer's PPD In our case, it would be /etc/cups/ppd. Use the default print commands, name the printer, set it as default, and you are ready to go! Start OpenOffice.org1.0 and go to the print screen, and select your printer. Print a test page, and you are done.

Abiword Abiword segfaults and crashes with CUPS-1.1.15-r2. It is recommended to go back to the .14 series as that will fix the problem.

TODO: add Abiword support.

Local printing is now complete, now to add network support.

Network printing using CUPS and SAMBA
Printing to a Windows Printer from a Linux Machine

First, SAMBA has to be installed for the next two network printing options to work.

# emerge net-fs/samba
For more information on SAMBA, the official SAMBA HOWTO is located here

First, we use foomatic to generate the PPD for the remote printer. Don't forget to check if your printer is compatible with Linux or not at the linuxprinting.org printer database. Now, we tell foomatic where and what the printer is, and then move the generated PPD to the correct location.

# foomatic-configure -s cups -p printer ID -c smb://user:password@server/share -n queue name -d hpijs  
# mv /etc/foomatic/your.new.ppd /etc/cups/ppd 

Now, point your favorite web browser here to bring up the CUPS configuration GUI. Follow the above steps to add a printer, but this time, when asked what port the printer is on, specify smb://user:password@server/share. This will point CUPS to the printer on the Windows machine.

Using Linux as a Windows Compatible Print Server

Linux makes a great print server, then again, it makes a great everything server. The first thing to do is edit /etc/samba/smb.conf to fit your settings. The smb.conf file contains all of the settings that will make your Linux box look like a Windows NT server to any Windows machine. I have included an very utilitarian example smb.conf below. Edit as needed to fit your network environment.

[global]

      workgroup = YOUR_WORKGROUP
      server string = Gentoo Linux Server
      encrypt passwords = True
      security = user
      smb passwd file = /etc/samba/private/smbpasswd
      log file = /var/log/samba/log.%m
      socket options = IPTOS_LOWDELAY TCP_NODELAY
      domain master = Yes
      local master = Yes
      preferred master = Yes
      os level = 65
      dns proxy = No
      name resolve order = lmhosts host bcast
      bind interfaces only = True
      interfaces = eth0
      hosts deny = ALL
      hosts allow = 192.168.1.4 127.0.0.1 (list of allow hosts here) 
      debug level = 1
      create mask = 0644
      directory mask = 0755
      level2 oplocks = True
      read raw = no
      write cache size = 262144

[printers]
      comment = All Printer
      path = /var/spool/samba
      browseable = no 
   

Now that the SAMBA is configured, restart samba, go to your Windows machine and install a network printer. Piece of cake, eh?