<

 

Compiling packages on Debian-based Linux distributions

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Written by: J. Reubsaet

See License for licensing information

 

 

License

 

This document is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license. This means that:

 “

You are free to:

 Share — copy and redistribute the material in any medium or format

Adapt — remix, transform, and build upon the material

for any purpose, even commercially.

 

The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

Attribution — You must give appropriate credit , provide a link to the license, and indicate if changes were made . You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.



ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.



No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

 

Notices:

You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.

No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.

As quoted from: http://creativecommons.org/licenses/by-sa/4.0/

 

he process of installing software directly from its source can be a pain to uninstall or to even compile. I have noticed that building software packages (in this case Debian packages) has relieved me of such pains; Dpkg and APT handle the package, which therefore is easily uninstallable, unlike directly installed compiled source code. The purpose of this simple tutorial will be to show you how one compiles Debian packages, be they complex or simple.

First of all, we will need some essential packages which offers the basic necessities for compiling packages. Installing the following packages:

dpkg-dev

build-essential

dh-make

then , download the source packages you want to compile. If the package is in a repository of which you are not sure whether it is compatible, run the following command:

apt-get source <packagename>

Or, if you are on a Debian-like distribution without APT, download the source package you want to build. Then fire up a terminal and navigate to the directory you downloaded the source archive in. Run the following command to extract it:

- for Bzip2: tar xvJf <archivename>.tar.bz2

- for Gzip: tar xvzf <archivename>.tar.gz

Then, change directory into the folder which contains the sources.

After that, verify that you have all building dependencies installed. If this package is in the repositories, run the following command to install the dependencies:

sudo apt-get build-dep <packagename>

If you downloaded the sources from a website, check a README or INSTALL file or on the website of the program for building dependencies. If you do not have these installed, the package will fail to compile.

If you've got limited hard drive space, note these packages. They might take up a considerable amount of room.

After you have done that, you are ready to Debian-ize the source package. If you have downloaded the archive with APT, you can skip this step. If not, continue. Run the following command:

dh_make --creatorig

When it asks you for the type of package, the option most users need is Single Binary (s).

Then, press Enter when it asks you to confirm the info.

A sub directory called debian is created in the folder which contains the sources. This folder contains files which will tell Dpkg what packages it requires to be installed, which it conflicts with and which it recommends and/or suggests (that being control). If you know that some dependencies are unneeded, you can modify that file as to remove some dependencies.

Next, type the following command:

dpkg-buildpackage

This will compile the source code into binaries and will form a Debian package together with the debian folder. Depending on the size and complexity of the sources, this might take up several minutes up to several hours.

At last, when the package(s) has (have) been generated, you can install it (them) with the following command:

sudo dpkg -i <packagename>.deb

That sums up the compilation process. If you have any questions, feel free to visit #debian-talk on irc.spotchat.org and ping jens.

I hope this guide will be helpful for you.