Subject: Re: top-ten patch
To: Jan Schaumann <jschauma@netmeister.org>
From: Min Sik Kim <minskim@NetBSD.org>
List: pkgsrc-bulk
Date: 05/16/2005 12:13:45
--Apple-Mail-4-517471740
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed

On May 13, 2005, at 9:25 AM, Jan Schaumann wrote:

> Min Sik Kim <minskim@NetBSD.org> wrote:
>
>> On May 8, 2005, at 2:34 PM, Jan Schaumann wrote:
>>
>
>
>>> Attached find a patch to calculate and list the top-ten offenders  
>>> in a
>>> bulk-build.  I have used this in my last IRIX build for the
>>> pkgsrc-2005Q1 branch, but since post-build has changed a bit for
>>> pkgsrc-current, I'd like somebody else to test this before I commit
>>> it.
>>>
>>>
>>
>> I ran my recent Linux bulk build with the patch applied, but the
>> result doesn't include the top ten list.  It only has a link.
>>
>
> Hmm, strange.  I just finished another build (though from the branch),
> and that worked fine, too.  Just to make sure, here's the patch that
> applies to the branch -- it might need minor adjustment for -current.
> Could you try to weave that into your mk/bulk/post-build and see if it
> works?

Now it works fine.  The patch for -current is attached.

Regards,
Min Sik Kim


--Apple-Mail-4-517471740
Content-Transfer-Encoding: 7bit
Content-Type: application/octet-stream;
	x-unix-mode=0644;
	name="post-build.diff"
Content-Disposition: attachment;
	filename=post-build.diff

Index: post-build
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bulk/post-build,v
retrieving revision 1.51
diff -u -r1.51 post-build
--- post-build	15 Jan 2005 01:53:00 -0000	1.51
+++ post-build	16 May 2005 17:10:25 -0000
@@ -106,10 +106,10 @@
 
 my $report_head = <<EOF;
 Package                    Breaks  Maintainer
---------------------------------------------------------------
+----------------------------------------------------------------------
 EOF
 my $report_form = <<EOF;
-@<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
+@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<
 EOF
 # $pkg, $nbrokenby, $maintainer
 
@@ -241,7 +241,7 @@
 		'<td align="right" class="pkg-'.$state_style.'">'.$nbrokenby.'</td>'
 		if $nbrokenby > 0;
 
-	if ($pinfo->{nerrors} != 0 && $verbose && $state eq "broken") {
+	if ($pinfo->{nerrors} != 0 && $verbose && ($state eq "broken" || $state eq "topten")) {
 		print swrite($report_form, $pkg, $nbrokenby > 0 ? $nbrokenby : "", $maintainer);
 	}
 
@@ -450,6 +450,7 @@
 <p>
   Jump to:<br/>
   <ul>
+    <li><a href="#topten">Top Ten Offenders</a></li>
     <li><a href="#broken">Broken packages</a></li>
     <li><a href="#broken depends">Broken dependencies</a></li>
     <li><a href="#not packaged">Not packaged</a></li>
@@ -459,19 +460,20 @@
 EOHTML
 
 	my %state_head = (
+		"topten" => "Top Ten Offenders",
 		"broken" => "Broken packages",
 		"broken depends" => "Broken dependencies",
 		"not packaged" => "Not packaged"
 	);
 
-	# only include broken packages in the email, see also pkgResult().
-	if ($verbose && scalar(@{$broken->{"broken"}})) {
-		print "\n\n$state_head{broken}\n\n";
+	foreach my $state ("topten", "broken", "broken depends", "not packaged") {
+		next unless scalar(@{$broken->{$state}});
+		
+		if ($verbose && ($state eq "topten" || $state eq "broken")) {
+			print "\n\n$state_head{$state}\n\n";
 		print $report_head;
 	}
 
-	foreach my $state ("broken", "broken depends", "not packaged") {
-		next unless scalar(@{$broken->{$state}});
 
 		print HTML <<EOHTML;
 
@@ -571,6 +573,12 @@
 		$res->{$state} = [ sort { $a->{pkg} cmp $b->{pkg} } @{$res->{$state}} ];
 	}
 
+	$res->{"topten"} = [ sort { $b->{nbrokenby} <=> $a->{nbrokenby} } @{$res->{"broken"}} ];
+
+	for (my $count = $#{$res->{"topten"}}; $count >= 10; $count--) {
+		pop(@{$res->{"topten"}});
+	}
+
 	return $res;
 }
 

--Apple-Mail-4-517471740--