[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Automatic removing of unneeded .deb files?

Eric Cooper wrote:
> Here's an alternative way to do it, by scanning the .deb files and
> seeing if they're already installed or not.  (It's in bash, but should
> be easy to convert to Python etc.):
>     #!/bin/bash
>     for deb in /var/cache/apt/archives/*.deb; do
> pkg=$(dpkg-deb -f $deb Package)
> if ! dpkg-query -Wf '${Status}' $pkg | grep -q ' installed'; then
> echo $pkg: not installed
> # uncomment this to remove it ...
> # rm $deb
> fi
>     done

Except that it is incredibly slow (running dpkg-query 1405-times in my
case). The attached version does the same, but is IMHO much better (and
yes, I prefer Python to complicated bash :-)).



Matej Cepl, http://www.ceplovi.cz/matej/blog/
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
They never open their mouths without subtracting from the sum of
human knowledge.
      -- Thomas Brackett Reed

Attachment: midclean.py
Description: application/python

Reply to: