#!/usr/bin/perl # # shlibdb-compare: compare two shlibsig databases for compatible -dev pkgs # Copyright (C) 1999 Roman Hodek # # This program 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 of the # License, or (at your option) any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # # $Id$ # BEGIN { ($HOME = $ENV{'HOME'}) or die "HOME not defined in environment!\n"; push( @INC, "$main::HOME/lib" ); } package conf; $HOME = $main::HOME; # defaults: $shlib_db_dir = "."; $dpkglibdir = "/var/lib/dpkg"; $local_archive_root = "/pub/debian"; # read conf files require "/etc/sbuild.conf" if -r "/etc/sbuild.conf"; require "$HOME/.sbuildrc" if -r "$HOME/.sbuildrc"; package main; use strict; use DB_File; use vars qw($verbose %dbold %dbnew %result $HOME); $verbose = 0; my %options = (# flags verbose => { short => "v", flag => \$verbose }, # options with args libdir => { short => "l", arg => \$conf::shlib_db_dir } ); while( @ARGV && $ARGV[0] =~ /^-/ ) { $_ = shift @ARGV; last if $_ eq "--"; my($opt, $optname, $arg); if (/^--([^=]+)(=|$)/) { $optname = $1; $opt = $options{$optname}; $arg = $1 if /^--\Q$optname\E=((.|\n)*)$/; } else { $optname = substr( $_, 1, 1 ); $opt = (grep { $_->{short} eq $optname } values %options)[0]; $arg = $1 if /^-$optname(.+)$/; } if (!$opt) { warn "Unknown option: --$1\n"; usage(); } if ($opt->{arg}) { if (!defined $arg) { die "$optname option missing argument\n" if !@ARGV; $arg = shift @ARGV; } ${$opt->{arg}} = $arg; } elsif (defined $arg) { die "Option $optname takes no argument\n"; } if ($opt->{flag}) { ${$opt->{flag}}++; } if ($opt->{code}) { &{$opt->{code}}; } } die "Usage: $0 dist1 dist2\n" if @ARGV != 2; # some checks die "Database dir $conf::shlib_db_dir is not a directory\n" if ! -d $conf::shlib_db_dir; my $distold = $ARGV[0]; my $distnew = $ARGV[1]; my $dboldname = "$conf::shlib_db_dir/shlibsigs-$distold"; my $dbnewname = "$conf::shlib_db_dir/shlibsigs-$distnew"; tie %dbold, 'DB_File', $dboldname, O_RDONLY, 0644, $DB_HASH; die "Cannot open database $dboldname: $!\n" if !tied %dbold; tie %dbnew, 'DB_File', $dbnewname, O_RDONLY, 0644, $DB_HASH; die "Cannot open database $dbnewname: $!\n" if !tied %dbnew; foreach (keys %dbold) { my $md5old = db_md5($dbold{$_}); next if $md5old eq "*"; if (!db_exists( \%dbnew, $_ )) { $result{$_} = "only in $distold"; } else { my $md5new = db_md5($dbnew{$_}); $result{$_} = ($md5old eq $md5new ? "" : "not ") . "compatible"; } } foreach (keys %dbnew) { my $md5new = db_md5($dbnew{$_}); next if $md5new eq "*"; $result{$_} = "only in $distnew" if !db_exists( \%dbold, $_ ); } foreach (sort keys %result) { print "$_: $result{$_}\n"; } sub db_exists { my $db = shift; my $key = shift; return exists $db->{$key} && db_md5($db->{$key}) ne "*"; } sub db_md5 { return (split( ' ', $_[0] ))[1]; }