How to easily exclude packages from apt-get upgrades

Once you’ve got the hang of Debian/Ubuntu’s package management system and have had a fine time smoothly upgrading your system periodically, at some point the inevitable will happen: while upgrading a package something will get installed that will break something else.

It could be, as happened to me recently, a version of Google Chrome that won’t play nice with some element of Gnome or the GTK toolkit – any button on a webpage that should launch a dialogue box took minutes to do so. Several minutes. So we need to reverse this, by downgrading the package to the previous version, and then prevent it from being reinstalled automatically. How?

The most common Debian package manager frontend is apt-get. There are a number of different options, from powerful but complex dpkg, it’s more user-friendly brother aptitude, to the full blown X-windows GUI of synaptic. But apt-get is most people’s first choice, the most straightforward, and the one which comes with no obvious switch or option included – the following demonstrates how.

 

1) Remove and downgrade the problem package

This is straightforward. First find the problematic package version:

$ sudo cat /var/log/apt/term.log | grep google-chrome-stable
Setting up google-chrome-stable (32.0.1700.77-1) ...
Preparing to replace google-chrome-stable 32.0.1700.77-1 (using .../google-chrome-stable_32.0.1700.102-1_amd64.deb) ...
Unpacking replacement google-chrome-stable ...
Setting up google-chrome-stable (32.0.1700.102-1) ...

There in the apt logfile is the output of the apt-get command that installed the package we want to replace, version 32.0.1700.102-1. Now we find the packages in the apt package cache:

$ ls -l /var/cache/apt/archives/google-chrome-stable*
/var/cache/apt/archives/google-chrome-stable_32.0.1700.77-1_amd64.deb
/var/cache/apt/archives/google-chrome-stable_32.0.1700.102-1_amd64.deb

There’s the last few versions. It’s simple enough to replace the most recent with the previous version using dpkg.

$ dpkg -i /var/cache/apt/archives/google-chrome-stable_32.0.1700.77-1_amd64.deb

 

2) Prevent the next apt-get update or dist-update from upgrading the package

The package manager records packages as flagged in one or more of various states, such as installed (or set to be installed), not installed (or set to be removed) or held. For this purpose we need to hold the package. There are two ways of doing this.

One is to use dpkg again, using –set-selections to set the package flags.

$ echo "google-chrome-stable hold" | sudo dpkg --set-selections

(note it’s dpkg that requires root privileges, not echo)

We can check this has worked:

$ dpkg --list | grep google-chrome-stable
hi google-chrome-stable 32.0.1700.77-1 amd64 The web browser from Google

Where the “hi” at the beginning of the line stands for “hold” and “installed”. You can read up more about the different package statuses, how to check them and what they mean in the dpkg-query manpage.

Now when we run an upgrade using apt-get, the held package will be ignored:

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
google-chrome-stable
The following packages will be upgraded:
curl libcurl3 libcurl3-gnutls
3 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 1,258 kB of archives.
After this operation, 39.9 kB of additional disk space will be used.
Do you want to continue [Y/n]?

You can easily check which version of the held package installed and the package offered from the repo by running apt-get install on the package with the -s (“simulate”) switch, which reports the package versions:

$ sudo apt-get install google-chrome-stable -s
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following held packages will be changed:
google-chrome-stable
The following packages will be upgraded:
google-chrome-stable
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Inst google-chrome-stable [32.0.1700.77-1] (32.0.1700.107-1 Google:1.0/stable [amd64])
Conf google-chrome-stable (32.0.1700.107-1 Google:1.0/stable [amd64])

At some point we’ll want to reverse this decision, as bugs will have been fixed and versions incremented. So we can unhold the package by setting it to install, where the “ii” refers to “set for installation” and “installed”:

$ echo "google-chrome-stable install" | sudo dpkg --set-selections
$ dpkg --list | grep google-chrome-stable
ii google-chrome-stable 32.0.1700.77-1 amd64 The web browser from Google

 

The alternative is to use apt-mark. This is chiefly for marking packages as either automatically or manually installed, which affects how they respond to being installed, upgraded or removed as dependencies to other packages. For example, a package set to auto will be automatically installed as a dependency to another package if required, and automatically removed if not required; those set to manual will not.

