From: Michael Prokop Date: Sun, 28 Oct 2007 17:27:46 +0000 (+0100) Subject: Add /usr/share/grml-live/scripts/repodiff.pl (by formorer, thx!) X-Git-Tag: 0.0.7~21 X-Git-Url: https://git.grml.org/?p=grml-live.git;a=commitdiff_plain;h=87c37be5a0cd8450d3e724f673e59c3bd13d5e58 Add /usr/share/grml-live/scripts/repodiff.pl (by formorer, thx!) --- diff --git a/debian/changelog b/debian/changelog index ef9e13b..3fbac63 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ grml-live (0.0.7) unstable; urgency=low debootstrap system we can't do anything via grml-live for you right now. Instead grab http://daily.grml.org/base.tgz and place that at $NFSROOT/nfsroot/live/filesystem.dir/var/tmp/base.tgz + * Add /usr/share/grml-live/scripts/repodiff.pl (by formorer, thx!) + for comparing two repositories. * Replaced /etc/grml/fai/files/etc/apt/preferences with /etc/grml/fai/apt/preferences so grml-live repository can be used and configured at a single place. diff --git a/debian/rules b/debian/rules index aa4bfab..971a44a 100755 --- a/debian/rules +++ b/debian/rules @@ -31,13 +31,13 @@ install: build dh_testroot dh_clean -k dh_installdirs etc/grml/fai/live-initramfs usr/sbin usr/share/doc/grml-live \ - usr/share/grml-live usr/share/grml-live/examples \ - usr/share/grml-live/buildd + usr/share/grml-live usr/share/grml-live/buildd # Add here commands to install the package into debian/grml-live. cp -a etc debian/grml-live/ cp -a examples debian/grml-live/usr/share/doc/grml-live/ cp -a templates debian/grml-live/usr/share/grml-live/ + cp -a scripts debian/grml-live/usr/share/grml-live/ cp -a buildd/*.sh debian/grml-live/usr/share/grml-live/buildd/ install -o root -m 640 buildd/grml-buildd.conf debian/grml-live/etc/grml/grml-buildd.conf install -o root -m 755 grml-live debian/grml-live/usr/sbin/grml-live diff --git a/scripts/repodiff.pl b/scripts/repodiff.pl new file mode 100755 index 0000000..0752cfa --- /dev/null +++ b/scripts/repodiff.pl @@ -0,0 +1,83 @@ +#!/usr/bin/perl +# Filename: repodiff.pl +# Purpose: compare the available packages from two different repositories +# Authors: grml-team (grml.org), (c) Alexander Wirt +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2 or any later version. +# Latest change: Sun Oct 28 18:00:49 CET 2007 [mika] +################################################################################ +# 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