[Pkg-multidistrotools-commits] r19 - multidistrotools/trunk/scripts
raphink-guest at alioth.debian.org
raphink-guest at alioth.debian.org
Tue Dec 18 14:01:37 UTC 2007
Author: raphink-guest
Date: 2007-12-18 14:01:37 +0000 (Tue, 18 Dec 2007)
New Revision: 19
Modified:
multidistrotools/trunk/scripts/compare-versions.pl
Log:
Clean script a bit
Modified: multidistrotools/trunk/scripts/compare-versions.pl
===================================================================
--- multidistrotools/trunk/scripts/compare-versions.pl 2007-12-18 13:32:09 UTC (rev 18)
+++ multidistrotools/trunk/scripts/compare-versions.pl 2007-12-18 14:01:37 UTC (rev 19)
@@ -8,27 +8,39 @@
use File::HomeDir;
use List::MoreUtils qw(uniq);
+#########################################
+
+
+# Configuration
+################
+
my $home = File::HomeDir->my_home;
my $mdtdir = "$home/.multidistrotools";
+my %listdir;
+
+my %packages;
+
+my %all_files;
+my %dist_files;
+
+
+# Arguments
+############
+
my ($dist1,$dist2) = @ARGV;
-
if ( ! $dist1 || ! $dist2 ) {
die "Usage: mdt compare-versions sarge etch";
}
-my %listdir;
+# Initialisation
+#################
$listdir{$dist1} = "$mdtdir/$dist1/var/lib/apt/lists";
$listdir{$dist2} = "$mdtdir/$dist2/var/lib/apt/lists";
-my %packages;
-
-my %all_files;
-my %dist_files;
-
foreach my $dist ($dist1, $dist2) {
opendir(LISTDIR, $listdir{$dist}) || die "Could not open dir $listdir{$dist} : $!\n";
@{$all_files{$dist}} = readdir(LISTDIR);
@@ -38,11 +50,47 @@
}
-######################################
-### Functions
-######################################
+# Execution
+############
+# Parse files for each dist
+foreach my $dist ($dist1, $dist2) {
+ foreach my $file ( @{$dist_files{$dist}} ) {
+ my $parsed_file = parseFile("$listdir{$dist}/$file");
+ foreach my $package ( keys(%{$parsed_file}) ) {
+ if ( $packages{$dist}{$package} ) {
+ warn "Package $package is already listed for $dist. Not overriding.\n";
+ } else {
+ $packages{$dist}{$package} = $parsed_file->{$package};
+ }
+ }
+ }
+}
+
+
+# Get entire list of packages
+my @all_packages = uniq sort ( keys(%{$packages{$dist1}}), keys(%{$packages{$dist2}}) );
+
+
+# Compare each dist with full list and output
+foreach my $package (@all_packages) {
+ my $line = "$package ";
+
+ foreach my $dist ($dist1, $dist2) {
+ if ( $packages{$dist}{$package} ) {
+ $line .= "$packages{$dist}{$package}{'Version'} ";
+ } else {
+ $line .= "NOTFOUND ";
+ }
+ }
+ print "$line\n";
+}
+
+
+# Functions
+############
+
sub parseFile {
my ($file) = @_;
@@ -81,37 +129,3 @@
return \%result;
}
-
-
-
-foreach my $dist ($dist1, $dist2) {
- foreach my $file ( @{$dist_files{$dist}} ) {
- my $parsed_file = parseFile("$listdir{$dist}/$file");
- foreach my $package ( keys(%{$parsed_file}) ) {
- if ( $packages{$dist}{$package} ) {
- warn "Package $package is alread listed for $dist. Not overriding.\n";
- } else {
- $packages{$dist}{$package} = $parsed_file->{$package};
- }
- }
- }
-}
-
-
-
-# Get entire list of packages
-my @all_packages = uniq sort ( keys(%{$packages{$dist1}}), keys(%{$packages{$dist2}}) );
-
-foreach my $package (@all_packages) {
- my $line = "$package ";
-
- foreach my $dist ($dist1, $dist2) {
- if ( $packages{$dist}{$package} ) {
- $line .= "$packages{$dist}{$package}{'Version'} ";
- } else {
- $line .= "NOTFOUND ";
- }
- }
- print "$line\n";
-}
-
More information about the Pkg-multidistrotools-commits
mailing list