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?
With Aptitude, search for the ?obsolete
pattern, possibly with a custom display format.
aptitude -F '%p' search '?obsolete'
-
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
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
-
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 -
-
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 andapt-get download
doesn't exist in Debian. – Teresa e Junior Jan 21 '12 at 10:24
Just update your packages with
sudo apt-get install update
In most cases it will solve the issues.If any unmet dependency issues are arises use this one
sudo apt-get -f install
apt-show-versions
and grep forNo available version in archive
. – Faheem Mitha Jan 21 '12 at 15:31