There are many situations where you need to build an application from source code and install it. The typical method to install it is:
$ sudo make install
One of the major problems with installing like this is that uninstalling is not possible. You will need to know what files were installed to what destination directories and manually remove those files!
The CheckInstall application can be used to convert such an installation into a package, which can be installed and uninstalled easily using your distribution’s package tools.
- Install checkinstall: First, we have to install this application:
$ sudo apt install checkinstall
- Creating a package file: Turning the above
make installinto the installation of a package is as easy as:
$ sudo checkinstall
This will take you through some prompts where you provide the meta information for the package. You can choose to just press Enter through these sections. After that, a package file is created and is also installed for you. For example, a
foo_amd64.deb package was created for me and it was installed.
- Package name: Note that the directory name from where you are running this becomes the default package name. If you do not want that, specify a package name:
$ sudo checkinstall --pkgname foobar_by_joe
- Make options: Checkinstall runs
make installby default. If you want other options to be used, that can be accommodated too.
For example, I noticed that checkinstall runs make serially, even though I have specified
-j in my
MAKEFLAGS. So, to explicitly tell checkinstall to build in parallel:
$ sudo checkinstall make -j install
Another example, for another project the install command was
make install_foobar. To use that with checkinstall:
$ sudo checkinstall make install_foobar
- Install your package: I can now use the
.debfile created by checkinstall to install on other computers or pass it to other people on the team:
$ sudo gdebi foo_amd64.deb
- Uninstalling is as easy as:
$ sudo apt remove foo
Tried with: CheckInstall 1.6.2 and Ubuntu 16.04