Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to retrieve a list of installed packages that have no install candidate (e.g., because I removed an apt source file entry). How would I do that on Debian-based systems?

share|improve this question
    
You could use apt-show-versions and grep for No available version in archive. –  Faheem Mitha Jan 21 '12 at 15:31
add comment

2 Answers

up vote 7 down vote accepted

With Aptitude, search for the ?obsolete pattern, possibly with a custom display format.

aptitude -F '%p' search '?obsolete'
share|improve this answer
    
I knew I should have started learning command-line package management using aptitude instead of apt. Thanks, straightforward and faster than the other answer. :) –  htorque Jan 21 '12 at 17:09
add comment

This one was updated:

for package in $(dpkg -l | awk '/ii/{print $2}'); do
     if ! grep -xq "Package: $package" /var/lib/apt/lists/*Packages; then
         echo $package
     fi
done

Using apt-cache policy:

for package in $(dpkg -l | awk '/ii/{print $2}'); do
    if ! apt-cache policy $package | grep -q '[0-9] http://'; then
        echo $package
    fi
done
share|improve this answer
    
Unfortunately this doesn't seem to care about :i386 packages on systems with multiarch support. Parsing the output of apt-cache policy <package> would work, but that would be rather slow I imagine. –  htorque Jan 21 '12 at 9:59
    
Give me an example of what the output of apt-cache policy would look like on your multiarch system. –  Teresa e Junior Jan 21 '12 at 10:04
    
The example for such a package with no install candidate... –  Teresa e Junior Jan 21 '12 at 10:07
    
paste.ubuntu.com/811658 - but I got another idea: trying to apt-get download -s all installed packages. –  htorque Jan 21 '12 at 10:08
    
Your apt-cache policy doesn't help and apt-get download doesn't exist in Debian. –  Teresa e Junior Jan 21 '12 at 10:24
show 3 more comments

Your Answer

 
discard

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.