You can get package lists with dpkg --get-selection, and read them with dpkg --set-selection - but that only works well if you really want to have the same packages installed.
So I wrote my own diff for dpkg --get-selection output, and its output is suitable to be cut-and-pasted to apt-get or aptitude (for installing or removal).
Being a typical, lazy Perl programmer I let Array::Diff do most of the work.
#!/usr/bin/perl use strict; use warnings; use Array::Diff; if (@ARGV != 2){ die "Usage: $0 file_1 file_2"; } my $diff = Array::Diff->diff(packages($ARGV[0]), packages($ARGV[1])); print "Packages only in '$ARGV[0]':\n"; print join(" ", @{$diff->deleted}), "\n"; print "Packages only in '$ARGV[1]':\n"; print join(" ", @{$diff->added}), "\n"; sub packages { my $fn = shift; open my $file, '<', $fn or die "Can't open file '$fn' for reading: $!"; my @packages = map { $_->[0] } grep { $_->[1] eq 'install' } map { chomp; [ split m/\s+/, $_, 2 ] } <$file>; close $file; return \@packages; }
In reply to Diff for `dpkg --get-selection` output by moritz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |