# Which packages recommended 'Missing Recommends'?

The Synaptic Package Manager has a custom filter "Missing Recommends". Is there a way to find out which packages installed on my system recommended the packages listed in this filter?

-

As far as I know there is no easy way to find out which package recommends a specific other package.

Here is a crude script to build a list of what package recommends or suggests what other package:

dpkg --get-selections | cut -f 1 | while read pkgname
do
apt-cache depends "$pkgname" | \ grep -E "Recommends|Suggests" | \ cut -b 3- | \ while read recommends do echo "$pkgname" "$recommends" done done | sort -k 3 -k 2 | column -t  Note: the script takes some to run. Also the output is very long so you very likely want to capture the output in a file: $ whatrecommends.sh > whatrecommends.txt


Sample of output:

...
ubuntu-desktop                    Recommends:  avahi-autoipd
avahi-daemon                      Suggests:    avahi-autoipd
dhcp3-client                      Suggests:    avahi-autoipd
libnss-mdns                       Suggests:    avahi-autoipd
hplip                             Recommends:  avahi-daemon
rhythmbox                         Recommends:  avahi-daemon
ubuntu-desktop                    Recommends:  avahi-daemon
libsane                           Suggests:    avahi-daemon
pulseaudio-utils                  Suggests:    avahi-daemon
sane-utils                        Suggests:    avahi-daemon
system-config-printer-common      Recommends:  avahi-utils
bash                              Recommends:  bash-completion
ubuntu-standard                   Recommends:  bash-completion
ack-grep                          Suggests:    bash-completion
bash                              Suggests:    bash-doc
...


By changing the parameters of sort at the end of the script you can change the sort order of the output.

-

Aptitude can perform some fairly fancy searches

This will show all the packages that have a Recommends that isn't satisfied:

aptitude search '?installed?broken-recommends'


To restrict it to a specific recommended package:

aptitude search '?installed?broken-recommends(PACKAGE)'

-
This is indeed a step in the right direction, however it would be superb if it would also list which recommends were missing for each package. But I will check into this this weekend and see if I manage to create something usefull with this. –  Zombaya Apr 12 '13 at 14:40

Based on tumbleweed's answer, I made a script that uses aptitude searches to come up with the packages which recommend a missing package.

It however doesn't give the same, complete list as synaptic. No idea why.

### The script

#!/usr/bin/php
<?php

$list = shell_exec("aptitude search '?broken-reverse-recommends(?installed)'"); preg_match_all("|^.{4}(.*) - (.*)$|mU", $list,$matches);

foreach ($matches[1] as$prog) {
$prog = trim($prog);
echo "$prog:\n";$missing = shell_exec("aptitude search '?installed?broken-recommends($prog)'"); preg_match_all("|^.{4}(.*) - (.*)$|mU", $missing,$mismatch);
foreach ($mismatch[1] as$missoft) {
echo "\tRecommended by: ".trim($missoft)."\n"; } }  ### Sample output ecryptfs-utils: Recommended by: adduser firefox: Recommended by: xubuntu-desktop Recommended by: xul-ext-ubufox firefox-gnome-support: Recommended by: xubuntu-desktop libatm1: Recommended by: iproute  - Here, my way - report for missing recommends :) apt-cache --no-pre-depends --no-depends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances depends dpkg --get-selections | grep '\sinstall$' | cut -f1 | grep -vf <(dpkg --get-selections | grep '\sinstall$' | cut -f1 | sed -e 's/^/ /' -e 's/$$:.*\|$$$/\$/') | grep -B1 '^ '

-