Package: whohas
Version: 0.24-1
Severity: normal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

The function debian search to all suite (so 4 requests).
The attached patch use the ubuntu function (renamed Debian ;) to search
on both packages.{debian.org,ubuntu.com} with a flag and drop the unused
debian function.

I've also restrict the matching version by dropping debports (in Debian case).

- -- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-26-generic (SMP w/4 CPU cores)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages whohas depends on:
ii  libwww-perl                   5.837-1    simple and consistent interface to
ii  libxml-simple-perl            2.18-3     Perl module for reading and writin
ii  perl                          5.10.1-16  Larry Wall's Practical Extraction 

whohas recommends no packages.

whohas suggests no packages.

- -- no debconf information

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQIcBAEBCAAGBQJM+R5cAAoJEJmGUYuaqqCl9IkP+wT+FiH7tDGVRmH1u+1GHgMn
f/BsC83NkUdkDJckoXLkhKB2HUudH6/cyYDifeETPmWyCw4Bn3JduSb9CdDMssqX
KZv/cYpPwZmkKsIhWPRcJEJZ1ZZHHFr4AwlhK8Wwi5jVYBQ6FGc/gSILZXSAAAMl
AjOh9jy39Yhm7qAtVlIGAf2NkWGA4C7Ld7wTeYRoh/h1Oc+he48YAUBg5Rs8WYdi
n1vleMwGVun240jdq0bJYRpvbAlcFcpplihisiSND/buhWX+2XJx9RbpQSY53gt/
Iw0ivM6cMMHkU2NNYbOV8rQtZac9fjZYG0TsefTOenB5c67QaZst+PUp3hLBUlpK
CmkxI3yTxW+dgEQtbtQWHPIkR175zPBUzd0hJz+lgWnsZn3fYGz4XyL3g066z+Ud
7q5B5QZpiT/UkOCf6ljRIvflvOSVKQJhOdMol0aEQ5bdAtfEobaUHxmkuJlJNp/b
D4Ah/bUMygyECS2MT3Jf9D/MZkTWlbZbadSeOZ0qnBYNVRJEdMq6Fz0L6Wm83Qu5
dkanRksSgqFxHdSvf4ta+kKmpN9d2/NPWuUsB9t59tGC2qgb4wF8pMMhcVOYqDKV
tfsjU596jVAprTMhNGCkD63vOm0i3qMvu13hChhPCojKWBcFZVujhDJKFCbsly7B
4HUQ6UcALfQ7tw5ts1kG
=VxmI
-----END PGP SIGNATURE-----
--- /usr/bin/whohas     2010-04-05 00:42:48.000000000 +0200
+++ /usr/bin/whohas.new 2010-12-03 17:32:57.010903018 +0100
@@ -190,7 +190,7 @@
                        $thrs[$here++] = threads->new(\&sourcemage,     
$ARGV[0]);
                }
                if ($ubuntu_bool == 1) {
-                       $thrs[$here++] = threads->new(\&ubuntu,         
$ARGV[0]);
+                       $thrs[$here++] = threads->new(\&debian,         
$ARGV[0],"Ubuntu");
                }
                if ($gentoo_bool == 1) {
                        $thrs[$here++] = threads->new(\&gentoo,         
$ARGV[0]);
@@ -256,7 +256,7 @@
                &sourcemage(    $ARGV[0]);
        }
        if ($ubuntu_bool == 1) {
-               &ubuntu(        $ARGV[0]);
+               &debian(        $ARGV[0],"Ubuntu");
        }
        if ($opkg_bool == 1) {
                &opkg(          $ARGV[0]);
@@ -336,9 +336,14 @@
        return ($_[0]);
 }
 
