| name | debian-packaging |
| description | Expert Debian package builder specializing in git-buildpackage, debhelper, and Debian Policy compliance. Use for .deb packaging, debian/ directory work, dpkg operations, and package maintenance. Triggers on "Debian", ".deb", "dpkg", "debhelper", "gbp", "pbuilder", "lintian", "dch". |
Modern Debian packaging expert focused on git-buildpackage workflows, clean builds (sbuild/pbuilder), quality assurance (lintian/piuparts), and patch management (quilt/gbp-pq). Follows current best practices with debhelper 13+ and Debian Policy compliance.
Core Principles
- Version control first - Always use git-buildpackage for reproducible builds
- Policy compliance - Follow Debian Policy strictly
- Clean builds - Test in isolated chroots (sbuild/pbuilder), never build as root
- Quality gates - Run lintian (no errors), piuparts, and autopkgtest before upload
- Patch documentation - All patches need DEP-3 headers explaining what/why
- Pristine upstream - Keep upstream sources unmodified, use debian/patches/ for changes
Git-Buildpackage Configuration
~/.gbp.conf (essential setup):
[DEFAULT]
pristine-tar = True
pristine-tar-commit = True
upstream-branch = upstream/latest
debian-branch = debian/latest
pbuilder = True
sign-tags = True
keyid = YOUR_GPG_KEY_ID
debian/gbp.conf (project-specific):
[DEFAULT]
upstream-tag = v%(version)s
Importing Upstream Sources
From tarballs:
git init --initial-branch=debian/latest mypackage.git
cd mypackage.git
gbp import-orig /path/to/mypackage-1.0.tar.gz
From git repository:
git clone https://upstream.example.com/mypackage.git
cd mypackage.git
git branch -m debian/latest
Update to new version:
gbp import-orig --uscan
gbp import-orig ../mypackage-1.1.tar.gz
Branch Structure (DEP-14)
- debian/latest - Main packaging branch
- upstream/latest - Upstream source history
- pristine-tar - Binary delta for exact tarball reproduction
- patch-queue/debian/latest - Temporary branch for patch development (gbp pq)
Essential debian/ Files
debian/control - Package metadata
- Source section: name, maintainer, build dependencies, standards version
- Binary section(s): name, dependencies, description, architecture
- Use
${shlibs:Depends} and ${misc:Depends} for automatic dependencies
debian/rules - Build instructions (executable)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh $@
debian/changelog - Version history (RFC 5322 format)
- Managed with
dch command
- Version format:
epoch:upstream-debian (e.g., 1.2.3-1)
- Generate from git:
gbp dch --auto
debian/copyright - License information (DEP-5 machine-readable format)
- Use copyright review tools:
licensecheck -r .
debian/source/format - Source package format
3.0 (quilt) for non-native packages (has upstream + Debian changes)
3.0 (native) for Debian-only packages (rare)
debian/watch - Upstream version tracking
Common debian/ Files
- debian/compat or debhelper-compat - Debhelper compatibility level (use 13+)
- debian/install - Files to install when dh_auto_install is insufficient
- debian/patches/ - Quilt patch series with DEP-3 headers
- debian/tests/ - autopkgtest integration tests
Clean Build Setup
sbuild (recommended, used by official buildds):
sudo apt install sbuild
sudo sbuild-adduser $LOGNAME
sudo sbuild-createchroot --include=eatmydata,ccache,gnupg unstable \
/srv/chroot/unstable-amd64-sbuild http://deb.debian.org/debian
sbuild -A -d unstable
pbuilder (alternative):
sudo apt install pbuilder
sudo pbuilder create --distribution unstable
gbp buildpackage
Git-Buildpackage Workflow
Daily development:
git add .
git commit -m "Description of changes"
dch -i
gbp buildpackage --git-pbuilder
Managing patches (quilt):
quilt push -a
quilt new fix-something.patch
quilt edit file.c
quilt refresh
quilt header -e
quilt pop -a
git add debian/patches/
git commit
Managing patches (gbp pq):
gbp pq import
git commit -a -m "Fix something"
gbp pq export
git add debian/patches/
git commit
DEP-3 Patch Headers
Required in all patches:
Description: One-line summary
Longer explanation of what this patch does and why.
Author: Your Name <you@example.com>
Origin: vendor|upstream|other
Bug: https://bugs.upstream.example.com/123
Bug-Debian: https://bugs.debian.org/123456
Forwarded: yes|no|not-needed|https://url
Last-Update: 2025-01-15
---
Quality Assurance
lintian - Policy compliance checker:
lintian -EvIL +pedantic ../mypackage_*.changes
piuparts - Install/remove testing:
sudo piuparts --log-level info \
--basetgz /var/cache/pbuilder/base.tgz \
../mypackage_*.deb
autopkgtest - Integration testing:
autopkgtest ../mypackage_*.changes -- unshare
wrap-and-sort - Consistent formatting:
wrap-and-sort -ast
Common Workflows
New package from scratch
git init --initial-branch=debian/latest mypackage.git
cd mypackage.git
gbp import-orig /path/to/mypackage-1.0.tar.gz
git archive HEAD --prefix=mypackage-1.0/ -o ../mypackage_1.0.orig.tar.gz
tar xzf ../mypackage_1.0.orig.tar.gz && cd mypackage-1.0
debmake
mv debian/* ../debian/
cd .. && rm -rf mypackage-1.0
gbp buildpackage
lintian -EvIL +pedantic ../mypackage_*.changes
Update to new upstream version
gbp import-orig --uscan
gbp import-orig ../mypackage-1.1.tar.gz
dch -v 1.1-1 "New upstream release"
gbp pq rebase
gbp buildpackage
Fix bug with patch
quilt new fix-bug-123.patch
quilt edit src/file.c
quilt refresh
quilt header -e
quilt pop -a
gbp pq import
gbp pq export
dch -i
gbp buildpackage
Prepare for upload
dch -r
git commit debian/changelog -m "Release X.Y-Z"
gbp buildpackage --git-tag
git push --all --follow-tags
Version Numbering
Format: [epoch:]upstream-debian
Examples:
1.2.3-1 - First Debian package of upstream 1.2.3
1.2.3-2 - Second Debian revision (bug fixes, no upstream changes)
1:1.0-1 - With epoch (when upstream versioning changed)
1.2.3-1~bpo12+1 - Backport to bookworm
1.2.3-1+deb12u1 - Security update for stable
Native packages:
- Version:
1.2.3 (no Debian revision)
- Only for Debian-specific tools
Build Commands
gbp buildpackage
gbp buildpackage --git-dist=bookworm --git-arch=arm64
gbp buildpackage --git-ignore-new
gbp buildpackage --git-builder='dpkg-buildpackage -S'
Anti-patterns
Never do:
- Build as root or outside clean chroot
- Skip lintian checks or ignore errors
- Edit upstream source without documenting in debian/patches/
- Commit with UNRELEASED in changelog before tagging
- Use debhelper compat < 13
- Mix unrelated changes in single changelog entry
- Hardcode paths or architecture names in debian/rules
- Modify files without quilt/gbp-pq tracking
- Push to Salsa with failing tests
- Upload without testing in clean environment
Always do:
- Run lintian, piuparts before every upload
- Document patches with complete DEP-3 headers
- Use
${shlibs:Depends} and ${misc:Depends} in debian/control
- Test package install/remove in clean chroot
- Follow DEP-14 branch naming (upstream/latest, debian/latest)
- Use pristine-tar for reproducibility
- Keep git history clean and commits atomic
Troubleshooting
lintian errors:
- Read error description carefully
- Check Debian Policy Manual section referenced
- Look at well-maintained similar packages for examples
Build failures:
- Check build log in ../build-area/ or /var/cache/pbuilder/result/
- Missing build-deps: add to debian/control Build-Depends
- Test with
DH_VERBOSE=1 for detailed output
Patch conflicts:
gbp pq import
gbp pq rebase
gbp pq export
Clean source tree:
debian/rules clean
quilt pop -a
git clean -dfx
Resources
Environment Setup
~/.bashrc additions:
export DEBEMAIL="your@email.domain"
export DEBFULLNAME="Your Name"
alias lintian='lintian -iIEcv --pedantic --color auto'
Remember: Debian packaging values correctness over convenience. Every shortcut creates technical debt that blocks package acceptance. When in doubt, check Policy and study well-maintained packages.