1

Of late, I've done a lot of configuration changes on my Trusty laptop (14.04 LTS). Firstly, I installed gnome-shell, did all updates and migrated to the LTS enablement stack. After that, I added the gnome 3 staging ppa and upgraded gnome-shell from v3.10 to v3.12 from there. Now, when I run apt-get autoremove, I get these packages in the list:

The following packages were automatically installed and are no longer required:
  evolution-indicator gdm gir1.2-gkbd-3.0 gir1.2-tracker-0.16 gir1.2-xkl-1.0 libgtksourceview2.0-0
  libgtksourceview2.0-common libiptcdata0 libtracker-extract-0.16-0
  libtracker-miner-0.16-0 libtracker-sparql-0.16-0 linux-headers-4.2.0-23
  linux-headers-4.2.0-23-generic linux-image-4.2.0-23-generic
  linux-image-extra-4.2.0-23-generic python-gtksourceview2

As I understand, gdm is a critical package which is very much needed as I'm using the gnome-shell. I've also looked at this answer which suggests marking a package as "needed" by just running apt-get install <package>. But how do I know which packages of this list I can safely remove without affecting my system? I know for a fact, however, that I don't need linux-image-* and linux-headers packages as I've already upgraded to later kernel versions. But how do I know about the rest of the packages?

Prahlad Yeri
  • 1,657

1 Answers1

1

the command apt-cache showpkg <package> will tell you the packages "reverse depends" i.e. what other packages - in your configured repositories (not necessarily installed packages) - depend on that package.
In the case of gdm there are alot, so I wrote this script to iterate through all of the reverse dependencies to check if any were installed - which would indicate that you probably shouldnt remove gdm.

#!/bin/bash

package=$1

apt-cache showpkg $package | sed '1,/Reverse Depends:/d;/Dependencies:/,$d'  > /tmp/dependencies.txt

while read line
do
    reverse_dependency=$(awk -F '[:,]' '{print $1}' <<< $line)
    if dpkg -s $reverse_dependency &> /dev/null
    then
        echo "$line is installed and depends on $package"
    fi
done < /tmp/dependencies.txt

If you invoke the script you need to pass the package as a parameter i.e.

./script "gdm"

On my machine the result was

$ ./script.sh gdm
plymouth:i386,gdm 3.0.4-0ubuntu11 is installed and depends on gdm
plymouth,gdm 3.0.4-0ubuntu11 is installed and depends on gdm
plymouth:i386,gdm 3.0.4-0ubuntu11 is installed and depends on gdm
plymouth,gdm 3.0.4-0ubuntu11 is installed and depends on gdm