Maintaining a production server on Debian Stable while needing specific newer packages is a common scenario. The challenge lies in avoiding full system upgrades while satisfying dependencies for particular applications.
The proper way involves creating an /etc/apt/preferences
file to pin packages. Here's a basic example:
Package: * Pin: release a=stable Pin-Priority: 700 Package: * Pin: release a=testing Pin-Priority: 50
Add the testing repository while keeping stable as primary:
deb http://deb.debian.org/debian stable main deb http://deb.debian.org/debian testing main
For installing package newpackage
from testing while keeping dependencies resolved from stable:
apt-get update apt-get -t testing install newpackage
When you encounter dependency problems, try:
apt-get -t testing install newpackage --no-install-recommends
Or for more control:
aptitude install newpackage/testing
Here's how to get a newer Python version while staying on Stable:
echo "Package: python3*" >> /etc/apt/preferences.d/python.pref echo "Pin: release a=testing" >> /etc/apt/preferences.d/python.pref echo "Pin-Priority: 500" >> /etc/apt/preferences.d/python.pref apt-get update apt-get -t testing install python3.9
Remember to:
- Regularly check for updates to pinned packages
- Monitor for security updates in testing
- Consider building from source if the package has complex dependencies
For many cases, using backports is safer:
deb http://deb.debian.org/debian buster-backports main apt-get install -t buster-backports package-name
Many Debian Stable users occasionally need newer versions of certain packages while maintaining system stability. This often happens when:
- A required feature exists only in Testing/Unstable
- Security patches haven't been backported to Stable
- Newer dependencies are needed for development
The safest approach is using APT pinning. Create /etc/apt/preferences
:
Package: * Pin: release a=stable Pin-Priority: 900 Package: [specific-package-name] Pin: release a=testing Pin-Priority: 500
Then add Testing to sources.list:
deb http://deb.debian.org/debian testing main deb-src http://deb.debian.org/debian testing main
For one-time installations:
apt-get -t testing install [package-name]
This avoids permanent configuration changes.
When dependencies become problematic:
apt-get download [package-name] -t testing dpkg -i --ignore-depends=[dependency] [package-name].deb
When Stable had Python 3.7 but Testing offered 3.9:
# In /etc/apt/preferences Package: python3* Pin: release a=testing Pin-Priority: 500 # Then run: apt-get update apt-get install python3 -t testing
- Always check package dependencies with
apt-cache depends
- Consider using containers for risky packages
- Document all manual overrides for future maintenance
For many packages, the official backports may suffice:
deb http://deb.debian.org/debian [release]-backports main