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 ################################################################################
8 # Notice: adjust $c_file[12] according to your needs, by default the script
9 # compares the i386 pool with the amd64 pool of grml.
10 ################################################################################
16 use AptPkg::Config '$_config';
17 use AptPkg::System '$_system';
20 (my $self = $0) =~ s#.*/##;
22 # initialise the global config object with the default values
25 # determine the appropriate system type
26 $_system = $_config->system;
28 # fetch a versioning system
29 my $vs = $_system->versioning;
33 return 'earlier than' if $_[0] < 0;
34 return 'later than' if $_[0] > 0;
38 my $c_file1 = get('http://deb.grml.org/dists/grml-testing/main/binary-i386/Packages.gz');
39 my $c_file2 = get('http://deb.grml.org/dists/grml-testing/main/binary-amd64/Packages.gz');
41 my $file1 = Compress::Zlib::memGunzip($c_file1);
42 my $file2 = Compress::Zlib::memGunzip($c_file2);
47 my ($package, $version) = "";
49 foreach my $line (split('\n', $file1)) {
50 if ($line =~ m/^Package: (.*)/) {
52 } elsif ($line =~ m/^Version: (.*)/) {
53 $file1_tree->{$package} = "$1";
57 foreach my $line (split('\n', $file2)) {
58 if ($line =~ m/^Package: (.*)/) {
60 } elsif ($line =~ m/^Version: (.*)/) {
61 $file2_tree->{$package} = "$1";
66 foreach my $key (keys %{$file1_tree}) {
67 if (defined $file2_tree->{$key}) {
68 print "package $key version " . $file1_tree->{$key} . " on repo1 is ",
69 (describe $vs->compare($file1_tree->{$key}, $file2_tree->{$key})),
70 " " . $file2_tree->{$key} . " on repo2\n";
72 print "$key does not exist on repo2\n";
76 foreach my $key (keys %{$file2_tree}) {
77 if (not defined $file1_tree->{$key}) {
78 print "$key does not exist on repo1\n";