Another way to do this is by determining what has been installed based on your "tasks" which determine the base packages to install according to your initial needs.
tasksel --list-tasks
At the very least you'd have server
. However, you may choose to have more. For each of those tasks you have installed, you can get a list of packages that are installed the following command does it all in one line (broken down for clarity) for the ones I have chosen in my installation:
(tasksel --task-packages server ; \
tasksel --task-packages openssh-server ; \
tasksel --task-packages lamp-server) | sort | uniq
A generic approach to the above would be:
(for a in $( tasksel --list-tasks | grep "^i" | awk '{ print $2 }' ) ; \
do tasksel --task-packages $a; done) | sort | uniq
Now use apt-cache depends --installed -i --recurse <packagename> | grep -v "^ "
to get a list of dependencies used by all the packages defined in the task. This can be done in one line as follows
apt-cache depends --installed -i --recurse \
$(for a in $( tasksel --list-tasks | \
grep "^i" | \
awk '{ print $2 }' ) ; \
do tasksel --task-packages $a; done) | grep -v "^ " | sort | uniq
The following lists all the packages that are installed in your system (not including dependencies).
dpkg --get-selections | grep "[[:space:]]install" | awk '{print $1}'
Now use the comm
command to find the ones that are in the second list only (i.e. ignore those that are in both files and just the first file)
comm -13 <(apt-cache depends --installed -i --recurse \
$(for a in $( tasksel --list-tasks | \
grep "^i" | \
awk '{ print $2 }' ) ; \
do tasksel --task-packages $a; done) | grep -v "^ " | sort ) \
<( dpkg --get-selections | grep "[[:space:]]install" | \
awk '{print $1}' | sort)