Table of Contents
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.gzor.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
Key Files
debian/control— package metadata, dependenciesdebian/rules— build rules (often justdh $@)debian/changelog— version history (mandatory format)debian/copyright— license and copyright infodebian/install— files to installdebian/systemd/— systemd units
Tips
- Always check copyright and licensing
- Test package install/removal thoroughly
- Use
debhelper(dh) to simplifydebian/rules - Never hardcode paths; use
/usr/bin, not/opt/bin - Clean source tree:
debcleanordebuild clean - Linting:
lintian package.debchecks for common issues
Building quality packages requires testing and knowledge of Debian conventions.
