2 # Filename: repodiff.pl
3 # Purpose: compare the available packages from two different repositories
4 # Authors: grml-team (grml.org), (c) Alexander Wirt <formorer@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 # Latest change: Sun Oct 28 18:00:49 CET 2007 [mika]
8 ################################################################################
9 # Notice: adjust $c_file[12] according to your needs, by default the script
10 # compares the i386 pool with the amd64 pool of grml.
11 ################################################################################
17 use AptPkg::Config '$_config';
18 use AptPkg::System '$_system';
21 (my $self = $0) =~ s#.*/##;
23 # initialise the global config object with the default values
26 # determine the appropriate system type
27 $_system = $_config->system;
29 # fetch a versioning system
30 my $vs = $_system->versioning;
34 return 'earlier than' if $_[0] < 0;
35 return 'later than' if $_[0] > 0;
39 my $c_file1 = get('http://deb.grml.org/dists/grml-testing/main/binary-i386/Packages.gz');
40 my $c_file2 = get('http://deb.grml.org/dists/grml-testing/main/binary-amd64/Packages.gz');
42 my $file1 = Compress::Zlib::memGunzip($c_file1);
43 my $file2 = Compress::Zlib::memGunzip($c_file2);
48 my ($package, $version) = "";
50 foreach my $line (split('\n', $file1)) {
51 if ($line =~ m/^Package: (.*)/) {
53 } elsif ($line =~ m/^Version: (.*)/) {
54 $file1_tree->{$package} = "$1";
58 foreach my $line (split('\n', $file2)) {
59 if ($line =~ m/^Package: (.*)/) {
61 } elsif ($line =~ m/^Version: (.*)/) {
62 $file2_tree->{$package} = "$1";
67 foreach my $key (keys %{$file1_tree}) {
68 if (defined $file2_tree->{$key}) {
69 print "package $key version " . $file1_tree->{$key} . " on repo1 is ",
70 (describe $vs->compare($file1_tree->{$key}, $file2_tree->{$key})),
71 " " . $file2_tree->{$key} . " on repo2\n";
73 print "$key does not exist on repo2\n";
77 foreach my $key (keys %{$file2_tree}) {
78 if (not defined $file1_tree->{$key}) {
79 print "$key does not exist on repo1\n";