#!/usr/bin/perl # Copyright (C) 2004 Stéphane Levant # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This file is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # Affiche les différences entre deux /var/lib/dpkg/status use strict; sub read_dpkg { my ($file) = @_; my $src = *STDIN; if ($file ne "-") { $src = *SRC; open ($src, $file); } my %t; my $pack = ""; while (<$src>) { $pack = $1 if (/^Package: (.+)$/); if (/^Status: (.+)$/) { if ($1 ne "install ok installed") { $pack = ""; } } if (/^Description: (.*)$/ && $pack ne "") { $t{$pack} = $1; } } if ($file ne "-") { close ($src); } return %t; } my %loc = read_dpkg ("/var/lib/dpkg/status"); my %arg = read_dpkg (@ARGV[0]); foreach my $i (sort keys %loc) { if (! $arg{$i}) { printf ("< %-25s %s\n", $i, $loc{$i}); } } print "\n"; foreach my $i (sort keys %arg) { if (! $loc{$i}) { printf ("> %-25s %s\n", $i, $arg{$i}); } }