But it also can be used to hold packages – in fact, it is a wrapper around dpkg --set-selections, and works in exactly the same way albeit in a slightly simpler fashion.


$ apt-mark hold google-chrome-stable
$ apt-mark showhold
google-chrome-stable
$ sudo apt-mark unhold google-chrome-stable
$ apt-mark showhold
$

And there you are. More straightforward than pinning using apt’s preferences file (with less margin for disaster), and easily reversible.

Proper British language tools in Libreoffice

UPDATE March 2013: It seems something has broken this way of setting up the British English dictionaries. Skip to the bottom for my suggestion.

An annoying and apparently long-standing bug in OO/OOo/Libreoffice is that a British English dictionary and thesaurus are absent, and won’t appear even after trying all the usual, obvious routes.

The option under Tools -> Language Tools -> Thesaurus stays greyed out regardless of what packages you install, and crucially all the packages you’d expect to install to solve the problem – hunspell-en-gb, hyphen-en-gb, mythes-en-gb, for example – don’t exist, even though other anglophone alternatives such as en-au, en-ca, and even en-za, do. Installing British English dictionary/thesaurus from the Libreoffice Extension Manager website doesn’t help either. Installing the libreoffice-l10n-en-gb localisation package only fixes the Libreoffice interface and suggests the obsolete en-gb versions of language tools above that don’t exist, which only adds to the confusion.

The answer is that the en-gb dictionary and thesaurus is included within the en-us versions, something made clear absolutely nowhere, although it is alluded to obliquely, for example:


$ sudo apt-get install mythes-en-gb
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'mythes-en-us' instead of 'mythes-en-gb'
mythes-en-us is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

This is explained at the bottom of this bug report, which also details a handy, albeit dirty, fix.

1. Ensure you have the guts of the programs you need to use spellchecking and thesaurus at all:

$ sudo apt-get install libmythes-1.2-0 hunspell

2. Next you’ll need to install the en-us versions, as they contain the en-gb versions (you could do this all in one apt-get install command, I’m just making it clear):

$ sudo apt-get install mythes-en-us hunspell-en-us

3. Finally, create symbolic links between the en-us and non-existent en-gb versions so that Libreoffice sees them.

$ cd /usr/share/mythes/
$ sudo ln -s th_en_US_v2.idx th_en_GB_v2.idx
$ sudo ln -s th_en_US_v2.dat th_en_GB_v2.dat

And that should do it. Restart Libreoffice, and check in Tools -> Options -> Language Settings -> Writing Tools that by clicking Edit you can see ‘OpenOffice New Thesaurus’ has appeared under the Thesaurus category. The Thesaurus option should now have reappeared, so you can press CTRL+F7 to bring up the dialog, make sure you select English UK from the Language box on the right (otherwise it displays results from both languages) and look for a Britishism like ‘grey’ or ‘colour’. It’s all there, apart from “a lot of the British swear words“, apparently – but then Americans never did have a clue what bollocks were anyway.

(thanks to Tom Brossman for spotting a stray hyphen typo in the package names)

UPDATE: I’ve tried playing with the Libreoffice dictionary extensions again and still can’t get them to recognise the difference between UK/US spelling, as they unhelpfully accept both. For sanity’s sake I’ve elected to start over with a package that actually does what it says it will (as mentioned in the comments). So:

1) Remove the US dictionary hunspell-en-us (but not the core hunspell spellchecker):
$ sudo apt-get remove hunspell-en-us

2) Install a GB dictionary – hunspell is backwards compatible with myspell, they use the same format:
$ sudo apt-get install myspell-en-gb

Notice that it actually installs the dictionary in /usr/share/hunspell, not /usr/share/myspell/dict – presumably because it recognises that we’re using hunspell (it’s installed) not myspell (it isn’t) as the spellcheck engine. Instead it puts links into the myspell directory for compatibility.

3) That’s it. Keep mythes-en-us (or install it if necessary: $ sudo apt-get install mythes-en-us) because it does actually include GB spellings (you can grep the files for colour, theatre, specialise, etc), and as long as the symbolic links to the non-existent GB thesaurus files (as in step 3 above) are in the directory, Libreoffice will recognise it, and will show Hunspell (UK) and Thesaurus (UK) modules enabled in Tools -> Options -> Language settings -> Writing aids.

