Installing software from source code with ‘checkinstall’

Even though your linux has a package management system, sometimes you may need to install a software from source code for some reason. And if you install the software by ‘make install’, you may have a little difficulty later on; You cannot use your package manager to uninstall it. This is where ‘checkinstall’ comes in. It generates a package from compiled files and installs it through your package manager, so that when you need to uninstall it, you can do that easily with your package manager.

Below is an example steps that shows how to use ‘checkinstall. In this example, I’m going to install alsa-utils 1.1.4 on Raspberry Pi (Raspbian Jessie).

 

Steps
1. Install ‘checkinstall’ It’s not installed by default. So, let’s install it first.

sudo apt-get install checkinstall -y

2. Check the current alsa-utils version.

pi@raspberrypi:~ $ arecord --version
arecord: version 1.0.28 by Jaroslav Kysela <perex@perex.cz>

3. You may need to install dependencies.

sudo apt-get install libasound2-dev libncursesw5-dev

4. Download the source.

wget ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.1.4.tar.bz2
tar xvjf alsa-utils-1.1.4.tar.bz2
cd alsa-utils-1.1.4/

5. Compile the source code as usual.

./configure --disable-alsaconf --disable-bat --disable-xmlto --with-curses=ncursesw
make -j4

6. To install, type “sudo checkinstall” instead of ‘sudo make install’.

sudo checkinstall

Then, ‘checkinstall’ will create a .deb file (Debian package) and install it. During the process, you will be asked a few questions about the package. Unless you are planning to distribute it, you can use the default answers.

pi@raspberrypi:~/src/alsa/alsa-utils-1.1.4 $ sudo checkinstall

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

Preparing package documentation...OK

Please write a description for the package.
End your description with an empty line or EOF.
>> alsa-utils package from source code
>> 

*****************************************
**** Debian package creation selected ***
*****************************************

This package will be built according to these values: 

0 -  Maintainer: [ root@raspberrypi ]
1 -  Summary: [ alsa-utils package from source code ]
2 -  Name:    [ alsa-utils ]
3 -  Version: [ 1.1.4 ]
4 -  Release: [ 1 ]
5 -  License: [ GPL ]
6 -  Group:   [ checkinstall ]
7 -  Architecture: [ armhf ]
8 -  Source location: [ alsa-utils-1.1.4 ]
9 -  Alternate source location: [  ]
10 - Requires: [  ]
11 - Provides: [ alsa-utils ]
12 - Conflicts: [  ]
13 - Replaces: [  ]

Enter a number to change any of them or press ENTER to continue: 

Installing with make install...

<snip>

**********************************************************************

 Done. The new package has been installed and saved to

 /home/pi/src/alsa/alsa-utils-1.1.4/alsa-utils_1.1.4-1_armhf.deb

 You can remove it from your system anytime using: 

      dpkg -r alsa-utils

**********************************************************************

After the installation, it’ll tell you where the package file is saved and how to uninstall the package.

 

7. Let’s check the updated version to confirm the installation.

pi@raspberrypi:~/src/alsa/alsa-utils-1.1.4 $ arecord --version
arecord: version 1.1.4 by Jaroslav Kysela <perex@perex.cz>

OK, it’s updated from 1.0.28 (see step2) to 1.1.4 as expected.

 

Package Information
You can also check the package information with ‘dpkg -l’ command. The package description you entered during the installation will be shown here.

pi@raspberrypi:~/src/alsa/alsa-utils-1.1.4 $ dpkg -l|grep alsa
ii  alsa-base                             1.0.27+1                                  all          dummy package to ease purging of obsolete conffiles
ii  alsa-utils                            1.1.4-1                                   armhf        alsa-utils package from source code
ii  gstreamer0.10-alsa:armhf              0.10.36-2                                 armhf        GStreamer plugin for ALSA
ii  gstreamer1.0-alsa:armhf               1.4.4-2+deb8u1                            armhf        GStreamer plugin for ALSA

 

To create a package without installation
In case you just need to create a package but you don’t need to install it, type:

sudo checkinstall --install=no

 

To uninstall the package

dpkg -r alsa-utils

 

To install the package to other machine
in case you need to install the package to other machine, use ‘dpkg -i’ command with the file name.

sudo dpkg -i alsa-utils_1.1.4-1_armhf.deb

 

Troubleshoot

I got an error when I was trying to install bluez with checkinstall.

libtool: install: /usr/bin/install -c tools/btattach /usr/bin/btattach
 /bin/mkdir -p '/usr/libexec/bluetooth'
/bin/mkdir: cannot create directory ‘/usr/libexec’: No such file or directory
Makefile:3520: recipe for target 'install-libexecPROGRAMS' failed
make[2]: *** [install-libexecPROGRAMS] Error 1
Makefile:8902: recipe for target 'install-am' failed
make[1]: *** [install-am] Error 2
Makefile:8896: recipe for target 'install' failed
make: *** [install] Error 2

****  Installation failed. Aborting package creation.

Cleaning up...OK

Bye.

There are bug reports for that and found a workaround. This worked for me.

sudo checkinstall --fstrans=no

https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/307799
https://bugs.launchpad.net/ubuntu/+source/checkinstall/+bug/78455