When managing Debian Lenny systems, many administrators use backports to access newer package versions. The common approach:
aptitude search ~i~Alenny-backports
has a critical limitation - it shows all installed packages that exist in backports, regardless of whether they're actually installed from backports. This creates noise when you need precise inventory.
Use this command instead:
aptitude search '?narrow(?installed,?origin(backports.debian.org))'
This properly filters to show only packages where:
- The package is currently installed
- The installed version specifically originates from backports.debian.org
For systems with apt-show-versions installed:
apt-show-versions | grep 'backports'
To check where a specific package came from:
apt-cache policy package-name | grep backports
Example output showing backports origin:
500 http://backports.debian.org/debian-backports lenny-backports/main Packages
release v=5.0,o=Debian Backports,a=oldstable-backports,n=lenny-backports,l=Debian Backports,c=main
Create a maintenance script:
#!/bin/bash
BACKPORTS_LIST="/var/backups/backports_packages_$(date +%Y%m%d).txt"
aptitude search '?narrow(?installed,?origin(backports.debian.org))' > $BACKPORTS_LIST
echo "Backports inventory saved to $BACKPORTS_LIST"
Accurate backports tracking helps when:
- Preparing system upgrades
- Troubleshooting compatibility issues
- Maintaining security updates
- Documenting system configuration
When managing Debian Lenny systems with backports, administrators often need to distinguish between packages installed from the main repository versus those pulled from backports. The standard aptitude search ~i~Alenny-backports
approach has limitations because it shows all installed packages that have a backported version available, regardless of installation source.
To accurately identify packages installed specifically from lenny-backports, we need to examine the actual installation source recorded in dpkg's metadata:
zgrep -hPo 'Package: \K.*|Version: \K.*' /var/lib/apt/lists/*lenny-backports*_Packages |
awk 'NR%2==1 {pkg=$0; next} {print pkg "=" $0}' > backports-available.txt
Then cross-reference with installed packages:
dpkg-query -W -f='${Package}=${Version}\n' |
grep -Fxf backports-available.txt
For systems with aptitude installed, this condensed command provides similar results:
aptitude search '?narrow(?installed, ?origin(lenny-backports))' --disable-columns -F '%p'
For absolute certainty about installation sources, examine individual package metadata:
apt-cache policy package-name | grep -A1 'Installed:'
Example output showing backport installation:
Installed: 1.2.3~bpo50+1
Candidate: 1.2.3~bpo50+1
Version table:
*** 1.2.3~bpo50+1 0
500 http://backports.debian.org lenny-backports/main Packages
100 /var/lib/dpkg/status
For regular maintenance, save this bash script as list-backports.sh
:
#!/bin/bash
# List packages installed from lenny-backports
BACKPORTS_URI=$(apt-cache policy | grep -Po 'lenny-backports.*(?=/dists/)')
zgrep -hPo 'Package: \K.*|Version: \K.*' \
/var/lib/apt/lists/*${BACKPORTS_URI}*_Packages | \
awk 'NR%2==1 {pkg=$0; next} {print pkg "=" $0}' | \
while read -r pkgver; do
pkg=${pkgver%=*}
ver=${pkgver#*=}
installed_ver=$(dpkg-query -W -f='${Version}' "$pkg" 2>/dev/null)
[[ "$installed_ver" == "$ver" ]] && echo "$pkg ($ver)"
done
When dealing with mixed installation sources (some packages from backports, others from main), this extended command helps identify the relationship:
aptitude search '?narrow(?installed, ?version(CURRENTBACKPORT))' \
--display-format '%p %V -> %v'