Linux on the move with acpi

Linux has good support for all sorts of varied and interesting hardware these days, right across the spectrum from esoteric mainframes to the common desktop PC. But configuring a computer such as a laptop or netbook to be energy efficient to save battery power can still be a source of frustration for linux users. Or at least it was to this linux user.

ACPI, the standard for power management, is capable of switching off or disabling devices to save power, such as shutting down wireless or bluetooth transmitters, ethernet ports, dimming monitor screens, spinning down idle hard drives and putting processors in to sleep states. This replaces the previous standard, APM. Older computers from before about 2000 support only apm, the newest computers support only acpi, with those built around the changeover supporting acpm and an incomplete acpi specification. It’s a good idea to have one or the other, and not to run both at the same time.

It has improved greatly, but power management support in linux is, as much as anything, a work in progress. Using Debian-based Crunchbang, my Samsung Q320 did not respond to acpi events at all – removing the power cable and switching to battery power did not dim the screen or scale down the processor frequency, for example. On a mission to squeeze more than 1hr 50min from my battery, I embarked on the following odyssey.

Install Acpi support

It may seem obvious, but as acpi is not a system essential, it is quite possible to run linux without any acpi layer at all. Kernel support for acpi has been included since kernel versions 2.4, and newer 2.6 kernels provide better support for more features and hardware. But you’ll still need to install the rest.

$ sudo apt-get install acpid acpi-fakekey pm-utils

This will set up the acpi daemon (acpid) to listen for acpi system events and run scripts in /etc/acpi to trigger system sleep, suspend, hibernate, and resume events.

acpi-fakekey generates fake key-press events to represent those keys providing acpi functions that are not recognised by the kernel. Getting dead keys recognised is in fact another complication in the process.

pm-utils is a distribution-neutral standardised set of hooks that can be called to trigger or resume from a sleep, suspend or hibernate acpi call, configured by placing scripts in /etc/pm/.

Add to that some utilities:

$ sudo apt-get install acpi acpitool acpi_listen

acpi is a very simple command line utility that will return information about the battery, AC adaptor, thermal trip points and CPU states, and I include it here really only because it comes with most distributions and some scripts may depend on it.

acpitool is a much more substantial acpi command line client that can query and manipulate acpi information and trigger acpi events. Some functions such as changing backlight settings are limited to Toshiba, Asus and IBM hardware.

acpi_listen runs in a terminal and intercepts and prints acpi requests as they appear, in the same way xev does for key-presses.

Hardware-specific acpi layer

With the essentials installed, we need to fill the gaps between the generic linux acpi drivers and the various function key combinations, hotkeys and extra buttons that are particular to each laptop model or manufacturer.

For those with IBM, Toshiba, Acer or Asus models, installing acpi-support may be enough: $ sudo apt-get install acpi-support, but this package has been deprecated, in Ubuntu at least. It includes a command line tool and more scripts that run in response to the non-standard buttons most laptops use to set low-power modes, hibernation, brightness settings, etc. It is configured from /etc/default/acpi-support and controlled by /etc/init.d/acpi-support. But it’s not much use for my Samsung, for example.

It turns out that Samsung laptops have a somewhat rocky history in terms of bulletproof linux compatibility. But developer Fortunato Ventre of the Linux On My Samsung project has made excellent progress carving out a functioning acpi implementation for Samsung netbooks, which by extension (mostly) works with other Samsung machines.

Add the project Launchpad PPA repository at launchpad.net/~voria/+archive/ppa to /etc/apt/sources.list (how to). There are several tools for different purposes, you might not need all of them. The easy-slow-down-manager lets you set the fan speed between fast, normal and silent (slow). samsung_backlight and nvidia-bl-dkms are two LCD screen backlight drivers that replace the standard and incompatible video.ko acpi driver. This will allow programs to change the screen brightness directly. samsung-tools includes a command line tool and graphic interface (samsung-tools-preferences) that can manually set up what function key combinations trigger which actions. More usefully it also provides a gui for powersaving measures, as we’ll see.

