This tutorial provides the exact steps for creating a deb package on Raspberry Pi for a simple application written in the C programming language with autotools. The described procedure has been tested on Raspberry Pi 3 using Raspbian Stretch from November 2017.
- Install the following tools:
sudo apt-get update
sudo apt-get install devscripts build-essential lintian
Create a directory for the deb package and enter it:
mkdir ~/hellodeb
cd ~/hellodeb
Download the source code of the application as an archive and unzip it:
wget https://github.com/leon-anavi/hello-world/archive/master.zip
unzip master.zip
Rename the directory to a name that matches the format package-version:
mv hello-world-master helloworld-0.0.1
Enter the directory with the source code and create directory debian in it:
cd helloworld-0.0.1
mkdir debian
Run the following command and follow the on screen instructions to create a changelog:
dch -i --create
In the change log is mandatory to replace PACKAGE with helloworld, VERSION with 0.0.1 UNRELEASED with unstable.
Create a copyright file which can be blank but must exists because it is required by lintian:
touch debian/copyright
Define debhelper compatibility level in file debian/compat:
echo 10 > debian/compat
Create file debian/control with the following content:
Source: helloworld
Maintainer: Leon Anavi
Build-Depends: debhelper (>= 10.2.5)
Standards-Version: 3.9.8
Section: utils
Package: helloworld
Priority: extra
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: a simple helloworld package
Prints "Hello, World" and exit.
Create file debian/rules with the following content (use TAB instead of spaces):
#!/usr/bin/make -f
%:
dh $@
override_dh_usrlocal:
override_dh_auto_install:
install -D -m 0755 src/hello $$(pwd)/debian/helloworld/usr/local/bin/hello
configure:
dh_autoreconf
./configure ...
clean:
dh_autoreconf_clean
dh_clean
Make the deb package using debuild:
debuild -us -uc
Verify that the deb package has been created successfully in the parent directory and install it for a test with dpkg:
cd ..
sudo dpkg -i helloworld_0.0.1_armhf.deb
If there are no issues, after installing the package with dpkg, you can run the application. Just type hello as in the example below:
pi@hassbian:~/hellodeb $ hello
Hello, World!
This article is specially for an application that uses autotools. If you want to adapt it for a straight-forward Makefile then remove the configure and clean sections from debian/rules. Over the time, with the new releases of Raspbian, some of the steps might change therefore please contact me if you notice room for improvement of the tutorial.
|