Site Tools


wiki:debian-building-packages

Debian Building Packages

Debian packages (.deb) are the standard distribution format. Building custom packages requires source and metadata.

Package Components

A source package consists of three files:

  • .orig.tar.gz — original upstream source
  • .debian.tar.gz or .diff.gz — Debian-specific patches and metadata
  • .dsc — metadata file (dependencies, checksums)

Example:

hello_2.10-1.orig.tar.gz
hello_2.10-1.debian.tar.gz
hello_2.10-1.dsc

Extracting Source

Extract source package:

dpkg-source -x hello_2.10-1.dsc
cd hello_2.10-1

This unpacks upstream source and applies Debian patches.

Building

Install build dependencies:

cd hello_2.10-1
sudo apt build-dep .

Build package:

debuild              # builds, signs, creates .deb
debuild -us -uc      # builds, no GPG signing
dpkg-buildpackage    # lower-level alternative

Output: .deb file in parent directory.

Installing Custom Package

Install locally-built package:

sudo dpkg -i hello_2.10-1_amd64.deb
sudo apt install ./hello_2.10-1_amd64.deb     # also resolves dependencies

Creating From Scratch

Create simple debian/ directory structure:

source/
├── debian/
│   ├── control        # package metadata
│   ├── rules          # build instructions
│   ├── changelog      # version history
│   └── copyright      # license info
└── main.c

Minimal debian/control:

Source: myapp
Maintainer: Your Name <[email protected]>
Section: utils
Priority: optional
Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.6.0

Package: myapp
Architecture: any
Depends: ${shlibs:Depends}
Description: My Application
 A brief description.

Minimal debian/rules:

#!/usr/bin/make -f
%:
	dh $@

Then build:

debuild -us -uc

Contributing to Debian

To formally contribute: 1. Check existing packages 2. Understand Debian Policy 3. Create quality package 4. Find sponsor (established developer) 5. Submit patch or new package 6. Go through review process

See Debian New Maintainers Guide.

Key Files

  • debian/control — package metadata, dependencies
  • debian/rules — build rules (often just dh $@)
  • debian/changelog — version history (mandatory format)
  • debian/copyright — license and copyright info
  • debian/install — files to install
  • debian/systemd/ — systemd units

Tips

  • Always check copyright and licensing
  • Test package install/removal thoroughly
  • Use debhelper (dh) to simplify debian/rules
  • Never hardcode paths; use /usr/bin, not /opt/bin
  • Clean source tree: debclean or debuild clean
  • Linting: lintian package.deb checks for common issues

Building quality packages requires testing and knowledge of Debian conventions.

wiki/debian-building-packages.md · Last modified: by 127.0.0.1