]> git.decadent.org.uk Git - dak.git/commitdiff
handle compressed files transparently
authorUli Martens <uli@youam.net>
Wed, 28 Mar 2012 09:22:12 +0000 (11:22 +0200)
committerUli Martens <uli@youam.net>
Wed, 28 Mar 2012 09:22:12 +0000 (11:22 +0200)
scripts/debian/update-ftpstats

index 1f9727a422edc9ee329f93704509d7db0ce6b327..a7fda09eb58b3400d3acb3afa26e438963e03f5a 100755 (executable)
@@ -1,20 +1,29 @@
 #!/usr/bin/perl
 
+use strict;
+use warnings;
+
+use IO::Uncompress::AnyUncompress ":all";
+
 my %data;
 my %data2;
 my @archs = ("source", "all", "amd64", "i386", "alpha", "arm", "armel", "armhf", "hppa",
              "hurd-i386", "ia64", "kfreebsd-amd64", "kfreebsd-i386", "mips", "mipsel", "powerpc", "s390",
              "s390x", "sparc");
 
-while (<>) {
-  if (/^(\d{8})\d{6}\|(?:k(?:atie|elly)|process-(?:accepted|upload))(?:\|dak)?\|installed\|[^|]+\|[^|]+\|(\d+)\|([-\w]+)$/) {
-    if (not defined $data{$1}) {
-      foreach $a (@archs) {
-        $data{$1}{$a} = 0;
+for my $file (@ARGV) {
+  my $FH = new IO::Uncompress::AnyUncompress $file, Transparent => 1
+    or die "Cannot open $file: $AnyUncompressError\n";
+  while (<$FH>) {
+    if (/^(\d{8})\d{6}\|(?:k(?:atie|elly)|process-(?:accepted|upload))(?:\|dak)?\|installed\|[^|]+\|[^|]+\|(\d+)\|([-\w]+)$/) {
+      if (not defined $data{$1}) {
+        foreach $a (@archs) {
+          $data{$1}{$a} = 0;
+        }
       }
+      $data{$1}{$3} += $2;
+      $data2{$1}{$3}++;
     }
-    $data{$1}{$3} += $2;
-    $data2{$1}{$3}++;
   }
 }