The updated udev and linux packages provide no-hacks-required support for different Samsung models by providing udev with the identifier strings for the hardware, but as mine wasn’t included I didn’t bother, and it seems to (mostly) work anyway. See if you’re model is listed in this thread.

I tried the nvidia_bl module but my Q320 didn’t like it; trying to change the brightness would blank the screen and it would refuse to come back again, forcing a reboot. So I used the samsung_backlight module, loaded automatically as the package installer compiles support into the kernel, and prevented the standard acpi video driver from loading by adding:

blacklist video

to /etc/modprobe.d/fbdev-blacklist.conf

Finally, the kernel must be told to use the new driver by editing a line in /etc/default/grub:

GRUB_CMDLINE_LINUX="acpi_backlight=vendor"

Followed by:

$ sudo update-grub
$ sudo update-initramfs -u

And finally, add a line to the Section “Device” clause of /etc/x11/xorg.conf:

Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce G 105M"
# add line below to get brightness keys working
Option "RegistryDwords" "EnableBrightnessControl=1"
EndSection

After which (on restarting X) my brightness keys worked, and the screen dimmed when I pulled out the power cord. Now that’s progress.

Power saving tools

Last of all, we need to install scripts and tools that will take advantage of this new power-saving framework by shutting down power-hungry devices that are not being used.

$ sudo apt-get install laptop-mode-tools cpufrequtils powertop

The laptop-mode-tools will add a directory /etc/laptop-mode where scripts can be placed which when triggered by acpi events will run other programs such as hdparm, sdparm and ethtool (all dependencies installed at the same time) to configure disk drive and other PCI device’s power-down timeouts or set some level of power-saving. It is configured from /etc/laptop-mode/laptop-mode.conf. It does other clever things too, such as restarting syslogd with alternate settings so that logfiles are not constantly being written to when the disk is trying idling. It is worth noting that the laptop-mode in the Ubuntu repositories is a crippled version, which the developer recommends replacing with the full Debian package.

cpufrequtils installs programs that can manage processor states, switch up or down the CPU speed according to load, and place it sleep states when idle. It also provides a means to set the CPU demand governor, which controls how aggressive or passive the CPU will be in trying to sleep.

powertop is from the official LessWatts linux acpi project from Intel developers. Like top, it shows what processes are calling interrupts and waking the CPU so you can hunt them down and shut them off to save power. Better still it provides a simple interface that identifies these programs and offers an on/off toggle to do it for you.

And with that, you should have all you need.

Tweaking and debugging

One thing to watch out for is the rate at which hard disks idle, spindown and then restart. Some drives assume a very aggressive power management mode, but if there is a lot of disk activity then the drive will be spinning down and up again every minute or less, which is going to have a serious impact on the lifespan of your drive. It is easy enough to set a less aggressive timing, the tricky bit comes in locating which program and which config file controls the setting. In this case, hdparm (/etc/hdparm.conf), laptop-mode (/etc/laptop-mode/laptop-mode.conf) and samsung-tools (/etc/samsung-tools/scripts) could all be the culprit.

$ sudo hdparm -B[1...255] /dev/sda

This will set the the power management feature of the drive, where 1 is the most aggressive power management, 254 is top performance, and 255 disables power management. Settings between 1 and 127 will allow spin-down and head parking, 128 and above will not. If the sound (and slight delay) of the drives spinning up irritates or worries you, set this to 128 or higher.

$ sudo hdparm -S[1...255] /dev/sda

This controls the idle time-out setting of the drive, ie., how long the drive will wait since the last read or write before switching to lower-power idle mode, and also how long to wait before timing out and sleeping, as in -B above. Note -s (lowercase s) puts the drive to sleep, so don’t mistype.

Esoterically, this figure represents the following: 0 disables time-out/idle mode; 1 to 240 represents multiples of five seconds, from 5 secs to 20 minutes; 241 to 251 represent multiples of 30 minutes, from 30 mins to 5.5 hours; 252 represents 21 minutes, 253 is a vendor-defined period in the region of hours, and 254 is reserved; 255 represents, bizarrely, 21 minutes and 15 seconds. Suck on that.

If laptop mode has been enabled to control all devices, check its config file for the same settings:


# Set to 0 to disable
CONTROL_HD_IDLE_TIMEOUT=1
#
# Idle timeout values. (hdparm -S)
# Default is 2 hours on AC (NOLM_HD_IDLE_TIMEOUT_SECONDS=7200) and 20 seconds
# for battery and for AC with laptop mode on.
#
LM_AC_HD_IDLE_TIMEOUT_SECONDS=300
LM_BATT_HD_IDLE_TIMEOUT_SECONDS=20
NOLM_HD_IDLE_TIMEOUT_SECONDS=72
#
# Should laptop mode tools control the hard drive power management settings?
#
# Set to 0 to disable
CONTROL_HD_POWERMGMT=1
#
# Power management for HD (hdparm -B values)
#
BATT_HD_POWERMGMT=200
LM_AC_HD_POWERMGMT=254
NOLM_AC_HD_POWERMGMT=254

Running samsung-tools-preferences should reflect the values from laptop-mode.conf in the laptop-mode-tools dialog, with the appropriate boxes selected or blank.

For everything else there’s powertop. Run it as root and switch to the wonderfully named Tunables tab using cursors – it will show a list of devices that can be low-powered or disabled, including (on Intel-based chipsets) most PCI/PCIe and USB bus devices and host controllers, ATA/SATA chipsets and drives. Use the cursors to select those marked “Bad” and change them to “Good”. That’s it. You’ll notice the difference between running powertop on mains power or battery – there’s little point in turning powersaving on for every device when plugged into the mains, unless you really want to help save the planet by a couple of watts.

There’s a lot of very fragmented and, by its nature, very hardware-specific information about acpi around the internet. Some informative pages can be found at the Arch wiki (pm-utils, cpufrequtils, laptop-mode, Acpi hotkeys), the Ubuntu wiki (power management and troubleshooting) and an exhaustive page at IBM thinkwiki.

And what was the result of this struggle? Well, battery life of 1hr 50min rose to somewhere around 2hr 20min, and peaked at 3hr 1min, but swayed wildly between the three depending on whether I was just looking at the battery meter, or actually using the computer. What have we learned? Well, battery life estimations are largely worthless. Oh, and it turned out my battery was down to 50% of it’s original capacity, after just two and a half years. Looks like I’m staying within sprinting pace of the mains for now…

Wine, a cruel mistress – updating Debian’s ancient wine

Wine can indeed be a cruel mistress; the morning after the night before, after the sudo apt-get install has faded away and left you nothing but a jiggered system that won’t even run notepad.

I speak of course not of the mighty grape and what she gives us, but of wine (Wine Is Not an Emulator), the Win32 translation layer for Unix/Linux that does an excellent job of allowing Windows programs to run natively on Linux, often at great speed and without problems.

And sometimes with problems. If you run Ubuntu or Fedora, you’ll be blessed with recent updates from the 1.3 beta versions of wine, while the official stable version has languished at 1.2 for what seems like an eon. If you use Debian, then apt-get will only provide you with the even more Jurassic 1.0.3 version from the current stable (squeeze) repositories, there’s nothing in debian-backports, and even the upcoming releases in testing (wheezy) and unstable (sid) are only minor 1.x version bumps. You can do a full search of Debian distribution package list to see the tale of woe.

The reasoning behind Debian’s exceptionally cautious nature and glacial pace of rolling out updates is well known and well founded, and wine is hardly a core package. But that doesn’t help in the slightest when you really, simply, absolutely have to install and run Deathspank right now, and older versions aren’t cutting it.

Naturally, there are ways and means. Linux is more complex; but with complexity comes flexibility.

There are a couple of options for Debian users that offer a relatively pain-free way of using updated wine binaries and libraries without the risk of doing something terrible to the system.

 

Debian, winehq-approved packages

Debian packages created from the latest wine builds by Kai Wasserbäch can be found on his page at carbon-project.org. These are the latest builds, currently 1.3.33 for i386 or amd64 architectures, released today, and officially sanctioned by winehq.

Rather than setting up an apt repository (as he points out, “I don’t want to encourage people to install binary packages from third parties without thinking about what they’re doing”), the individual files are listed for download. You could just click each one, but it’s nice to get the computer to do the work for us. While wget won’t accept wildcards when downloading using http, so we can’t use a regexp like *wine*[your_arch_here], we can use a different method.

