Ubuntu has thousands of .deb files in the official and unofficial repositories. But, all packages will not be available in DEB format. Some times, packages might be available only for RPM based distros, or Arch based distros. In such cases, it's important to know how to create a .deb file from source file. In this brief tutorial, let us see how to create a .deb file from Source file in Ubuntu 16.04 LTS. This guide should work on all DEB based systems such as Debian, Linux Mint, and Elementary OS etc.

Create a .deb file from Source in Ubuntu

First, we need to install the required dependencies to compile and create DEB file from source file.

To do so, run:

sudo apt-get install checkinstall build-essential automake autoconf libtool pkg-config libcurl4-openssl-dev intltool libxml2-dev libgtk2.0-dev libnotify-dev libglib2.0-dev libevent-dev

We have installed the required dependencies. Let us go ahead and download the source file of a package.

Downloading source tarballs

For the purpose of this tutorial, let us create .deb file for Leafpad source file. As you know already, Leafpad is the simple, graphical text editor.

Go to the Leafpad home page and download the tar file.

wget http://tarot.freeshell.org/leafpad/leafpad-0.8.17le2.tar.bz2

Then, extract the downloaded tar file as shown below.

tar xvjf leafpad-0.8.17le2.tar.bz2

Then, go to the extracted folder, and run the following commands one by one to compile the source code:

cd leafpad-0.8.17le2/

./configure

Note: In case ./configure command is not found, skip it and continue with next command.

make

Finally, run the following commands to create .deb file from source code.

sudo checkinstall

Sample output:

Type Y when asked to create the description for the Deb file.

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran This software is released under the GNU GPL. The package documentation directory ./doc-pak does not exist. Should I create a default set of package docs? [y]: y

Next, type the description for the DEB file, and press ENTER double time to continue.

Preparing package documentation...OK Please write a description for the package. End your description with an empty line or EOF. >> This Leafpad DEB file has been created from source code >> EOF

In the next screen, you will see the details of source file that you are going to create a DEB file from it. The DEB package will be built according to these details.

Review the details, and change them as your wish.

***************************************** **** Debian package creation selected *** ***************************************** This package will be built according to these values: 0 - Maintainer: [ [email protected] ] 1 - Summary: [ This Leafpad DEB file has been created from source code ] 2 - Name: [ leafpad ] 3 - Version: [ 0.8.17 ] 4 - Release: [ 1 ] 5 - License: [ GPL ] 6 - Group: [ checkinstall ] 7 - Architecture: [ amd64 ] 8 - Source location: [ leafpad-0.8.17 ] 9 - Alternate source location: [ ] 10 - Requires: [ ] 11 - Provides: [ leafpad ] 12 - Conflicts: [ ] 13 - Replaces: [ ]

For example, I want to change the maintainer Email id. To do so, press number "0". Type the maintainer email, and press ENTER key.

Enter a number to change any of them or press ENTER to continue: 0 Enter the maintainer's name and e-mail address: >> [email protected]

Finally, press Enter if you ok with details.

The .deb Package has been built successfully, and installed automatically.

********************************************************************** Done. The new package has been installed and saved to /home/ostechnix/leafpad-0.8.17/leafpad_0.8.17-1_amd64.deb You can remove it from your system anytime using: dpkg -r leafpad **********************************************************************

The .deb will be saved in the directory where you extracted the source file.

Let us view the contents of the source directory:

ls

Sample output:

ABOUT-NLS config.sub intltool-extract missing aclocal.m4 configure intltool-extract.in mkinstalldirs AUTHORS configure.ac intltool-merge NEWS ChangeLog COPYING intltool-merge.in po compile data intltool-update README config.guess depcomp intltool-update.in src config.h description-pak leafpad_0.8.17-1_amd64.deb stamp-h1 config.h.in doc-pak Makefile config.log INSTALL Makefile.am config.status install-sh Makefile.in [email protected]:~/leafpad-0.8.17$

As you can see in the above output, the deb file has been successfully created and saved in the source directory itself.

You can also remove the installed deb package as shown below.

sudo dpkg -r leafpad

I have tested these guide with Leafpad and 7zip source files. It worked like a charm as I described above.

That's all for now. You know now how to create .deb file from its source file. I will be soon here with another interesting article. Until then, stay tuned with OSTechNix.

If you find this article useful, please share it on your social networks and support us.

Cheers!