Accessing Debian Sid software from stable

So, I needed to access a file which had been created on my old Mac laptop using a newer version of an open-source application (installed via Homebrew on the Mac) than was currently packaged in Debian stable.

To my mind, I had 3 obvious choices:

  1. Download from source, build by hand and use it
  2. Download the Debian source package, rebuild it on stable, install and use it
  3. Create a Debian unstable (Sid) chroot, install it there and use it

I decided to go with option 3, which has a number of advantages over the other 2:

  • apt/the developers have already handled any dependencies (and version differences) needed by the new version
  • I don’t pollute my root filesystem with a version other than the one packaged and tested in stable (option 2)
  • I don’t have different versions of the same software installed on the path, in /usr and /usr/local (option 1)
  • If this were more than a one-off I could use apt in the chroot to track and keep the software updated with the current version in Debian unstable
  • I can install other software in the chroot, once it’s setup, direct from the repository

Alternatives I didn’t look would be installing unstable in a virtual machine or containers. I need this for a quick and dirty one-time task (install new version, convert file to old version, throw away chroot and use version installed with stable from now on) so either of these would be more effort for me than required (writing this blog post took longer than the actual task, below!).

To get this working, firstly we need debootstrap installed:
apt-get install debootstrap

Make a directory for the chroot:
mkdir /tmp/sid-chroot

Install Debian into the chroot:
debootstrap unstable /tmp/sid-chroot http://ftp.uk.debian.org/debian/

Change into the chroot:
chroot /tmp/sid-chroot

Update software:
apt-get update

Install and use new version of software within chroot.

This was a quick-and-dirty solution to a temporary problem (once opened and saved in the older format, I can use my file with the old version).

The Debian wiki recommends making these configuration changes to a chroot, which I’ve not bothered to do (as it was going to last all of 5 minutes):

  1. Create a /usr/sbin/policy-rc.d file IN THE CHROOT so that dpkg won’t start daemons unless desired. This example prevents all daemons from being started in the chroot.

    cat > ./usr/sbin/policy-rc.d <<EOF
    #!/bin/sh
    exit 101
    EOF
    chmod a+x ./usr/sbin/policy-rc.d
  2. The ischroot command is buggy and does not detect that it is running in a chroot (685034). Several packages depend upon ischroot for determining correct behavior in a chroot and will operate incorrectly during upgrades if it is not fixed. The easiest way to fix it is to replace ischroot with the /bin/true command.

    dpkg-divert --divert /usr/bin/ischroot.debianutils --rename /usr/bin/ischroot
    ln -s /bin/true /usr/bin/ischroot

A more complete chroot solution would involve the use of schroot to manage it, which I’ve done before to get an old ruby-on-rails application working on newer versions of Debian.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>