Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 82 lines (65 sloc) 2.294 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#!/usr/bin/perl
# Filename: repodiff.pl
# Purpose: compare the available packages from two different repositories
# Authors: grml-team (grml.org), (c) Alexander Wirt <formorer@grml.org>
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2 or any later version.
################################################################################
# Notice: adjust $c_file[12] according to your needs, by default the script
# compares the i386 pool with the amd64 pool of grml.
################################################################################

use strict;
use LWP::Simple;
use Compress::Zlib ;

use AptPkg::Config '$_config';
use AptPkg::System '$_system';
use AptPkg::Version;

(my $self = $0) =~ s#.*/##;

# initialise the global config object with the default values
$_config->init;

# determine the appropriate system type
$_system = $_config->system;

# fetch a versioning system
my $vs = $_system->versioning;

sub describe
{
    return 'earlier than' if $_[0] < 0;
    return 'later than' if $_[0] > 0;
    'the same as';
}

my $c_file1 = get('http://deb.grml.org/dists/grml-testing/main/binary-i386/Packages.gz');
my $c_file2 = get('http://deb.grml.org/dists/grml-testing/main/binary-amd64/Packages.gz');

my $file1 = Compress::Zlib::memGunzip($c_file1);
my $file2 = Compress::Zlib::memGunzip($c_file2);

my $file1_tree;
my $file2_tree;

my ($package, $version) = "";

foreach my $line (split('\n', $file1)) {
    if ($line =~ m/^Package: (.*)/) {
$package = $1;
    } elsif ($line =~ m/^Version: (.*)/) {
$file1_tree->{$package} = "$1";
    }
}

foreach my $line (split('\n', $file2)) {
     if ($line =~ m/^Package: (.*)/) {
$package = $1;
    } elsif ($line =~ m/^Version: (.*)/) {
$file2_tree->{$package} = "$1";
    }
}


foreach my $key (keys %{$file1_tree}) {
    if (defined $file2_tree->{$key}) {
print "package $key version " . $file1_tree->{$key} . " on repo1 is ",
(describe $vs->compare($file1_tree->{$key}, $file2_tree->{$key})),
" " . $file2_tree->{$key} . " on repo2\n";
    } else {
print "$key does not exist on repo2\n";
     }
}

foreach my $key (keys %{$file2_tree}) {
    if (not defined $file1_tree->{$key}) {
print "$key does not exist on repo1\n";
    }
}

# EOF
Something went wrong with that request. Please try again.