Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question

4 Answers 4

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.

share|improve this answer
How can I use autoclean for my repository? –  sorush-r Mar 8 '12 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 '12 at 14:11
I need to delete old packages from a local repository, say in /home/soroush/repo –  sorush-r Mar 12 '12 at 18:03

He asked for an equivalent of "repomanage --keep" under yum based repos. This tools keeps the last n'th package in the local repository.

  • This has nothing to do with the database handeling the installed package
  • This has nothing to do with mirroring a .deb repo either.
  • This is about cleaning your own made local repository.

And I'm searching for the same tool.

A tool that scans a deb local repo (a directory) and removes old versions of each packages keeping the last n'th versions.

for example, if you have:





repomanage --keep 2 would remove foo_1.1.deb and foo_1.2.deb

share|improve this answer

You are not saying what you used to make your local repository in the first place. I would recommend that you use apt-mirror

This can mirror whole Ubuntu distributions or just ppa's if you want.

It keeps the repo up to date, so you do not have to worry about deleting old packages manually, it does this for you.

You basically just need to run one command every time to update.

share|improve this answer

For removing the obsolete packages, try

sudo apt-get autoremove
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.