|Todd on Installing Debian to disk on a…|
|Jorge Ferreira on Installing Debian to disk on a…|
|nigelr on Installing Debian to disk on a…|
|Guillermo on Installing Debian to disk on a…|
|arvati on Installing Debian to disk on a…|
Above average nerdiness
I’ve previously struggled to find a reliable way of building packages on my ubuntu laptop for my ix2-200 running squeeze. I’ve tried scratchbox/scratchbox2 in various configurations, and although it will work for some packages, not all packages work all the time, and I usually end up fiddling with scratchbox 2 settings/scripts/modes to make it work or using a native qemu session. The problems seem to be related to running scratchbox 2 directly on Ubuntu and thus which native tools that scratchbox 2 tries to use.
Recently my wife got a MacBook Air and so she needs a TimeMachine compatible system to back it up to if she wants to do so over the network. This means I needed to get the netatalk package working on one of my ix2-200s, but because the latest version of MacOS X requires AFP 3.3 support for TimeMachine, I needed 2.2.x rather than the 2.1.x that is currently available in squeeze. At the same time, I was also having a play with LXC that comes with Ubuntu 12.04 and lets you set up lightweight Debian and Ubuntu containers for process isolation etc. so I decided to see if I could get a reliable cross-compile environment going for this. I’m happy with the results and l like how I there is no dependency on packages installed in the underlying OS, although there are probably better ways to do it using tools directories and one of the other scratchbox modes.
The first step is to install LXC and create a Debian Squeeze container:
apt-get install lxc lxc-create -t debian -n build lxc-start -n build /sbin/init -d lxc-console --name build
Once logged into the console (using the root account and password that it tells you in the output to lxc-create), you can then install all the required packages to run scratchbox. I use scratchbox2 and qemu from testing as well as the emdebian toolchain from its own repo, as the stable stuff is just a bit old, so I need to create the right APT preferences.
To enable the testing and emdebian repos, put the following in /etc/apt/preferences.d/10testing. I used cat to do this, because vi wasn’t installed:
Package: * Pin: release a=stable Pin-Priority: 900 Package: * Pin: release o=Debian Pin-Priority: -10
Put the following in /etc/apt/apt.conf.d/10testing:
Edit your “/etc/apt/sources.list” and add this
deb http://cdn.debian.net/debian testing main deb-src http://cdn.debian.net/debian/ testing main deb http://security.debian.org/ testing/updates main deb-src http://security.debian.org/ testing/updates main deb http://www.emdebian.org/debian/ squeeze main
Install the emdebian keychain to avoid unauthorised packages:
apt-get update apt-get install emdebian-archive-keyring apt-get update
Then install the packages needed for cross compiling, including scratchbox2 and qemu-user which we will reinstall later:
apt-get install gcc-4.4-arm-linux-gnueabi build-essential cdbs hardening-includes libcrack2 apt-get install scratchbox2 qemu-user libavahi-client-dev gcc-multilib autoconf realpath debootstrap sudo
Install qemu-user and scratchbox2 from testing:
apt-get -t testing install qemu-user scratchbox2
Install the build dependencies for netatalk, otherwise sb2 in simple mode won’t find all the files required to build netatalk:
apt-get build-dep netatalk
At this point you want to create a normal user for youself with access to sudo to continue the rest of the setup:
adduser <username> adduser <username> sudo
Once you’ve logged in as your new user, initialise the sb2 environment in their home directory.
mkdir debian && cd debian sb2-init -n -c /usr/bin/qemu-arm debian arm-linux-gnueabi-gcc fakeroot /usr/sbin/debootstrap --variant=scratchbox --foreign --arch armel squeeze ~/debian http://cdn.debian.net/debian/ sb2 -eR debootstrap/debootstrap --second-stage
Create the new sources.list in ~/debian/etc/apt/sources.list:
deb http://mirror.internode.on.net/pub/debian/ squeeze main deb-src http://mirror.internode.on.net/pub/debian/ squeeze main deb http://security.debian.org/ squeeze/updates main deb-src http://security.debian.org/ squeeze/updates main
Update the apt database and install the dependencies for building netatalk:
sb2 -eR apt-get update sb2 -eR apt-get install libavahi-client-dev # this is missing from the dependencies in the testing netatalk source package sb2 -eR apt-get build-dep netatalk
You will get an error because dbus fails to install, but you can just go ahead and remove it:
sb2 -eR apt-get remove dbus
Now retrieve the source for netatalk in another directory:
cd ~ apt-get source -t testing netatalk cd netatalk-2.2.2 sb2 dpkg-buildpackage -rfakeroot -b -d -uc -us
And that’s it! There are plenty of other sites out there on how to configure netatalk for TimeMachine, so I’ll leave that as an exercise for the reader.