5 hours ago
I would like to cleanup my local repository after each upgrade. When I add newer version of packages to pool and regenerate indexes with dpkg-scanpackages, program warns about old versions of packages (in case -m option is not passed):
pool
dpkg-scanpackages
-m
dpkg-scanpackages: warning: Package php5-common (filename pool/local/php5-common_5.3.6-13ubuntu3.3_amd64.deb) is repeat but newer version; dpkg-scanpackages: warning: used that one and ignored data from pool/local/php5-common_5.3.6-13ubuntu3.2_amd64.deb!
I'm looking for an automated way to safely remove old packages from disk. I'll call such a script safe if it do not delete an old package if a newer version is available and removing old version will cause an unmet dependency in local repository
18 hours ago
Have you tried apt-get clean and apt-get autoclean?
apt-get clean
apt-get autoclean
apt-get clean removes everything except lock files from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. Thus, if you need to reinstall a package APT should retrieve it again.
/var/cache/apt/archives/
/var/cache/apt/archives/partial/
apt-get autoclean removes only package files that can no longer be downloaded.
26 hours ago
For removing the obsolete packages, try
sudo apt-get autoremove