First highlight and copy the text list of packages from the webpage for whichever architecture you need and paste it into a text file. Using gedit or vi will neatly remove the bullet points leaving one package name per line, just as we want it. Name the file something memorable and recognisable, such as say, zig. Then type into a shell:

# wget --base=http://dev.carbon-project.org/debian/wine-unstable --input-file=zig -P libwine

This gives wget the base URL to work from, the list of files to download, and –P tells it create or use the directory libwine to store the files. Add the full path to zig if required, and you can substitute -B for --base and --i for --input-file.

Once you have a neat directory of .deb packages, you have to install them. apt-get is for querying and installing packages from the main Debian repositories (or other repositories you have added to /etc/apt/sources.list). For manual installation use dpkg, which usefully can be pointed at a directory and told to get on with installing a bunch of files at once:

# dpkg -R -i libwine/
or
# dpkg -i libwine/*

achieve much the same, where -i selects for install and -R tells dpkg that -i refers to a directory, not a file, which is why in the second example the asterisk wildcard (*) is needed to refer to ‘all files’.

But dpkg doesn’t provide hands-free dependency handling like apt-get, so it may be that some of the wine packages will fail to install due to unmet dependencies or version clashes. It’s easy enough to work out what it wants from the output given on screen, search the Debian package list for the updated version, download and use dpkg to install as before – but if you’re unlucky, that process that could potentially continue ad infinitum, ad nauseam. For what it’s worth, running Debian squeeze I needed only two: lib32ncurses5_5.9-4 and lib32tinfo5_5.9-4, both available from the testing repository (change the distribution drop down box to ‘any’, and search). It’s worth using the --no-act switch while using apt-get and dpkg
to dry-run without installing, giving you not only a chance to review what is happening but also precise details of what file version is being pulled from which repo.

 

Ubuntu Wine Team PPA packages

So far so easy. It’s certainly preferable to use packages built for the version of Debian you’re using, or at least a version of Debian, but if that doesn’t bring the results hoped for there’s always Ubuntu to turn to. With a large installed user base, more resources and a quicker release schedule than the Debian team, Ubuntu packages are mostly interoperable and tend to be packaged with the less-expert user in mind. For example, the Debian packages above weighed in at 59 Mb, while apt-get install issued at the Ubuntu wine PPA tried to pull in over 200 Mb of dependencies and support packages to make sure things work smoothly, including the very useful winetricks. Too much, I hear you say? Well it (wine 1.3.26) worked for me while the Debian packages (wine 1.3.33) didn’t, so the proof is in the pudding.

I’ve explained how to use Ubuntu Launchpad PPA repositories with Debian here, and the same applies. Briefly:

1.    Go to the Ubuntu wine PPA archive.

2.    Click on the green ‘Technical details’ tab, select an Ubuntu version and copy/paste the deb and deb-src lines into your /etc/apt/sources.list file. I’ve used the last long term support version, Lucid.

3.    Copy the GPG key (the part after the 1024R/) and add it using apt-key, then use apt-get update and apt-get install wine1.2 or apt-get install wine1.3 to install wine, depending on how wild, up-to-date and un-Debian you’re feeling.

Finally, run winecfg to prompt wine to autoconfigure, use the GUI to make any further changes and then see what works, using winetricks to install Microsoft packages such as msxml3, msxml4, msvc60, gdiplus, etc. if needed. There’s a lot of information on what works and what doesn’t, tips and tricks at appdb.winehq.org.

Note: it’s worth mentioning that there is another repository of updated Debian packages including wine at http://frickelplatz.de/debian/dists/, which appear to be different builds of equally up-to-date versions. And another is the Mepis Linux distribution, based on Ubuntu/Debian, for which repos can be found at http://main.mepis-deb.org/mepiscr/repo/. You’re mileage may vary as I’ve not tried either of them.

Using Ubuntu PPA packages with Debian or Crunchbang

Ah, the joys of package management. Every linux distribution flavour has a package management tool – even the venerable Slackware – to ensure the otherwise near-impossible task of installing programs and their dependencies and updating them to the latest versions is made possible for mere mortals.

