How to build a Debian/Ubuntu package from source?

Ryszard Szopa picture Ryszard Szopa · Sep 25, 2008 · Viewed 104.9k times · Source

I have the source of a program (taken from cvs/svn/git/...) and I'd like to build a Debian/Ubuntu package for it. The package is present in the repositories, but:

  • It is an older version (lacking features I need)
  • I need slightly different compile options than the default.

What is the easiest way of doing it? I am concerned about a couple of things

  • How can I check if I have listed all the dependencies correctly? (I can get some hints by looking on what the older version depended, but new dependencies may have been added.)
  • How I can I prevent the update system installing the older version in the repo on an update?
  • How I can prevent the system installing a newer version (when its out), overwriting my custom package?

Answer

 picture · Nov 21, 2008

you can use the special package "checkinstall" for all packages which are not even in debian/ubuntu yet.

You can use "uupdate" (apt-get install devscripts) to build a package from source with existing debian sources:

Example for libdrm2:

apt-get build-dep libdrm2
apt-get source libdrm2
cd libdrm-2.3.1
uupdate ~/Downloads/libdrm-2.4.1.tar.gz
cd ../libdrm-2.4.1
dpkg-buildpackage -us -uc -nc