My first Debian Package

The Debain logo
The Debain logo

The following is my first technical post , this is something that I have long been thinking of and now finally , I’ve gathered courage to post this .I will write about my experience of my first open source contribution , my first Debian package .Some useful / basic info on what the term Debian Packaging actually refers to , [1] , this will contain the answer to most of the questions that you may have and the one mentioned above .For beginners , in simple words , this is what you have to go through when you decide to do a Debian Package .

  • Firstly , to build a package , you need to chose one . So ,choose a package .
  • Check if it has already been packaged or if someone is already working on it.
  • If you get all clear , i.e no one else is working on it . Go ahead !
  • File an ITP (Intent to Package).
  • Try building the package with suitable commands.
  • Run tests to test for errors(syntax flaws).
  • Build the package again in a clean chroot environment.
  • Upload your package for review.
  • Finally, if your package is error-free and working , some Debian developer will upload your package .
  • You have now successfully completed packaging.

First step , choose your Gem .

FYI : Gems are nothing but distributed ruby libraries , which we aim to package in the Debian format .

To check if your chosen gem is already being packaged by someone else ,in your terminal use the command

wnpp-check<gemname>

Next , install the gem2deb , run the command ,

 sudo apt-get install gem2deb 

Once the installation is done , you might want to create a directory(and sub-directories) of your choice in which you can store all the packaged files . Do this using the mkdir command.

In the directory that you created look out for the Control,Copyright and Changelog files . These are the files in which you’ll be prompted to make changes once you run the next command .

My package was the ruby-sinon-rails , which was a relatively easier one . The package was directly built after running the gem2deb command . But in most cases , you will have to go through the pains of running ruby tests and basic quilt [1].

[1] is the wiki page of the Debian packaging for diaspora . It is specific to this stream and if anyone is doing a package for diaspora , this will serve as an excellent guide .

To build your package , run the following command on a terminal/konsole .

 dpkg-buildpackage 

This will build the package for you and help you move on to the next steps .

Our next task is to run the lintian command . The lintian dissects the debian package and reports bugs and policy violations . Run the command as follows :

 lintian -iIEcv -- pedantic --color auto ../ ruby-<filename> * . changes 

An , easy way to ommit writing such a lengthy and cumbersome command is to make alias in the .bashrc

In your terminal , type in gedit ~/.bashrc , the text editor will open the .bashrc file .

Now add a line

alias lintian=lintian -iIEcv -- pedantic --color auto 

save it and the run the command ,

 source ~/.bashrc 

Now everytime you run the lintian command , you can be assured that things will work out the right way and you won’t miss out on any thing .

Now , you might encounter some errors after running the command , eradicate them by making changes in the Control/Copyright/Changelog files .

Once you are free of errors , run the dpkg-buildpackage command

Run the lintian command again and see if there are any errors popping up again .Once you checked and are finally convinced that there are no more errors returned by running the lintian , we can proceed .

NOTE : My gem didn’t have any ruby tests to be done , neither was the basic quilt required . You might not be so lucky . So, don’t forget to run the tests . Look for references ! [1]

The Pbuilder :

Once you have run all the tests and ensured that the lintian is clean , you must now make sure if it builds properly . By running Pbuilder you can find out if you missed any dependencies debian/control file . By running this , you are also elimiating any possibilities of an FTBS error – “Fails to Build from Source” . [7]

You will have to install the Pbuilder , if you don’t have it with you and make the following changes to the directories specified in the .pbuilderrc


BASETGZ=/home/harish/Build/PBuilder/sid-base.tgz

BUILDPLACE=/home/harish/Build/PBuilder/build

CCACHEDIR=/home/harish/Build/PBuilder/ccache

BASEPATH=/home/harish/Build/PBuilder/base.cow

COWBUILDER_BASE=/home/harish/Build/PBuilder/

DISTRIBUTION=sid

BUILDRESULT=/home/harish/Build/PBuilder/results

APTCACHE=/home/harish/Build/PBuilder/aptcache

DEBEMAIL="R.Harish Navnit <harrygreenghost@gmail.com>"

AUTOCLEANAPTCACHE=yes 

Be careful to set the appropriate directories , the above is just an example .

Now , you must build the package you’ve already created again with the help of pbuilder . Type in

 sudo pbuilder build <package-name>.dsc 

It’s result can be found in a results folder that will be created in the Pbuilder directory .

Now make sure it’s lintian is clean , by running the lintian command on the .changes file after changing the working directory to the results directory .

Once you have done all this , it’s time to upload your work on one of the many version-control systems (VCS) , in this case , I chose gitorious, but there are many others like github, butbucket etc.

Upload your files , and mail a mentor  asking him to upload your package . This will find it’s place , in the new package queue . Be patient , this takes time  [4]. Very soon someone will sponsor your package and you will be done. FYI : I’m still waiting for the same .

If there’s any change required , you will be notified of the same , and you might have to do some bug fixes , but all said and done you have successfully completed your first debian package . Kudos !

Keep looking for more info on this avenue. I can assure you , that you will find plenty of them and if you press a little hard , you could even find a mentor .

P.S : The role of a mentor can’t be neglected , especially if you are a beginner . I found the help of Praveen A [6] There is so much about packaging that this post does not cover . Please don’t consider this a tutorial . I will provide you with some references. Keep looking for more.

Another important point that I would like to mention is that my package was , as stated earlier , “the easier one” . There are a few more steps in the procedure . But , then this one was just to create awareness about FOSS and contributions.

Some useful references :

[1]  https://wiki.debian.org/Diaspora/Packaging

[2]  http://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html

[3]  http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/

[4]  http://mentors.debian.net/intro-maintainers

[5]  http://try.github.io/levels/1/challenges/1

Advertisements

6 thoughts on “My first Debian Package

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s