When examining Debian package versions through dpkg -l
, you'll notice they follow a specific format:
[epoch:]upstream_version-[debian_revision]
Let's break down each component with examples from your package list:
The epoch is an optional numeric field preceding the version with a colon (e.g., 2:7.3.429
). It's used when:
- Upstream version numbering changes radically (like switching from date-based to semantic versioning)
- Package maintainers need to force an upgrade despite numerically lower version
This comes directly from the original software developers. Common patterns include:
- Semantic versioning (1.2.3)
- Date-based versions (20201231)
- Alpha/beta markers (1.0alpha1)
The part after the hyphen indicates Debian/Ubuntu modifications:
-1
: First Debian packaging-ubuntu2
: Second Ubuntu-specific modification.1
: First point release (usually security fixes)
Character | Meaning | Example |
---|---|---|
~ | Pre-release marker (sorts before empty string) | 1.5.0-1~webupd8 |
+ | Post-release additions | 5.1.1alpha+20110809 |
- | Separates upstream version from Debian revision | 7.3.429-2ubuntu2.1 |
: | Separates epoch from version | 2:7.3.429 |
- ubuntuX: Ubuntu-specific patches (X=revision number)
- dfsg: Indicates Debian Free Software Guidelines compliant source (non-free files removed)
- buildX: Build number for the same source version
- alpha/beta/rc: Development release status markers
Debian uses the dpkg --compare-versions
tool which follows strict rules:
- Compare epochs (higher always wins)
- Compare upstream versions character by character
- Compare debian revisions
Example comparison script:
#!/bin/bash
dpkg --compare-versions "1:2.3.4-5" gt "2.3.4-6" && echo "Newer" || echo "Older"
1:1.2.3.4.dfsg-3ubuntu4
(zlib1g): Epoch=1, upstream=1.2.3.4.dfsg, debian_revision=3ubuntu40.52.11-2ubuntu10
(whiptail): No epoch, upstream=0.52.11, debian_revision=2ubuntu101.5.0-1~webupd8~precise
(wimtools): Upstream=1.5.0, debian_revision=1~webupd8~precise
You can extract version components with these commands:
# Get full version
dpkg-query -W -f='${Version}\n' vim
# Get upstream version only
dpkg-query -W -f='${Version}\n' vim | cut -d- -f1
# Get Debian revision
dpkg-query -W -f='${Version}\n' vim | cut -d- -f2-
- Debian Policy Manual: Version Format
- man dpkg(1) - search for "Version numbering"
- man deb-version(7) - detailed version comparison rules
Debian package versions follow a strict format that may appear complex at first glance. A typical version string looks like:
[epoch:]upstream_version-debian_revision
The optional epoch is a single number before the colon. It's used when version numbering schemes change dramatically:
# Compare versions with dpkg
dpkg --compare-versions "1:2.0" gt "2.1" && echo "Newer" || echo "Older"
# Example showing epoch comparison
echo "Package A: 2:1.0 vs Package B: 1:2.0"
dpkg --compare-versions "2:1.0" gt "1:2.0" && echo "A is newer" || echo "B is newer"
The main version number assigned by the original software authors. This may include:
- alpha/beta/rc tags (development versions)
- dfsg indicating Debian Free Software Guidelines compliance
- build numbers or dates (20110809)
Example of version extraction:
# Extract upstream version from full version string
full_version="2:7.3.429-2ubuntu2.1"
upstream_version=$(echo $full_version | cut -d- -f1 | cut -d: -f2)
echo $upstream_version # Outputs: 7.3.429
This portion reflects Debian/Ubuntu-specific modifications:
- Initial Debian package version (-2)
- Ubuntu-specific changes (ubuntu2.1)
- Security updates (.1 at the end)
Debian uses specific rules for comparing versions:
# Compare versions with various operators
dpkg --compare-versions "1.2.3" lt "1.2.4" # less than
dpkg --compare-versions "2.0~beta" lt "2.0" # tilde sorts before release
dpkg --compare-versions "1.0+dfsg" gt "1.0" # plus sorts after
Character | Purpose | Sorting Order |
---|---|---|
~ | Pre-release versions | Before empty string |
+ | Post-release additions | After empty string |
- | Separates upstream and Debian versions | N/A |
Let's analyze real-world package versions:
# Analyzing wget version
version="1.13.4-2ubuntu1"
echo "Upstream: ${version%-*}" # 1.13.4
echo "Debian: ${version#*-}" # 2ubuntu1
# Handling xz-utils with alpha tag
version="5.1.1alpha+20110809-3"
if [[ $version == *alpha* ]]; then
echo "This is an alpha release"
fi
For complete details, consult:
- Debian Policy Manual - Version Format (Section 5.6.12)
- man 5 deb-version
- Ubuntu Packaging Guide