File ubuntu-versions.patch of Package whohas

From: Yaroslav Halchenko <debian@onerussian.com>
Subject: Reincarnated and refactored the patch to fetch multiple suites from listing page for ubuntu (and Debian)

original patch had header:
    ## 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>

I have not relied on it actually but redone it, this time relying more on the
markup instead of lines counts. Also fixed stripping of additional HREFs after
the version (e.g. to backports repo)

Origin: Debian
Bug-Debian: http://bugs.debian.org/670675
Last-Update: 2012-09-27

--- a/program/whohas
+++ b/program/whohas
@@ -51,7 +51,7 @@ my @columns = (11,38,18,4,10,25);
 my $cols = 6;
 
 my $fedora_release		 =  16			;
-my $ubuntu_current_release	 = "oneiric"		;
+my $ubuntu_current_release	 = "all"		;
 my $opensuse_major		 = "12"			;
 my $opensuse_minor		 = "1"			;
 my $mandrivaVersion		 = "2011.0"		;
@@ -964,17 +964,31 @@ sub debuntu {
 		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,  $baseurl.$parts[2];
-				push @dates, "";
-				@parts = split />|: /, $lines[$i+6];
-				$parts[1] =~ s/ \[\<strong.*//;
-				push @versions, $parts[1];
-				$i += 11;
+				# 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
+				# And this list starts with <ul> and ends with </ul>
+				$i += 1;
+				while (($lines[$i] !~ '</ul>') && ($i < @lines)) {
+					if ($lines[$i] =~ /class="resultlink"/) {
+						push @names, $name;
+						my @parts = split /href\=\"|\"\>|<\/a\>/, $lines[$i];
+						$parts[4] =~ s/ \(|\)://g;
+						push @groups, $parts[4];
+						push @repos, $dists[$x];
+						push @urls,  $baseurl.$parts[2];
+						push @dates, "";
+						my $vline = $lines[$i+3];
+						# prune possibly existing link to backports
+						$vline =~ s/ *\[.*strong.*\]//g;
+						# Split lines e.g. "0.8.4-3+squeeze1: all"
+						@parts = split />|: /, $vline;
+						push @versions, $parts[1];
+						$i += 4; # do not be too greedy
+					} else {
+						$i += 1;
+					}
+				}
 			}
 		}
 	}
openSUSE Build Service is sponsored by