Creating a package .deb in Ubuntu

Posted: April 25, 2011 in Ubuntu
Tags: , ,

Hello everybody. Today we will see how we can create a package .deb in Ubuntu.
This type of package is a compacted file that contain softwares, libraries and instruction set for installing them. It is a good way to optimize the installation process.

So, let’s start the package creation. Firstly we need to create the basic structure. Open a shell and type:

mkdir -p ~/pkgdeb/DEBIAN
mkdir -p ~/pkgdeb/usr/sbin

The pkgdeb folder is our base directory where we will mount the structure that will be used to be installed.
Regarding the DEBIAN folder, this one will not be included in the package. It is important to specify information about package control. To do that, inside of this folder, create a file named control and fill it up with the following data (you can use the vim):

Package: pkgdeb
Priority: optional
Section: misc
Version: 1.0
Architecture: amd64
Maintainer: Buildall
Depends: build-essential, qt4-designer
Description: This package, demonstrate how we can create packages

In architecture field you must inform in which kind of architecture this package will be installed. It can be i386, amd64 and all. In my case, I am using 64 bits.
Now, inside of the folder ~/pkgdeb/usr/sbin create a file named pkgdeb and type (again you can use the vim):

echo "This is just a example about how to create a package"

Set the permission to this file:

chmod 777 ~/pkgdeb/usr/sbin/pkgdeb

The file pkgdeb created in ~/pkgdeb/usr/sbin will be copied to the folder /usr/bin during the installation. Any file you put here will be copied too. However you can specify another local like /usr/local/bin but in our base directory we would specify ~/pkgdeb/usr/local/bin.

To complete our example, with the shell opened type:

cd
dpkg -b pkgdeb pkgdeb.deb

Done that, you have a package created. So you just need to test it. Still in the shell, type:

sudo dpkg -i pkgdeb.deb
pkgdeb

You will have this message in the shell:
This is just a example about how to create a package

Remember it is just a example, in the field Depends I just showed how we can use dependency.

That’s it. See you next time.

Advertisements
Comments

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