On Sun, Apr 19, 2009 at 03:31:19PM +0800, Paul Wise wrote: > On Sun, 2009-04-19 at 09:23 +0200, Jan Hauke Rahm wrote: > > > You're welcome but I just noticed that rc-alert(1) mentions popbugs(1) > > in the SEE ALSO section. I should have had a look there. It's in the > > debian-goodies package which says in its description: > > > > popbugs - Display a customized release-critical bug list based on > > packages you use (using popularity-contest data) > > Unfortunately it isn't useful due to lack of version support (#495606).
I was confused first because both rc-alert and popbugs use the same URL to get the RC bugs but rc-alert compares with /var/lib/dpkg status which popbugs doesn't. > I guess combining the popcon stuff from it with rc-alert would be good. Well, I added a similar algorithm to rc-alert now. I'd appreciate if you could test it. The patch applies against current trunk, though. So, if you find some time please check out svn://svn.debian.org/devscripts/trunk and patch it with the patch attached. scripts/rc-alert --popcon scripts/rc-alert --popcon --pc-vote scripts/rc-alert --popcon --pc-local Cheers, Hauke
Index: scripts/rc-alert.pl =================================================================== --- scripts/rc-alert.pl (revision 1861) +++ scripts/rc-alert.pl (working copy) @@ -27,7 +27,7 @@ use Getopt::Long; sub remove_duplicate_values($); -sub print_if_relevant(%); +sub store_if_relevant(%); sub human_flags($); sub unhtmlsanit($); sub dt_parse_request($); @@ -65,6 +65,10 @@ my $distincoperation = "or"; my $distexcoperation = "or"; +my $popcon = 0; +my $popcon_by_vote = 0; +my $popcon_local = 0; + my $debtags = ''; my $debtags_db = '/var/lib/debtags/package-tags'; @@ -93,6 +97,12 @@ --debtags Comma separated list of tags (e.g. implemented-in::perl,role::plugin) --debtags-database Database file (default: /var/lib/debtags/package-tags) + + Popcon options: + --popcon Sort bugs by package's popcon rank + --pc-vote Sort by_vote instead of by_inst (see debtags(1)) + --pc-local Use local popcon data from last popcon run + (/var/log/popularity-contest) EOF my $version = <<"EOF"; @@ -124,6 +134,9 @@ "exclude-dist-op=s" => \$distexcoperation, "debtags=s" => \$debtags, "debtags-database=s" => \$debtags_db, + "popcon" => \$popcon, + "pc-vote" => \$popcon_by_vote, + "pc-local" => \$popcon_local, ); if ($opt_help) { print $usage; exit 0; } @@ -177,6 +190,30 @@ $package_list = InstalledPackages(0); } +## Get popcon information +my %popcon; +if ($popcon) { + my $pc_by = $popcon_by_vote ? 'vote' : 'inst'; + + my $pc_regex; + if ($popcon_local) { + open POPCON, "/var/log/popularity-contest" + or die "Unable to access popcon data: $!"; + $pc_regex = '(\d+)\s\d+\s(\S+)'; + } else { + open POPCON, "wget -q -O - http://popcon.debian.org/by_$pc_by.gz | gunzip -c |" + or die "Not able to receive remote popcon data!"; + $pc_regex = '(\d+)\s+(\S+)\s+(\d+\s+){5}\(.*\)'; + } + + while (<POPCON>) { + next unless /$pc_regex/; + # rank $1 for package $2 + $popcon{$2} = $1; + } + close POPCON; +} + ## Get debtags info my %dt_pkg; my @dt_requests; @@ -198,6 +235,7 @@ my $found_bugs_start; my ($current_package, $comment); +my %pkg_store; while (defined(my $line = <BUGS>)) { if( $line =~ /^<div class="package">/) { $found_bugs_start = 1; @@ -210,9 +248,10 @@ } elsif ($line =~ m%<a name="(\d+)"></a>\s*<a href="[^\"]+">\d+</a> (\[[^\]]+\])( \[[^\]]+\])? ([^<]+)%i) { my ($num, $tags, $dists, $name) = ($1, $2, $3, $4); chomp $name; - print_if_relevant(pkg => $current_package, num => $num, tags => $tags, dists => $dists, name => $name, comment => $comment); + store_if_relevant(pkg => $current_package, num => $num, tags => $tags, dists => $dists, name => $name, comment => $comment); } } +for (sort {$a <=> $b } keys %pkg_store) { print $pkg_store{$_}; } close BUGS or die "$progname: could not close $cachefile: $!\n"; @@ -228,15 +267,16 @@ return $in; } -sub print_if_relevant(%) { +sub store_if_relevant(%) { my %args = @_; + if (exists($$package_list{$args{pkg}})) { # potentially relevant my ($flags, $flagsapply) = human_flags($args{tags}); my $distsapply = 1; my $dists; ($dists, $distsapply) = human_dists($args{dists}) if defined $args{dists}; - + return unless $flagsapply and $distsapply; foreach (@dt_requests) { @@ -246,16 +286,32 @@ } # yep, relevant - print "Package: $args{pkg}\n", - $comment, # non-empty comments always contain the trailing \n - "Bug: $args{num}\n", - "Title: " . unhtmlsanit($args{name}) , "\n", - "Flags: " . $flags , "\n", - (defined $args{dists} ? "Dists: " . $dists . "\n" : ""), + my $bug_string = "Package: $args{pkg}\n" . + $comment . # non-empty comments always contain the trailing \n + "Bug: $args{num}\n" . + "Title: " . unhtmlsanit($args{name}) . "\n" . + "Flags: " . $flags . "\n" . + (defined $args{dists} ? "Dists: " . $dists . "\n" : "") . (defined $dt_pkg{$args{pkg}} ? - "Debtags: " . $dt_pkg{$args{pkg}} . "\n" : ""), - "\n"; + "Debtags: " . $dt_pkg{$args{pkg}} . "\n" : ""); + unless ($popcon_local) { + $bug_string .= (defined $popcon{$args{pkg}} ? + "Popcon rank: " . $popcon{$args{pkg}} . "\n" : ""); } + $bug_string .= "\n"; + + if ($popcon) { + return unless $bug_string; + my $index = $popcon{$args{pkg}} ? $popcon{$args{pkg}} : 9999999; + if ($pkg_store{$index}) { + $pkg_store{$index} .= $bug_string; + } else { + $pkg_store{$index} = $bug_string; + } + } else { + $pkg_store{1} .= $bug_string; + } + } } sub human_flags($) { Index: scripts/rc-alert.1 =================================================================== --- scripts/rc-alert.1 (revision 1861) +++ scripts/rc-alert.1 (working copy) @@ -2,7 +2,7 @@ .SH NAME rc-alert \- check for installed packages with release-critical bugs .SH SYNOPSIS -\fBrc-alert [inclusion options] [\-\-debtags [tag[,tag ...]] [package ...]\fR +\fBrc-alert [inclusion options] [\-\-debtags [tag[,tag ...]] [\-\-popcon] [package ...]\fR .br \fBrc-alert \-\-help|\-\-version\fR .SH DESCRIPTION @@ -76,6 +76,22 @@ .BR \-\-debtags\-database Use a non-standard debtags database. The default is /var/lib/debtags/packages-tags. +.P +Popularity-contest collects data about installation and usage of Debian +packages. You can additionaly sort the bugs by the popcon rank of the related +packages. +.TP +.BR \-\-popcon +Sort bugs by popcon rank of the package the bug belongs to. +.TP +.BR \-\-pc\-vote +Packages are sorted by the number of people who installed this package. With +this option you can change it to the number of people who use this package +regularly. This option has no effect in combination with \-\-pc\-local. +.TP +.BR \-\-pc\-local +Instead of requesting remote data the information of the last popcon run is +used (/var/log/popularity-contest). .SH EXAMPLES .TP .BR \-\-include\-dists " OS" @@ -95,6 +111,10 @@ The bug must apply to packages matching the specified debtags, i.e. the match will only include packages that have the ‘role::plugin’ tag and that have either of the tags ‘implemented-in::perl’ or ‘implemented-in::python’. +.TP +.BR \-\-popcon " "\-\-pc\-local +Read out /var/log/popularity-contest and sort bugs by your personal popcon +ranking (which is basically the atime of your packages binaries). .SH BUGS It is not possible to say "does not apply only to unstable" .SH SEE ALSO
signature.asc
Description: Digital signature