8

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):

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

1

2 Answers 2

5

Have you tried apt-get clean and 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.

apt-get autoclean removes only package files that can no longer be downloaded.

5
  • How can I use autoclean for my repository?
    – sorush-r
    Mar 8, 2012 at 5:46
  • Running the command doesn't work? Have you tried bleachbit ? apt-get install bleachbit. This is a cleanup utility that erases various caches, delete cookies, clears internet history, removes unused localisations, shreds logs, and deletes temporary files. It doesn't remove anything you can't live without, so it's safe to use and all it does is clear out logs and caches. [link] (bleachbit.sourceforge.net) 'BleachBit - cleanup tool for Ubuntu'
    – LnxSlck
    Mar 12, 2012 at 14:11
  • 1
    I need to delete old packages from a local repository, say in /home/soroush/repo
    – sorush-r
    Mar 12, 2012 at 18:03
  • 1
    How is this the most upvoted answer? It's not even addressing the question asked, which is about maintaining a local repository (not about apt caches).
    – swelljoe
    Jul 20, 2020 at 14:50
  • @swelljoe This question has already accepted answers, check the link: How to delete old versions of same packages from a Local Repository?
    – LnxSlck
    Jul 21, 2020 at 15:03
2

For removing the obsolete packages, try

sudo apt-get autoremove

Not the answer you're looking for? Browse other questions tagged .