I’ve recently switched from Gentoo to Ubuntu. The main reasons is that in Ubuntu I have less things to take care about that I don’t really care about (like compiling Linux). In the switch I also lost some interesting features.
The most interesting feature is to be able to easily tell the packaging system that I want the unstable versions of this and that packages. I normally use the latest of GHC and Erlang (for example, the current GHC is just too old, and for Erlang, I like living on the edge; and the same for lots of other packages).
Although I was not able to reproduce that functionality completely I’ve found a good alternative. As usual this applies verbatim to other members of the Ubuntu family like Kubuntu and Edubuntu. They also apply to Debian, but for Debian there are already Backports so it doesn’t make any sense there. In this case I’ll do it for Ubuntu Edgy and Erlang, you’ll have to adapt it to your case.
Open the sources definitions in /etc/apt/sources.list and add the sources you want, but only to get sources and not binary packages (that is, the deb-src record and not the deb one). This is very important, if you add the deb you’ll get your whole system upgraded into the unstable version hence your system will be unstable. That option is only for developers, testers and adventurous people. In my case I added:
deb-src http://ar.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse
Note that it is the mirror for Argentina (the “ar.” there), pick a mirror closer to you.
As usual you have to update the database of sources:
sudo aptitude update
where you should see something like:
Get:16 http://ar.archive.ubuntu.com feisty/main Sources [278kB] Get:17 http://ar.archive.ubuntu.com feisty/restricted Sources [1740B] Get:18 http://ar.archive.ubuntu.com feisty/universe Sources [1106kB] Get:19 http://ar.archive.ubuntu.com feisty/multiverse Sources [43.3kB]
among the normal output. Very good.
I recommend running all the commands I’ll mention latter in a
particular directory for this purpose, like ~/pkg/Ubuntu/Erlang.
Basically, the build is done by one line:
fakeroot apt-get source --build erlang
but something can go wrong:
bash: fakeroot: command not found
We are missing fakeroot, we just install it:
sudo aptitude install fakeroot
and now we try the build command,
fakeroot apt-get source --build erlang
again:
Reading package lists... Done Building dependency tree Reading state information... Done Need to get 10.2MB of source archives. Get:1 http://ar.archive.ubuntu.com feisty/universe erlang 1:11.b.2-2 (dsc) [845B] Get:2 http://ar.archive.ubuntu.com feisty/universe erlang 1:11.b.2-2 (tar) [10.2MB] Get:3 http://ar.archive.ubuntu.com feisty/universe erlang 1:11.b.2-2 (diff) [33.7kB] Fetched 10.2MB in 2m33s (66.5kB/s) gpg: Signature made Thu 23 Nov 2006 02:59:49 AM ART using DSA key ID C4CF8EC3 gpg: Can't check signature: public key not found dpkg-source: extracting erlang in erlang-11.b.2 dpkg-source: unpacking erlang_11.b.2.orig.tar.gz dpkg-source: applying ./erlang_11.b.2-2.diff.gz dpkg-buildpackage: source package is erlang dpkg-buildpackage: source version is 1:11.b.2-2 dpkg-buildpackage: source changed by Erlang Packagers <erlang-pkg-devel@lists.berlios.de> dpkg-buildpackage: host architecture i386 dpkg-buildpackage: source version without epoch 11.b.2-2 dpkg-checkbuilddeps: Unmet build dependencies: debhelper (>= 4.0.0) dpatch unixodbc-dev dpkg-buildpackage: Build dependencies/conflicts unsatisfied; aborting. dpkg-buildpackage: (Use -d flag to override.) Build command 'cd erlang-11.b.2 && dpkg-buildpackage -b -uc' failed. E: Child process failed
Believe it or not, that was better. We can see that it downloaded three file, a dsc, a tar and a diff. Those are the sources of a deb package. It tried to verify the gpg signature and it failed, don’t worry about that. The real problem is in the line that starts with “dpkg-checkbuilddep”, to build Erlang we need some packages we don’t have. So we install them:
sudo aptitude install debhelper dpatch unixodbc-dev
It is possible that a unstable package would depend on other unstable packages. Imagine if Ubuntu Edgy shipped debhelper 3.6.2, then it would not be enough to satisfy the dependency of debhelper (>= 4.0.0). In that case you should restart all this process for that other package until you have all the packages you need. You may run into trouble if you hit basic packages such as linux or libc… that’s beyond the scope of this little tutorial. With those packages installed we are ready to issue the build command again:
fakeroot apt-get source --build erlang
This time nothing goes wrong and we can see the familiar compiling output. Now it is just a matter of waiting. Wait. After the wait, and if everything went right, you’ll see your newly created Erlang packages:
$ ls *.deb erlang_11.b.2-2_all.deb erlang-dev_11.b.2-2_i386.deb erlang-nox_11.b.2-2_all.deb erlang-base_11.b.2-2_i386.deb erlang-examples_11.b.2-2_all.deb erlang-src_11.b.2-2_all.deb erlang-base-hipe_11.b.2-2_i386.deb erlang-mode_11.b.2-2_all.deb erlang-x11_11.b.2-2_all.deb
All we have to do know is install them:
sudo dpkg -i erlang_11.b.2-2_all.deb erlang-base_11.b.2-2_i386.deb erlang-dev_11.b.2-2_i386.deb erlang-examples_11.b.2-2_all.deb erlang-mode_11.b.2-2_all.deb erlang-nox_11.b.2-2_all.deb erlang-src_11.b.2-2_all.deb erlang-x11_11.b.2-2_all.deb
Dpkg knows about dependencies and how to solve them but doesn’t know where to get packages from, that is what APT does (with all its repositories and all that). During that installation I’ve run into a problem:
dpkg: dependency problems prevent configuration of erlang-x11: erlang-x11 depends on tk8.4 | wish; however: Package tk8.4 is not installed. Package wish is not installed.
To solve it I just run:
sudo aptitude install tk8.4
and that was it:
$ erl Erlang (BEAM) emulator version 5.5.2 [async-threads:0] [kernel-poll:false] Eshell V5.5.2 (abort with ^G) 1>
Enjoy!
Comments in the original blog
- Gwern Says:
Wow. That’s pretty complex. Couldn’t you just pin packages to experimental or unstable, or run out of a local darcs repository?March 16th, 2007 at 2:49 e -
Pupeno Says:
You
can’t just run packages from experimental or unstable because they are
compiled for experimental or ustable. They are not likely to work with
older versions of libraries, and if you start updatnig those libraries
as well you are likely to soon hit libc6 and kaboom, your whole system
will be upgraded to experimental or unstable.I don’t know what you mean by a local darcs repository, but if it is
download the source code, compiling (like in configure, make) and
install (make install), of course you can… but you loose the hability
to do package-related actions, like uninstalling (aptitude uninstall
package), finding out what files it installed (dpkg -L package),
finding out to what package a file belongs when it belongs to our
experimental software (dpkg -S /some/file) or spread the experimental
package across comptures.I hope I have answered your question.
Leave a Reply