How To Create A .deb Package From Source & Install It Automatically

nolarut
  13 years ago
  33

I've found this method to work in most but NOT all cases, as sometimes additional depencies are required in order to build the package.

STEP 1:

The required packages are:

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

Or simply run the following command:

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

STEP 2:

Now to make the package:

The source tarball "transmission-1.76.tar.bz2" is used in this example (sub the .bz2 tarball of the source code for the app you are working on for this one)

$ tar xvjf transmission-1.76.tar.bz2 (alt:or you can extract the data from the tarball using the archive manager the right-click menu)

$ cd transmission-1.76 (alt: or you can highlight the newly created folder and from the right click menu choose "open terminal here")

$ ./configure && make && sudo checkinstall

This will create a .deb package for you and automatically install it on your system, which can then be easily removable via Synaptic (look in the local section), or via the Software Manager or by:

$ sudo dpkg -r

Then you can remove the source .tar.gz from your computer.

STEP 3:

You may have to:

sudo chown .deb in the source directory to make it yours and the move that to another location so that you have it on hand if you need it, then you can delete the source folder.

Note 1: Step #3 may not be required if you open the untarred folder with "open folder as root" from the right click menu (for Linux Mint users only).

Note 2: Though your newly installed app will appear in the Linux Mint Software Manager, reviews cannot be submitted for it.

P.S. Thanks go out to ckristi for helping out with this tuto smiley

Comments
Ravrao 6 years ago

Thank you,

works great.

Do we need to worry about any security or integrity of dep package.
can we safely use it in production environment.


gompie-nr3 9 years ago

Just compiled and upgraded libressl from source tarball. Worked flawlessly.

Thanks!!


jahid_0903014 9 years ago

great!


Tomas_IV 10 years ago

In case of problems in STEP 2, I would add one optional command to STEP 1:

$ sudo apt-get build-dep transmission

This should ensure specific prerequisities of the given software compilation are installed. It can help in many cases and it is fully automatic, but:
- Works only for software, which is in the repos (although different version), and on the assumption, that the version in repos does not have too much different prerequisities than the one compiled.
- Unfortunately for beginners, it is also needed to add source repositories (one-time work). This means to do this (replace 'gedit' with your favorite console or gui text editor, like nano, vi, bluefish, leafpad...):

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
$ sudo gedit /etc/apt/sources.list

There you see lines strating with "deb http://...." and possibly some lines starting with "deb-src http://" you have to make it so all the lines starting with deb... have a copy starting with deb-src... To do that, make identical copy of every line starting with 'deb', and then change the 'deb' to 'deb-src' in the second copy of the same line. If the created deb-src lines contain the [arch...] brackets, remove them. No need to do this all for the lines with security word in them. So for example my sources.list chaged from:

deb [arch=amd64,i386] http://linux-mint.froonix.org/ debian main upstream import
deb-src http://linux-mint.froonix.org/ debian main upstream import #Added by software-properties
deb http://tux.rainside.sk/mint/debian/latest testing main contrib non-free
deb [arch=amd64,i386] http://tux.rainside.sk/mint/debian/latest/security testing/updates main contrib non-free
deb http://tux.rainside.sk/mint/debian/latest/multimedia testing main non-free

to:

deb [arch=amd64,i386] http://linux-mint.froonix.org/ debian main upstream import
deb-src http://linux-mint.froonix.org/ debian main upstream import #Added by software-properties
deb http://tux.rainside.sk/mint/debian/latest testing main contrib non-free
deb-src http://tux.rainside.sk/mint/debian/latest testing main contrib non-free
deb [arch=amd64,i386] http://tux.rainside.sk/mint/debian/latest/security testing/updates main contrib non-free
deb http://tux.rainside.sk/mint/debian/latest/multimedia testing main non-free
deb-src http://tux.rainside.sk/mint/debian/latest/multimedia testing main non-free

NOTE: do *not* copy my sources.list, edit yours! I am using LinuxMint Debian 64bit and my sources are not compatible with LinuxMint 32bit versions or with Ubuntu based LinuxMint.

After editing the souces, run command:

$ sudo apt-get update

In case the output of this command indicates that something went wrong by editing the sources.list, you can revert back to original version by

$ sudo cp /etc/apt/sources.list.backup /etc/apt/sources.list
$ sudo apt-get update

and try again or just give up. ;-)


sdibaja 11 years ago

./configure: command not found
now what?


sdim 12 years ago

Great job.
Many thanks.


genothomas 12 years ago

Nice article :-)


MrDaleR 13 years ago

This is quite a bit more user friendly the building RPM's. Thanks for the info.


nolarut 13 years ago

Thank you ckristi for your input. I did leave out a few details and I will revise my original post. Thanks again for checking out my tuto.

-NR


ckristi 13 years ago

Very interesting article i must say. Please specify if after you run checkinstall the package will also be automatically installed, because you only mention that a package will be created and can be removed.
I presume it's auto-installed, but I never used checkinstall and I do not know it's default behavior. This may apply to newbies also. :-)

Also, in the first package list you forgot to mention the checkinstall package.