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

sorush-r
  • 1,012

2 Answers2

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.

jokerdino
  • 41,320
LnxSlck
  • 12,256
  • How can I use autoclean for my repository? – sorush-r Mar 08 '12 at 05: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] (http://bleachbit.sourceforge.net/) 'BleachBit - cleanup tool for Ubuntu'

    – LnxSlck Mar 12 '12 at 14:11
  • 1
    I need to delete old packages from a local repository, say in /home/soroush/repo – sorush-r Mar 12 '12 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 '20 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 '20 at 15:03
2

For removing the obsolete packages, try

sudo apt-get autoremove
Ajit S
  • 201
  • 1
  • 3
  • 12