Brother HL-5150D

The Brother HL-5150D is a USB black and white laser printer for use in small offices or at home. It works in Linux using CUPS and Brother's lpr driver and cupswrapper.

Brother-provided PPD file
Brother does provide a PPD file for this printer, so in theory installation should be a breeze using Cups' built-in printer installation wizard. However, Brother printers installed that way often don't work correctly, in particular they tend to misalign the printed content on the page, leading to margins being too small or too wide or text being cut off. This is due to the driver being buggy with regards to paper size and who knows what else. The method described below leads to a fully working printer.

64bit Systems
The steps below work for 64bit systems.

Setting up the Kernel
If you use Cups 1.3.x, you need USB Printer Support enabled in your kernel. Cups 1.4.x brings its own kernel module, so if you use that version, remove USB Printer Support from your kernel to avoid conflicts.

Installing required packages

 * You'll need to install on your system if you haven't done that already. For more information on that subject please refer to the article CUPS.
 * You'll need to unpack the downloaded .rpm files.
 * On an amd64 non-multilib system, you need . (Quick check: if you already have you should be good to go.)

Downloading and extracting the driver

 * Go to http://welcome.solutions.brother.com/bsc/public_s/id/linux/en/download_prn.html#HL-5150D and download both rpm packages.
 * 'cd' to wherever you saved the files, convert them to .tar.gz and extract them (the filenames might look a little different depending on printer model and version updates):

Performing necessary changes
You'll need to adapt the scripts surrounding the drivers a litte to make them work. Open in your favorite editor.
 * Change all occurrences of to  (there should be 6 of them).
 * If you're on a 64bit system, change all occurrences of to  (I've counted 4).
 * On recent Cups versions (probably 1.4.x, I'm not sure), you'll need to change the connection identifier for your printer. At the bottom of the file, you'll see a line . To find out what to change it to:
 * Start /etc/init.d/cupsd if it's not already running
 * Turn on your printer
 * Open your browser and go to http://localhost:631
 * Begin adding a printer ("Administration" -> "Add Printer"), choose your connected printer
 * On the second screen, look out for the field labeled "Connection:". Copy its contents. Cancel the printer addition process.
 * Put this string into the script, replacing, so that the line looks like this: cupswrapperHL5150D-1.0.2
 * The driver defaults to A4 paper. If you're in North America you'll probably want to change that. Open and change  to: usr/local/Brother/inf/brHL5150Drc

Installing the drivers
Now it's time to copy the driver to your system.

You'll also need to set a few symlinks to make Cups happy:

Then you can install the printer. Run:

Done!
No further setup inside Cups is necessary. Go print yourself a test page.