]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Modules/Debian.pl
- new time delta function
[infobot.git] / src / Modules / Debian.pl
index 89e249efb623cdcf808fa4bbcb1f939c1c92435d..7652c8cf20be9c2933df57ab39bd40338b6a6996 100644 (file)
@@ -13,9 +13,12 @@ use strict;
 my $announce   = 0;
 my $defaultdist        = "woody";
 my %dists      = (
-       "unstable"      => "woody",
+       "unstable"      => "sid",
+       "testing"       => "woody,      # new since 20001219.
        "stable"        => "potato",
        "incoming"      => "incoming",
+### the following don't work. too much effort to get 3 types of distros
+### to work harmoniously :-)
        "slink"         => "archive-2.1",
        "hamm"          => "archive-2.0",
        "rex"           => "archive-1.?",
@@ -26,11 +29,11 @@ my %urlcontents = (
        "debian/Contents-##DIST-i386.gz" =>
                "ftp://ftp.us.debian.org".
                "/debian/dists/##DIST/Contents-i386.gz",
-### BROKEN!!!
-#      "debian/Contents-##DIST-i386-non-US.gz" =>
-#              "ftp://ftp.ca.debian.org".
-#              "/debian-non-US/dists/##DIST/non-US/Contents-i386.gz",
-###
+### APPEARS TO BE FIXED?
+# => strip control chars just to be safe.
+       "debian/Contents-##DIST-i386-non-US.gz" =>
+               "ftp://ftp.ca.debian.org".
+               "/debian-non-US/dists/##DIST/non-US/Contents-i386.gz",
 );
 
 my %urlpackages = (
@@ -189,7 +192,7 @@ sub searchContents {
     }
 
     # start of search.
-    my $start_time = &main::gettimeofday();
+    my $start_time = &main::timeget();
 
     my $found = 0;
     my %contents;
@@ -296,7 +299,7 @@ sub searchContents {
     @list = sort { length $a <=> length $b } @list;
 
     # show how long it took.
-    my $delta_time = &main::gettimeofday() - $start_time;
+    my $delta_time = &main::timedelta($start_time);
     &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
 
     my $prefix = "Debian Search of '$query' ";
@@ -316,7 +319,7 @@ sub searchAuthor {
     $query =~ s/^\s+|\s+$//g;
 
     # start of search.
-    my $start_time = &main::gettimeofday();
+    my $start_time = &main::timeget();
     &main::status("Debian: starting author search.");
 
     my $files;
@@ -397,7 +400,7 @@ sub searchAuthor {
     my @pkg = sort keys %{$pkg{$list[0]}};
 
     # show how long it took.
-    my $delta_time = &main::gettimeofday() - $start_time;
+    my $delta_time = &main::timedelta($start_time);
     &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
 
     my $email  = join(', ', keys %{$maint{$list[0]}});
@@ -413,7 +416,7 @@ sub searchDesc {
     $query =~ s/^\s+|\s+$//g;
 
     # start of search.
-    my $start_time = &main::gettimeofday();
+    my $start_time = &main::timeget();
     &main::status("Debian: starting desc search.");
 
     my $files;
@@ -476,7 +479,7 @@ sub searchDesc {
     }
 
     # show how long it took.
-    my $delta_time = &main::gettimeofday() - $start_time;
+    my $delta_time = &main::timedelta($start_time);
     &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
 }
 
@@ -788,6 +791,8 @@ sub infoStats {
        close IN;
     }
 
+    ### TODO: don't count ppl with multiple email addresses.
+
     &main::performStrictReply(
        "Debian Distro Stats on $dist... ".
        "\002$total{'count'}\002 packages, ".
@@ -901,7 +906,7 @@ sub validPackage {
            next;
        }
 
-       if (/^$package\n$/) {
+       if (/^\Q$package\E\n$/) {
            push(@files,$file);
        }
        $count++;
@@ -917,7 +922,12 @@ sub searchPackage {
     my ($dist, $query) = &getDistroFromStr($_[0]);
     my $file = "debian/Packages-$dist.idx";
     my @files;
-    my $error = 0;
+    my $error  = 0;
+    my $warn   = 0;
+
+    if ($query =~ tr/A-Z/a-z/) {
+       $warn++;
+    }
 
     &main::status("Debian: Search package matching '$query' in '$dist'.");
     unlink $file if ( -z $file);
@@ -961,6 +971,10 @@ sub searchPackage {
     }
     close IN;
 
+    if (scalar @files and $warn) {
+       &main::msg($main::who, "searching for package name should be fully lowercase!");
+    }
+
     return @files;
 }