Ugly debian packaging: Just put my binary in a .deb, dammit

I recently wanted to put some shared libraries and executables in .deb files, so end-users could just apt install ./the-package.deb. This task is straightforward but it’s surprisingly hard to find instructions. I found Vincent Bernat’s Pragmatic Debian packaging quite useful, and I recommend you go read that first. However, his methods are still too reasonable and maintainable for me. I just want to put my binary in a .deb, dammit.

Assume we work at a company called CoolSoft. CoolSoft has a program called sayhi that says hi. It can be a binary, shell script, whatever.

$ ./sayhi

We would like to install it into /usr/local/bin. First create a script called

set -euo pipefail


tmpdir=$(mktemp -d)
mkdir -p $pkgdir $pkgdir/DEBIAN 

# this is the part where it installs your files
install -Dm 755 sayhi $pkgdir/usr/local/bin/sayhi

cat <<EOF >$pkgdir/DEBIAN/control
Package: $pkgname
Version: $version
Architecture: $arch
Maintainer: CoolSoft (
Description: It says hi

dpkg -b $pkgdir ./${pkgname}_${version}_${arch}.deb
rm -rf $tmpdir

Then just run it and install the package.

$ bash
dpkg-deb: building package 'sayhi' in './sayhi_0.0.1_all.deb'.
$ sudo apt install ./sayhi_0.0.1_all.deb
$ sayhi

Architectures: My sayhi is actually a shell script, so I chose arch=all above. If yours is a binary, set it to amd64, arm64, or another Debian architecture.

More files: See above where it says # this is the part where it installs your files? Well, just keep installing your other files. 755 for executables, 644 otherwise. -D creates leading folders automatically.

# this is the part where it installs your files
install -Dm 755 sayhi $pkgdir/usr/local/bin/sayhi
install -Dm 644 $pkgdir/usr/local/lib/

← back