Wednesday 30 May 2012

Steps to build debian package


Before go for this, need to know about debian package.

Debian package contains set of files that will install that package where we run this debain in ubuntu linux. Like exe in windows. So, Debian package is used to install particular software in ubuntu linux.

Now, Let start how to build this debian pacakge.

Requirements to build debian packages : Ubuntu System/VM

1. First we need some packages to build debain package in ubuntu. 
Run following command

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

[ For ubuntu linux, we can use apt-get package manager to install any package ]

This command will install all packages specified.

2. Then, create source folder.  [ Folder name should be in lower case ]

Debian pacakage name have some naming convensions,  For Example. My source folder name is clientprojrct-1.0

This contains clientproject_1 folder. it contains all files need to be packed in debian package.

Folder structure  clientproject-1.0  -> clientproject_1

3.  Begin debianization
To build debian package, we need some files [ like control, postinst, postrm etc ] to define debian package.

After create source folder, we need to run this command.

cd clientproject-1.0

dh_make   [ This command will create one debian folder. This folder contains all neccessary files ]

After run this command,this will print

Type of package: single binary, indep binary, multiple binary, library, kernel module, kernel patch or cdbs?
[s/i/m/l/k/n/b]

Give option : s

4. Control file
Probably the most important step is how you edit the control file.

This file will be created after completing step 3, and you can find it in the "debian" folder in the directory containing your source files. It initially looks like this:

   1 Source: x264
   2 Section: unknown
   3 Priority: extra
   4 Maintainer: andrei <webupd8@gmail.com>
   5 Build-Depends: debhelper (>= 7), autotools-dev
   6 Standards-Version: 3.8.1
   7 Homepage: <insert the upstream URL, if relevant>
   8
   9 Package: x264
   10 Architecture: any
   11 Depends: ${shlibs:Depends}, ${misc:Depends}
   12 Description: <insert up to 60 chars description>
   <insert long description, indented with spaces>

For now, enter a hompage (line 7) and a description (line 12) for your package.

Now, a very important step: we must enter the build dependencies on line 5.

For example, Am created one application in java and I packed that application in debian package. To run that application, I need java.
Like this all needed packages, We should include in debian dependencies.

Then, if we need noacrh debian, then need to update "Architecture" as "all".
[ noarch : no architecture. We can install this debian package in both 32 and 64 bit system ]

5. The "copyright" file

In the same "debian" folder, you will also find a "copyright" file which you need to edit. The important things to add to this file are the place you got the package from and the actual copyright notice and license. You must include the complete license, unless it's one of the common free software licenses such as GNU GPL or LGPL, BSD or the Artistic license, when you can just refer to the appropriate file in /usr/share/common-licenses/ directory that exists on every Debian system.

6. The "changelog" file

You can fild this in the same "debian" folder, this file is very important. Here, You need to mention name and date deails.

x264 (0.1+svn20100107-1) unstable; urgency=low

* Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>

-- andrei <webupd8@gmail.com> Sat, 09 Jan 2010 22:40:24 +0200

7.  The "postinst" file

You can find this in the same "debian" folder. Here we need to mention where packed files are need to copy.

8. The "postrm" file

You can find this in the same "debian" folder. Here we need to mention what are the files are need to remove while uninstall this package.

9. Building the actual .deb package

After defined debian packages, we need to run this command to build debiam.

cd clientproject_1.0 -> clientproject_1

debuild -b     [ This will build debian packgae ]

After run this, you can get debian package.

No comments:

Post a Comment