Ubuntu, based on Debian, uses the same apt-get and dpkg tools. But as the pace of development at Ubuntu is much quicker and has a broader reach of users and developers than vanilla Debian, Canonical introduced PPA – personal package archives – on its Launchpad service to allow developers to create and maintain their own packages that can be accessed by Ubuntu users through apt-get, without having to bring them into the Ubuntu official release package tree itself.

While built for Ubuntu releases specifically, these packages can be used with Debian – and therefore Crunchbang – without much hassle. Two things are needed: firstly the location of the archive, usually an http:// or https:// web address; secondly the GPG encryption key that is used to sign the .deb packages, ensuring that the software you are installing on your computer with root permissions is, at least to a point, trusted.

In Ubuntu this is taken care of either using the add-apt-repository command, or by adding the package source using the Synaptic package manager GUI app. Neither comes with the stripped down and Gnome/KDE-free Crunchbang.

Instead we go old school again and edit the text file that the graphical app would be doing for us anyway, /etc/apt/sources.list. In this case, I’m installing the Darktable photo management and editing package, a sort of open source Adobe Lightroom. The PPA address can be found from the Ubuntu PPA achive on Launchpad. A search reveals the individual page(s) for Darktable.

In this example, there are three pages for Darktable, darktable-release, -release-plus, and -unstable. I’m using the cutting edge -unstable release in this case. Debian Squeeze (6.0.1) came out in February 2011, but I’ve used packages from the Ubuntu 10.04 “Lucid Lynx” release from April 2010 as it is a Long Term Support version and will continue to be updated long after Ubuntu 10.10 “Maverick Meercat” has been archived. Click the green link marked Technical Details about this PPA to reveal the source lines we need, beginning with deb:

We need to add the following text to /etc/apt/sources.list:

deb http://ppa.launchpad.net/pmjdebruijn/darktable-unstable/ubuntu lucid main
deb-src http://ppa.launchpad.net/pmjdebruijn/darktable-unstable/ubuntu lucid main

Darktable-unstable is the cutting-edge version in this case. The same deb line but substituting the words “darktable-release” would install from the more stable branch.

Running sudo apt-get update will force apt to add the new PPA repository to its list, but it will complain that it doesn’t have the GPG encryption keys we need to install packages:

Hit http://ppa.launchpad.net lucid/main Sources
Hit http://ppa.launchpad.net lucid/main amd64 Packages
Fetched 634 B in 0s (1,172 B/s)
Reading package lists... Done
W: GPG error: http://ppa.launchpad.net lucid Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40C18E9EC07EE05F
[...]

To add the key we use the apt-key tool. Under the PPA source lines on the Darktable page, under the title Signing Key is an eight-character key, prefixed with 1024R/ (= 1024-bit RSA encryption). The key is per-user, so will be the same for each of the Darktable releases created by Pascal de Bruijn. To add it to our GPG keychain, the command we need is:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C07EE05F

Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys C07EE05F
gpg: requesting key C07EE05F from hkp server keyserver.ubuntu.com
gpg: key C07EE05F: public key "Launchpad PPA for Pascal de Bruijn" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)

Follow this with another sudo apt-get update, and we’re done. You can install away using the usual method, for example: sudo apt-get install darktable.

It’s a little less polished than Ubuntu’s tools, but what you lose in convenience you gain in speed and responsiveness, and a better understanding of how the system works underneath – a price worth paying, imho.

UPDATE: It’s worth noting that up-to-date versions of Darktable packages now appear in Debian Wheezy (1.0.4-1) and Debian Sid (1.0.5-1).

Using #! (Crunchbang) Linux

Crunchbang is sleek, fast, minimal linux flavour based on Debian, one of the largest families in the linux ecosystem. It uses the X-Window system and Openbox window manager, with a lightweight underpinning of GTK+2.0 but without the full Gnome desktop environment, making it considerably more snappy to boot and use than full-bodied distributions such as Ubuntu or Fedora.

I’ve been using it for a month or two and liked it enough to decide to rebuild my Samsung Q320 laptop around it. I’m going to cover a few of the tweaks I applied, problems I tackled, additions or subtractions I made – just in case they’re of interest to you, the reader, but mainly so that they’re written down for me when I come to repeat this process at some point in the future.

Continue reading Using #! (Crunchbang) Linux