-sub ubuntu {
-       my $base = "http://packages.ubuntu.com";;
-       my $query = 
$base."/search?keywords=".$_[0]."&searchon=names&suite=".$ubuntu_current_release."&section=all";
+sub debian {
+       my $base = "http://packages.debian.org";;
+       my $variant = "Debian";
+       if ($_[1] =~ /Ubuntu/) {
+               $base = "http://packages.ubuntu.com";;
+               $variant = "Ubuntu";
+       }
+       my $query = 
$base."/search?keywords=".$_[0]."&searchon=names&suite=all&section=all";
        my @lines = split /\n/, &fetchdoc($query);
        my @names;
        my @versions;
@@ -362,9 +367,19 @@
                                push @groups, $parts[4];
                                push @urls,  $base.$parts[2];
                                push @dates, "";
-                               @parts = split />|<\/strong>/, $lines[$i+1];
+                               if ($variant =~ /Ubuntu/) {
+                                      @parts = split />|<\/strong>/, 
$lines[$i+1];
+                               }
+                               else {
+                                       @parts = split /\(|\)/, $parts[3];
+                               }
                                push @repos, $parts[1];
-                               @parts = split />|: /, $lines[$i+3];
+                               # we don't want Debian debports listed
+                               my $version_line = 3;
+                               if ($lines[$i+$version_line] =~ /debports/) {
+                                       $version_line = 5;
+                               }
+                               @parts = split />|: /, $lines[$i+$version_line];
                                push @versions, $parts[1];
                                $i += 8;
                        }
@@ -390,7 +405,7 @@
                }
        }
        for (my $i = 0; $i < @repos; $i++) {
-               
&pretty_print($cols,@columns,"Ubuntu",$names[$i],$versions[$i],$sizes[$i],$dates[$i],$repos[$i],$urls[$i]);
+               
&pretty_print($cols,@columns,$variant,$names[$i],$versions[$i],$sizes[$i],$dates[$i],$repos[$i],$urls[$i]);
        }
        return ();
 }
@@ -1019,60 +1034,6 @@
        }
 }
 
-sub debian {
-       my $debianbase = "http://packages.debian.org";;
-       my @names;
-       my @repos;
-       my @groups;
-       my @versions;
-       my @urls;
-       my @sizes;
-       my @dates;
-       my @dists = ( 'stable', 'testing', 'unstable', 'experimental' );
-       for (my $x = 0; $x < @dists; $x++) {
-               my @lines = split /\n/, 
&fetchdoc($debianbase."/search?keywords=".$_[0]."&searchon=names&suite=".$dists[$x]."&section=all");
-               for (my $i = 50; $i < @lines; $i++) {
-                       if ($lines[$i] =~ /<h3>Package /) {
-                               my $name = (split /h3>Package |<\/h3>/, 
$lines[$i])[1];
-                               push @names, $name;
-                               my @parts = split /href\=\"|\"\>|<\/a\>/, 
$lines[$i+3];
-                               $parts[4] =~ s/ \(|\)://g;
-                               push @groups, $parts[4];
-                               push @repos, $dists[$x];
-                               push @urls,  $debianbase.$parts[2];
-                               push @dates, "";
-                               @parts = split />|: /, $lines[$i+6];
-                               $parts[1] =~ s/ \[\<strong.*//;
-                               push @versions, $parts[1];
-                               $i += 11;
-                       }
-               }
-       }
-       if ($goDeep == 1) {
-               if ($useThreads == 1) {
-                       my @thr;
-                       for (my $i = 0; $i < @urls; $i++) {
-                               push @thr, threads->new(\&debian_sizes, 
$urls[$i]);
-                       }
-                       for (my $i = 0; $i < @thr; $i++) {
-                               push @sizes, $thr[$i]->join;
-                       }
-               } else {
-                       for (my $i = 0; $i < @urls; $i++) {
-                               push @sizes, &debian_sizes($urls[$i]);
-                       }
-               }
-       } else {
-               for (my $i = 0; $i < @urls; $i++) {
-                       push @sizes, "";
-               }
-       }
-       for (my $i = 0; $i < @repos; $i++) {
-               
&pretty_print($cols,@columns,"Debian",$names[$i],$versions[$i],$sizes[$i],$dates[$i],$repos[$i],$urls[$i]);
-       }
-       return ();
-}
-
 sub aur {
        my $aurbase    = "http://aur.archlinux.org";;
        my $stop;

Reply via email to