Sunday, November 20, 2016

Debian packages mini howto

Sure there are many places you have good tutorial for debian packages
but here I am going to add short howto.


How to build a debian packages:

Just head on to where you find catalog of packages, choose
one you like

Lets say I want to build one of most popular packages "vlc"

You can see lots of information about the package and also soure package link 
on the right side of the page, now download file ending with ".dsc" 

The dsc file can fetch all required source and apply debian patches required
when run it with dget command. If dget is not available, please install them
by apt-get install devscripts

1. dget -x

Now you have all the sources and patches applied, head on building the packages with the command debuild

2. debuild -b -us -uc

The options are to instruct only to build binary packages without signing it.

3. Now you may be reported for some dependencies required to be installed on the running system, resolve them by installing it using apt-get install.

4. Once  the debuild completes you will get the packages .deb files in the source directory, we can go and install them using dpkg.

dpkg -i vlc*.deb

Hope I think I covered the major steps you need to start with. Isn't this simple?
One of the reason why debian has large community.

Speeding up building debian packages

I have been away to blogging for a while and but am planning to write more on the work I do so that it may be useful to others and definitely useful when I read back.

As part of my work, I was building debian browser packages, which is firefox-esr.

We are bringing lots of the changes in the default settings, security and privacy and also changes on the branding.

The main problem that happens when building such big package is build time it takes for a complete build, for firfox-esr it takes 2.5 hrs on a i7 machine.

The best we can do reduce the time is to let the compiler to compile only the modified changes which are minimal in nature rather compiling the entire sources.

I have come across the ccache which is the best friend in this case. First make sure you have ccache installed on your debian machine.

sudo apt-get install ccache

Then if you are building the package first time use the following command.

debuild --preserve-envvar=CCACHE_DIR --prepend-path=/usr/lib/ccache -b -uc -us

In the above command I am build the debian package using debuild, the options

--preserve-envvar=CCACHE_DIR --prepend-path=/usr/lib/cache is passed to the ccache

The other option -b is to instruct to build only .deb packages and -uc -us are for building the unsigned packages

Please remember there won't be any error message if you don't have the ccache installed but then the recomilation takes complete rebuild.

I jumped to ccache without explaining about debian packages intro which I will add in later blogs.