Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

This question already has an answer here:

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

marked as duplicate by Fabby, David Foerster, Eric Carvalho, Elder Geek, muru Mar 12 at 17:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

This near-duplicate question has the right answer: How to delete old versions of same packages from a Local Repository? – Colin Pickard Mar 10 at 15:00

3 Answers 3

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

For removing the obsolete packages, try

sudo apt-get autoremove
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

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