I recently switched from Arch Linux to Debian on the laptop. I did this because I run into a problem during an exam where virtualbox didn't want to work. So far it's working great for me however I obviously miss some of the very up to date applications from Arch. Luckily I found a way around this problem, it's not perfect but it works good enough for me to keep using Debian.

The solution is having a chroot in which I'm downloading the source from unstable or some other repo and then compile the missing applications. You could do this directly inside your normal system but I prefer to do it inside a chroot because this way I don't have to install a bunch of build depencies on my regular system.

First we have to set up the chroot. For this we have to create a folder in which we want to install the chroot. I called mine packages. In addition we need to install some packages.

mkdir ~/packages
sudo apt-get update && sudo apt-get install binutils debootstrap fakeroot devscripts

Then we can install the system into the freshly created directory with the debootstrap command. The following command will install a 64-bit Debian Jessie inside the packages folder.

sudo debootstrap jessie ~/packages/ http://httpredir.debian.org/debian

This will take a while because it has to download all the relevant files. Once it's finished we chan already switch into the chroot with the following command.

sudo chroot ~/packages

As a first step I install some useful packages:

apt-get install vim htop sudo

You will notice that the information left to the cursor changes slightly. However it's not really obvious that we're currently inside the chroot. To improve this, we'll need to make some configurations inside the chroot.

Firstly we'll give the chroot a name. For this we have to create the debian_chroot file in /etc/ and add the desired name on the first name, in my case this is build-chroot.

vim /etc/debian_chroot

This allone isn't enough however. To display this name left of the cursor we have to make some changes to the .bashrc files in /etc/skel/.bashrc and /etc/bash.bashrc. For this we can use the replace function of vim to replace all instaces of “@\h“, eg by doing “:%s/@\h//gc” with repeated presses of y.

At the moment we're working as root inside the chroot. To avoid this I've created an additional user and added it to the sudo group.

adduser username

Additionaly it makes sense to add the user to the sudo group.

adduser andreas sudo

To enter the chroot directly with that user one can use the following command:

sudo chroot ~/packages su - username

The chroot is now finished and ready to be use.

When I researched this topic I've seen that a lot of people are mounting various system directories. I haven't done this in my chroot because a) I don't really understand the reasons for doing it. b) I currently haven't noticed any downsides for not doing it.

Be sure that you execute the following commands inside the chroot.

To be able to download the source for a package in unstable we have to add the source repository to the sourcelist. This can be done with a single command:

sudo echo "deb-src http://httpredir.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list

Don't forget to update the sourcelist otherwise it won't use the new repository.

sudo apt-get update

We need to install the required build depencies for nmon

sudo apt-get buil-dep nmon/unstable

Now we can dowload and compile the source of the package. The following command will download and compile the package.

apt-get source --compile nmon/unstable

After the compiling went trough successfully you can exit the chroot.

exit

Now you can navigate into the home folder of your chroot user then install the compiled package:

cd ~/packages/home/username/
sudo dpkg -i nmon*.deb

Some things to note:

  • It sometimes happens that you have to compile other packages before you can compile the package you want to install.
  • It can happen that the package is getting installed but requires some more runtime depencies. Those can get installed with "sudo apt-get install -f"

Next Post Previous Post