Here's a little awk script that will correlate the two files, /var/lib/aptitude/pkgstates and /var/lib/apt/extended_states, and print a list of packages that have been manually installed. It's important to feed the aptitude "pkgstates" file first, then the apt "extended_states" file.
Code:
#!/usr/bin/awk -f
/^Package:/ {
pkg_name = $2;
}
/^State:/ {
if ($2 == 1) {
installed_pkg[pkg_name] = 1;
}
}
/^Auto-Installed:/ {
if ($2 == 1 && pkg_name in installed_pkg) {
printf "- removing package %s because it's auto-installed\n", pkg_name;
delete installed_pkg[pkg_name];
}
}
END {
printf "- manually installed packages:\n";
for (i in installed_pkg) {
printf "%s\n", i | "sort";
}
}
Everything that has a "- " at the beginning of the line should be ignored, the rest is a list of packages which have been installed manually.
Example:
Code:
cat /var/lib/aptitude/pkgstates /var/lib/apt/extended_states | /path/to/awk/script