Debian Packaging: From Source to Repository

Building the First DEB Package

A practical Debian packaging course lesson covering building the first deb package.

Building the First DEB Package

We now have the basic Debian metadata and build instructions. It is time to put them together and create our first binary package.

In this lesson, we will check the build dependencies, build Syspeek, inspect the generated .deb, and install it locally for testing.

Learning Objectives

  • Check whether build dependencies are available.
  • Build a binary Debian package.
  • Understand the files generated by the build.
  • Inspect the package before installation.
  • Install and remove the package for a basic smoke test.

1. Review the Source Tree

Move into the project:

1
cd ~/packaging-lab/syspeek

Check that the essential files exist:

1
find . -maxdepth 3 -type f -not -path './.git/*' -print

You should have main.go, go.mod, and the files under debian/.

2. Install Build Dependencies

On a Debian build machine, install the declared build dependencies:

1
2
sudo apt update
sudo apt install build-essential devscripts debhelper golang-go

Then ask dpkg to check the package’s declared build dependencies:

1
dpkg-checkbuilddeps

If it reports missing dependencies, install them or build in the clean environment prepared earlier.

3. Build the Binary Package

Run:

1
dpkg-buildpackage -us -uc -b

The options mean:

  • -b: build binary packages only.
  • -us: do not sign the source package.
  • -uc: do not sign the .changes file.

These options are convenient for local testing. They are not a substitute for signing artifacts intended for a trusted release workflow.

The build output is normally placed in the parent directory.

4. Inspect the Build Artifacts

Move to the parent directory:

1
2
cd ..
ls -lh

You should find a package similar to:

1
syspeek_0.1.0-1_amd64.deb

You may also see .buildinfo and .changes files. These record information about the build and its generated artifacts.

5. Inspect the DEB Before Installing

Use:

1
2
dpkg-deb --info syspeek_*.deb
dpkg-deb --contents syspeek_*.deb

The contents should include:

1
./usr/bin/syspeek

Extract the package without installing it:

1
2
3
mkdir -p inspect
dpkg-deb --extract syspeek_*.deb inspect/
find inspect -type f -print

This is a useful way to catch incorrect installation paths before touching the system.

6. Install and Test

Install the package:

1
sudo apt install ./syspeek_*.deb

Run the installed command:

1
2
syspeek
syspeek --version

Check which package owns the executable:

1
dpkg -S /usr/bin/syspeek

7. Remove the Package

When you are finished testing:

1
sudo apt remove syspeek

To remove package configuration files as well, use:

1
sudo apt purge syspeek

For this simple command-line utility, there should be no persistent system configuration to preserve.

8. What We Learned

We built a Debian binary package from our Go source, inspected its metadata and file list, installed it, and verified that the command works.

A successful build is only the beginning. We still need to improve the packaging, validate dependencies, and test the package more thoroughly.

Exercises

  1. Inspect the .deb with dpkg-deb --info.
  2. Confirm that the executable is installed at /usr/bin/syspeek.
  3. Install the package on a test system or clean virtual machine.
  4. Compare the package version with the version printed by the application.

What’s Next?

Next, we will look more closely at packaging Go applications and how the Go build process fits into Debian’s packaging ecosystem.

Next: Packaging Go Applications