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

Enabling SSH on Raspberry Pi

By enabling SSH, you can access Raspberry Pi remotely. For security, you should change login password If you enable SSH. Here is the steps.

 

1. Enable SSH

1-1. Launch raspi-config

sudo raspi-config

1-2. Select “Interfacing Options”.

1-3. Select “SSH”, and “Yes”.

1-4. Then, exit raspi-config.

 

2. Change login password for user ‘pi’

2-1. Type the following command:

passwd

2-2. Enter the current password and new password. Then retype the new password.

Changing password for pi.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

 

3. Access from PC

3-1. Check IP address on Raspberry Pi.

ifconfig

Or, alternatively you may be able to figure out the IP address by using the following command on your PC.

arp -a

3-2. Then access from your PC like below (After @ sign will be your Raspberry Pi’s IP address).

ssh pi@192.168.0.1

 

Free up SD card space on Raspberry Pi


Raspberry Pi uses SD card for its main storage and you may run out of the free space as your project goes on. Here are some tips to free up your SD card space.

 

1. Uninstall unnecessary packages
Wolfram Engine: I’ve never used but it seems that Wolfram Engine is for mathematical/physics programming. If you don’t have any plans to use, you can get about 700 MB of free space by uninstalling it.

libreoffice: LibreOffice is a free and open source office suite that can be run on multiple OSes such as Linux, Windows, Mac, etc, which is very nice. However, I don’t think many people use LibreOffice on Raspberry Pi… If you remove this pre-installed office suite, you can get approx. 250 MB of free space.

scratch: Scratch is a free educational programming language. If you don’t need it, you can remove it and get approx. 90 MB space.

After you decide what packages to remove, you can remove it like below:

sudo apt-get purge wolfram-engine libreoffice* scratch -y

 

2. Clean up of apt cache
When installing and updating packages, cache date is kept and it’s getting bigger and bigger. To clear the cache, run the following command.

sudo apt-get clean

 

3. Remove unused dependencies
This command removes packages that are no longer used/required.

sudo apt-get autoremove -y

 

arecord creates hundreds of files

Update (Sep. 7th, 2017):
If you are using Raspbian Stretch, the pre-installed version is now v1.1.3 and this issue doesn’t occur any more!

Update (Dec. 9th, 2018):
If you are looking for steps to update ALSA on Raspbian Strech, please see this post.

 

If you find hundreds of files like below after the recording is done by arecord command, you may need to update your alsa-utils. According to here, this problem is introduced in alsa-utils 1.0.28, which is preinstalled in Raspbian Jessie, and can be fixed by either downgrading or upgrading alsa-utils version.

pi@raspberrypi:~/tmp $ ls -l
total 360
-rw-r--r-- 1 pi pi 319798 Jun 11 02:12 test-01.wav
-rw-r--r-- 1 pi pi     44 Jun 11 02:12 test-02.wav
-rw-r--r-- 1 pi pi     44 Jun 11 02:12 test-03.wav
-rw-r--r-- 1 pi pi     44 Jun 11 02:12 test-04.wav
-rw-r--r-- 1 pi pi     44 Jun 11 02:12 test-05.wav
...

 

Steps
Here are the steps to get the latest alsa-utils (1.1.4 as of 6/10/2017) from source.

1. Download and extract the source code.

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/

2. Install the dependencies.

sudo apt-get install libasound2-dev libncursesw5-dev -y

3. Configure, make and install.

./configure --disable-alsaconf --disable-bat --disable-xmlto --with-curses=ncursesw
make && sudo make install

4. Check the version:

arecord --version

If everything is fine, the result should be this:

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

5. Check if the problem is fixed.

$ arecord -D hw:1,0 -d 10 -f S16_LE -r 16000 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
$ ls -l
total 316
-rw-r--r-- 1 pi pi 320044 Jun 11 04:23 test.wav

 

Reference
– Multiple files created by arecord
http://stackoverflow.com/questions/24629915/multiple-files-created-by-arecord

 

Voice Recording on Raspberry Pi

 

The purpose of this post is to record audio (e.g. voice) on Raspberry Pi with a microphone. Raspberry Pi doesn’t have mic input by default, so USB microphone or USB soundcard + 3.5 mm jack mic is required.

 

Example Setup

 

Steps
1. Setting Up
1-1. Connect the speakers into 3.5 mm audio jack.
1-2. Connect the USB mic into USB ports.
1-3. Boot up Raspberry Pi Board. If it’s not set up yet, please refer this post.
1-4. Make sure the speaker is working. The command below can be used for speaker output test. To end the test, press Ctrl-C.

speaker-test -t wav

1-5. Check if the mic is recognized as a recording device by this command:

arecord -l

If everything is fine, the result should be something like below.

**** List of CAPTURE Hardware Devices ****
card 1: Device [USB PnP Sound Device], device 0: USB Audio [USB Audio]
 Subdevices: 1/1
 Subdevice #0: subdevice #0

This means the USB mic is on “card 1”, “device 0”. This card number and device number will be used when you record.

 

2. Recording
2-1. Now you can start recording by “arecord” command, for example:

arecord -D hw:1,0 -d 5 -f cd test.wav -c 1

-D option specifies recording device. Since the mic is on “card 1”, “device 0” (see step 1-4), the value is “hw:1,0” here. This command creates “test.wav” as a 5-second, CD-quality wave file. Since it’s a mono mic, specify “1” as the number of channels with “-c” option. You can find the details of the options here.

Note:
If you find hundreds of files (test-01.wav, test-02.wav…) after the recording is done, please refer this troubleshooting.

Note:
I found that a hissing noise is introduced when the file is played through 3.5 mm audio jack on Raspberry Pi board, even though the recording quality itself is ok. So you may want to use HDMI sound output or a USB sound card to play the audio file.

 

3. Testing

3-1. Play the recorded file and make sure the recording is done properly.

aplay test.wav

*If the playback volume is too low (or high), you can check and change it with “amixer” command.

Check the current volume.

amixer

Below is an output example. In this case, the current vol is 77%.

$ amixer 
Simple mixer control 'PCM',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback -10239 - 400
  Mono: Playback -2000 [77%] [-20.00dB] [on]

Set the vol to 100%.

amixer set PCM 100%

 

Reference
– USB Audio Cards with a Raspberry Pi
https://cdn-learn.adafruit.com/downloads/pdf/usb-audio-cards-with-a-raspberry-pi.pdf