Dienstag, 9. Februar 2010

yet another ubuntu package rebuild guide

Hi all!

Recently I wanted to rebuild a package on my kubuntu 9.10 system to fix a stupid bug with a very easy patch, where the package maintainers were not able or willing to do that themselves since months and fix the bug for everyone.

I searched for guides on how to do that most easily, but all guides missed some bit of info here and something there and a small error in the end and so on. Some forget to push the version, some "sudo" too much, resulting in file access problems, oh my, it was a mayhem. So after getting all needed info from about 3 or 4 places, I now decided to try making such a guide in a better way.

Note that this is just for personal use on my machine, because I don't create patch or diff tarballs for my changes and so on, I just make the changes, push the version and rebuild.

My package to rebuild was "audacious", so you have to replace this with whatever package you need to rebuild.

Prerequisite: Just once you need to install the needed tools to create debian packages. You do this with:

sudo apt-get install build-essential fakeroot dpkg-dev devscripts

1:  Get the build dependencies of the package. This will install every library and development package you need to build that baby. Might be quite a bunch of packages, but normally most of them are -dev packages with some header files within a few kilobytes.

sudo apt-get build-dep audacious

2: Create a new build directory to not mess up your home or such. Enter that folder.

mkdir build && cd build

3: Get the sources of the package and unpack it in the actual folder (consider re-checking you're really in the "build" folder using "pwd" if your shell doesn't show it to you anyway). Yep, no "sudo" here:

apt-get source audacious

4: Now enter the new sub directory that contains the sources (named "packagename-version"):

cd audacious-2.1/

5: Set your emailadress and push the version and put something into the changelogs to remember what you did

EMAIL=myemail@addr.ess dch -i

First time you do that you might be asked to choose a command line editor. I use vim.basic, tho beginners might choose nano or such. Your email address will be put into the file and the revision get's pushed automatically. Just enter your changes after the asterisk char like the maintainers before did. Save and close.

6: Make your changes. Do whatever you want to be done to the sourcetree. Or/and edit the file "debian/rules" to add configure flags for example.

7: Recompile the whole thing

dpkg-buildpackage -rfakeroot -b

If all went good (means you didn't mess up the source with your changes ;) ) you end up with one or more fresh .deb packages in the build directory. Install them with dpkg -i or whatever you use to install your .deb files.

Feel free to send me comments or hints on how to do something better/easier. Unlike the other guides I will listen to my commenters and update this guide  accordingly if I can see the benefit.




Michael hat gesagt…

Great guide, I  found it very useful, though installing stuff with apt-get is very easy and the way ubuntu is now if a command is not found it tells you what package that contains it. I am using the 11.04 release and when I ran the dch command it told me that it wasn't installed, but that I needed to install the 'devscripts' package. Not a real problem, but in the interests of being thorough if you wanted to ammend the 'sudo apt-get install build-essential ...' line above, or for other people who find this post, just information

Sleeksorrow hat gesagt…

Hey Michael, thanks for the hint! Seems I already had that devscripts package installed before, so I didn't recognize this was missing :) I'll update the post!

Kommentar veröffentlichen