Avoiding Debian Headaches: Apt Pinning By Example

I use Virtualmin on my Linode VPS. When it Debian 6.0 was first released, Virtualmin only supported 5.0 (lenny), not unstable or 6.0 (squeeze). I was unwittingly auto-upgraded, hosing the Virtualmin install. Cleaning up the mess required a re-install, and these are some notes on my setup so I don’t get surprised by the apt package manager again in the future:

/etc/apt/sources.list

Make sure release codenames are named, like ‘lenny’ rather than ‘stable’, unless you’d like to be upgraded to the next dist without warning!

## main & security repositories
deb http://ftp.us.debian.org/debian/ lenny main
deb-src http://ftp.us.debian.org/debian/ lenny main
deb http://security.debian.org/ lenny/updates main
deb-src http://security.debian.org/ lenny/updates main

#deb http://ftp.us.debian.org/debian/ lenny contrib
#deb-src http://ftp.us.debian.org/debian/ lenny contrib
#deb http://security.debian.org/ lenny/updates contrib
#deb-src http://security.debian.org/ lenny/updates contrib

#deb http://ftp.us.debian.org/debian/ lenny non-free
#deb-src http://ftp.us.debian.org/debian/ lenny non-free
#deb http://security.debian.org/ lenny/updates non-free
#deb-src http://security.debian.org/ lenny/updates non-free
deb http://software.virtualmin.com/gpl/debian/ virtualmin-lenny main
deb http://software.virtualmin.com/gpl/debian/ virtualmin-universal main

#DCL: backports
deb http://Backports.Debian.Org/debian-backports lenny-backports main contrib non-free
deb-src http://Backports.Debian.Org/debian-backports lenny-backports main contrib non-free

#DCL: unstable
deb http://ftp.us.debian.org/debian unstable main non-free contrib
deb-src http://ftp.us.debian.org/debian unstable main non-free contrib

/etc/apt/preferences

Make sure you read the apt_preferences man page!

Package: *
Pin: release a=lenny
Pin-Priority: 700 

Package: *
Pin: release a=lenny-backports
Pin-Priority: 200 

Package: *
Pin: release a=unstable
Pin-Priority: -10 

How to use

To install from backports, aptitude -t lenny-backports <pkg-name>. It will then be auto-updated from lenny-backports in the future because of the 200 pin priority, as per the backports instructions.

To install from unstable, aptitude -t unstable <pkg-name>. The negative pin priority prevents it from being auto-updated. This is useful because it may otherwise drag the whole system up to the unstable versions.

Setting GEM_HOME on Phusion Passenger 3

I recently built a Ruby on Rails app, and I chose to install some Ruby gems locally (in my home directory) rather than system-wide. This worked from the console, when my GEM_HOME environment variable was read from .bashrc. However, when I wanted to deploy via Phusion Passenger, I was stumped as to how to get it to find GEM_HOME. I got errors such as the following:

Ruby (Rack) application could not be started
...
Could not find mysql2-0.2.6 in any of the sources (Bundler::GemNotFound)

Some pages suggested setting ENV['GEM_HOME'] in config/environment.rb, but this had no effect. Phusion Passenger calls Bundler.setup before loading the application. Instead, the fix is to put the necessary lines in config/setup_load_paths.rb. You’ll probably have to create this file:

ENV['GEM_HOME']='~/gems1.9.1'
# You can also set GEM_PATH if needed
#ENV['GEM_PATH']='~/gems1.9.1:/var/lib/gems/1.9.1'

Light Drawing in Color

Light drawing is a night-time activity using a camera to take long-exposure pictures (usually 15 seconds or so). During the exposure, you can move lights around to create trails of light, making glowing doodles and sketches that seem to hover in the air.

It can be hard to find good lights to use—they have to be pretty small to make good drawings. You can make dedicated LED pens for doodling, but this requires soldering together LEDs, switches, and button cell batteries. It’s a fairly easy but time-consuming DIY project.

An alternative is to get super-bright and inexpensive keychain lights: 10 lights at 47 cents a piece. These lights are blinding—and at a price that makes them disposable.

Next you can add color with cellophane! This stuff is actually kind of hard to find in small quantities, but I saw some at Party City, 50 cents for a 5′ x 20″ roll—that’s enough to make color filters for at least a hundred of these lights. I cut out the cellophane and wrapped it around the light, tacking it down with just a bit of Scotch tape. Four layers of red produced a more vivid (but dimmer) red, and 2 layers produced pink. Alternatively, it could be easier to stick colored latex balloons on the lights.

Now to test out drawing:

Installing Catalyst on Debian, the easy way

A few notes I collected after searching online for information about installing Catalyst, the MVC Web framework for Perl. This approach uses pre-built Debian packages which install a lot quicker than compiling things yourself using CPAN — plus, this way you don’t have to tinker with the modules that somehow fail tests, which inevitably happens with such a large dependency base.

First, set up the unstable repository and pin it so that most packages don’t get installed from unstable — just the Perl ones.

/etc/apt/sources.list:

# the main Debian packages.
deb http://mirror.cc.columbia.edu/pub/linux/debian/debian/ lenny main contrib

# Unstable
deb http://http.us.debian.org/debian unstable main non-free contrib

/etc/apt/preferences:

Package: *
Pin: release a=stable
Pin-Priority: 700

Package: *
Pin: release a=lenny
Pin-Priority: 700

Package: *
Pin: release a=unstable
Pin-Priority: 600

Next, install a sampling of useful modules from Task::Kensho:

aptitude -t unstable install liblocal-lib-perl libtest-simple-perl \
    libtest-most-perl libtest-exception-perl libtest-pod-perl \
    libtest-pod-coverage-perl libtest-memory-cycle-perl \
    libdevel-cover-perl libmoose-perl libpoe-perl \
    libmodule-install-perl libperl-critic-perl libcarp-always-perl \
    libdatetime-perl

Install modules recommended by Catalyst docs:

aptitude -t unstable install sqlite3 libdbd-sqlite3-perl \
    libcatalyst-perl \
    libcatalyst-modules-perl libdbix-class-timestamp-perl \
    libdatetime-format-sqlite-perl libconfig-general-perl \
    libhtml-formfu-model-dbic-perl libterm-readline-perl-perl \
    libdbix-class-encodedcolumn-perl libperl6-junction-perl \
    libtest-pod-perl

The Best Way to Unclog Print Heads

I’ve had many inkjet print heads that eventually got dried up and started streaking when printing. These supposedly delicate parts consist of a very fine, narrow channel for ink of each color. The extremely narrow width allows them to position ink precisely, but it also means they can clog easily with dried ink.

Print head

The solution for clogged ink heads is pretty simple: Rinse with hot, hot water. Boiling water, in fact. I poured a small cup slowly over the print heads for about ten seconds, dried it off with a towel, and stuck it back into the printer. PRINTS LIKE NEW!

Many sites advise treating the print head much more carefully: make measured-out solutions of ammonia, soak a paper towel, and leave the print head resting on the towel overnight. But soaking for hours has never worked for me. Lesson learned: The print head is remarkably resilient.

I’ve tried this now with two printers: a Canon i560s and a Canon iP1800. Worked perfectly both times. The iP1800 has cartridges with built-in print heads, so I worried that water would enter and dilute the just-refilled cartridges. The cartridge would just be junk if I couldn’t get it working, though, so I gave it the scalding-hot treatment anyway. It worked!