Friday, May 23, 2014

How to build a debian package from source?

1. download the source from the repository

 $apt-get source    Ex. $apt-get source scimsource

 This command will fetch the source code of the package you specified in , which will contain .dsc, .orig.tar.gz, sometimes .diff.gz.

2. Apply changes/differences with the original source

[Assume that I downloaded the packages under ~/Download/scimsource.]

$cd ~/Download/scimsource

apply the diff (changes) to the orig source by

$dpkg-source -x .dsc

[For further details about unpacking debian source you can refer this crisp & simple howto.]

Now, the changes will be applied to the source. 

3. Build/Compile the source to build installable deb package.

   a)  If you want to add some changes in the source code or add some features to the existing source code proceed with the extracted source & then update the Changelog* file accordingly. 
  b) If your aim is just to build the deb package from the source you need not to touch the Changelog file.

For building the source to deb package you need to

  i). Build dependency

  $sudo apt-get build-dep

  This command will install the needed libraries, other packages that are
  essential for compiling/building the source into deb.

  ii). Build the source by,


  $sudo dpkg-buildpackage -rfakeroot -us -uc -sa

Note:  you must issue the above command provided that you are inside the package's source directory. (first do $cd ~/Download/scimsource/scim).



* -> changelog file will be available in the extracted source under "/debian/Changelog"



No comments: