A beginner’s guide to Debian Source Packages

Source packages have a very different process of installation and handling while compared to the traditional executable packages which are handled by the sudo apt-get install command. Source packages provide source for a software. These are used to build other packages. Source code can be studied or errors can be fixed in this by downloading these to your system.

To access these you have to add deb-src lines sources.list in /etc/apt/sources.list If you had followed my earlier article on setting up Jessie, this means you have to remove the ‘#’ in front of the deb-src lines.

First, find the required source package online in the debian packages list here. Be sure to select the ‘Source Package Names’ option while searching. When you find a package it will have a list of binary packages that are built from this source package.

Make sure you have all the dependencies to build the package by running:

     $ apt-get build-dep packagename

Then, download the source package, using the following command:

     $ apt-get source packagename

This will download three files: a .orig.tar.gz, a .dsc and a .diff.gz. In the case of packages made specifically for Debian, the last of these is not downloaded and the first usually won’t have “orig” in the name.

The .dsc file is used by dpkg-source for unpacking the source package into the directory packagename-version. Within each downloaded source package there is a debian/ directory that contains the files needed for creating the .deb package.

To auto-build the package when it’s been downloaded, just add -b to the command line, like this:

     $ apt-get -b source packagename

If you decide not to create the .deb at the time of the download, you can create it later by running:

     $ dpkg-buildpackage -rfakeroot -uc -b

from within the directory that was created for the package after downloading. To install the package built by the commands above one must use the package manager directly, like this:

     # dpkg -i file.deb

There’s a difference between apt-get‘s source method and its other methods. The source method can be used by normal users, without needing special root powers. The files are downloaded to the directory from which the apt-get source package command was called.

Tip : If you are a developer testing software, you may need to run the make command after this. Be sure to run make check as well later to make sure there are no errors and everything is alright.

Most of the commands I’ve used here was by following the APT How To documentation which is marked as “obsolete” for some reason but turned out to be pretty useful. Hope it works for you too! 🙂

Related Posts
keerthana

Comments ( 4 )
  1. Marianne
    June 21, 2016 at 3:41 pm
    Reply

    I see you don’t monetize your blog, i know how to earn some extra money and
    get more visitors using one simple method, just search in google for:
    How to monetize a blog Twardziel advices

    • keerthana
      June 21, 2016 at 5:11 pm
      Reply

      Sure, I’ll look into it. Thanks for your advice.

  2. Homepage
    July 9, 2016 at 2:23 pm
    Reply

    … [Trackback]

    […] Read More: thewaterbabe.in/2016/06/13/a-beginners-guide-to-debian-source-packages/ […]

  3. Quelques nouvelles du projet Debian – PassionGNU/Linux
    August 4, 2016 at 5:21 am
    Reply

    […] bonnes choses comme toujours, notamment des astuces comme un guide du débutant pour les paquets source de Debian partagé par Keerthana […]

Leave a reply