#! /bin/sh /usr/share/dpatch/dpatch-run
## 06-ubuntu-versions-510203.dpatch by Jonathan Wiltshire <debian@jwiltshire.org.uk>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Patch to show all versions of a package from Ubuntu, not just
## DP: the earliest, see bug 510203.
## DP: Additionally, show the repo that the package is from (eg. universe)
## DP: Original patch from Steve Cotton <steve0001@s.cotton.clara.co.uk>
## DP: Status: forwarded upstream to Philipp Wesche <phi1ipp@yahoo.com>

@DPATCH@
--- whohas-0.23.orig/program/whohas
+++ whohas-0.23/program/whohas
@@ -49,7 +49,7 @@
 my $cols = 6;
 
 my $fedora_release		 =  12			;
-my $ubuntu_current_release	 = "karmic"		;
+my $ubuntu_current_release	 = "all"		;
 #my $opensuse_rel_string		= "112"		;
 my $opensuse_major		 = "11"			;
 my $opensuse_minor		 = "2"			;
@@ -332,18 +332,25 @@
 	my @groups;
 	my $now = 0;
 	for (my $i = 0; $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, "";
-			push @urls,  $base.$parts[2];
-			push @dates, "";
-			@parts = split />|: /, $lines[$i+6];
-			push @versions, $parts[1];
-			$i += 11;
+               (my $name) = ($lines[$i] =~ /<h3>Package (.+)<\/h3>/);
+               if ($name) {
+                       $i += 3;
+                       # There are now one or more 8-line blocks that are approximately
+                       # $lines[$i]   <li class="intrepid"><a class="resultlink" href="/intrepid/dpkg">intrepid</a> (base):
+                       # $lines[$i+3] <br>1.14.20ubuntu6: amd64 i386
+                       while ($lines[$i] =~ /class="resultlink"/) {
+                               push @names, $name;
+                               my @parts = split /href\=\"|\"\>|<\/a\>/, $lines[$i];
+                               $parts[4] =~ s/ \(|\)://g;
+                               push @groups, $parts[4];
+                               push @urls,  $base.$parts[2];
+                               push @dates, "";
+                               @parts = split />|<\/strong>/, $lines[$i+1];
+                               push @repos, $parts[1];
+                               @parts = split />|: /, $lines[$i+3];
+                               push @versions, $parts[1];
+                               $i += 8;
+                       }
 		}
 	}
 	if ($goDeep == 1) {
