Thursday, July 28, 2011

How to create debian packages

Using a debian package is one of the best methods for installing, upgrading, and removing software.
Before you creating a debian package you should know exactly where should go each files/folders in your software when installing.

Refer the following folder structure to decide which file to go which folder.

usr/share/ - main program binaries, packages, manuals, resource files.
/usr/bin - symbolic links to the main program binaries or you can have main program binaries.
/etc/- program configuration files.
/etc/skel - default configurations files to be installed for every new user.



Also ,Before doing all below, you should have installed the tools you need for creating deb packages.

To install all the packages needed for creating a .deb package, run the following command:


sudo apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder

Here are the steps to follow to create a simple debian package.

1.Decide which file to go which folder for each of the file in your software.

2.Create a folder like ExampleDebianPackage_1.0.0

3.Inside that folder create folders like,
usr/share
usr/bin
etc/
etc/skel

and place your files inside those folders as appropriately.

4.then create another folder called DEBIAN inside ExampleDebianPackage_1.0.0

5.inside DEBIAN folder create a text file called "control" which is the most import file in debian packaging.


example control file:


Package: RoleSwitcher 
Version: 1.0.0  
Priority: optional 
Architecture: all
Depends: screenlets
Installed-Size: 1024
Maintainer: sampath bandara amarasinghe   
Description: Describe what can do your software primarily.
in addition to these fields there are some other fields.

like this create your own control file.

now you are ready to create the debian package.

6.open up a terminal and go to the ExampleDebianPackage_1.0.0 folder location and type

dpkg -b ExampleDebianPackage_1.0.0


this will create a debian package for you,


1 comment:

  1. Thank You Sampath.A great post.Above is all we need to know to create a simple deb package of our own.

    For a person who would like to work in depth on creating deb packages following will be helpful.

    http://www.debian.org/doc/FAQ/ch-pkg_basics.en.html

    ReplyDelete