X-Git-Url: https://git.donarmstrong.com/?p=bugscan.git;a=blobdiff_plain;f=scanlib.pm;h=cc32b457839033ece9f22cf3b14cbfa72355d09b;hp=4c6b09bf03a8fab543e246e117c6e3889f4aae2a;hb=refs%2Fheads%2Fscanlib_fixup;hpb=882c3a5e8e8d32eb965a7d1f805f8ea31668b91c diff --git a/scanlib.pm b/scanlib.pm index 4c6b09b..cc32b45 100644 --- a/scanlib.pm +++ b/scanlib.pm @@ -10,6 +10,9 @@ # %section - map from packagename to section in the FTP-site # %packagelist - map from packagename to bugreports +use warnings; +use strict; + use lib qw(/org/bugs.debian.org/perl); use LWP::UserAgent; use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522); @@ -17,9 +20,13 @@ use Debbugs::Packages; use Debbugs::Versions; use Debbugs::Status; use Fcntl qw(O_RDONLY); -use strict; -use warnings; -require bugcfg; +use IO::File; +use IO::Dir; + +use File::Basename; +use lib dirname(__FILE__); +use bugcfg; + package scanlib; our (%maintainer,%section,%packagelist,%debbugssection,%bugs); @@ -46,14 +53,10 @@ sub readmaintainers() { } -sub readsources() { - my $root; # Root of archive we are scanning - my $archive; # Name of archive we are scanning - my $sect; # Name of current section +sub readsources { + my ($root,$archive) = @_; - $root=shift; - $archive=shift; - for $sect (@bugcfg::sections) { + for my $sect (@bugcfg::sections) { open(P, "zcat $root/$sect/source/Sources.gz|") or die open "open: $sect sourcelist: $!\n"; while (

) { @@ -96,12 +99,9 @@ sub readpackages { } } -sub readdebbugssources() { - my $file; - my $archive; +sub readdebbugssources { + my ($file,$archive) = @_; - $file=shift; - $archive=shift; open(P, $file) or die "open: $file: $!\n"; while (

) { @@ -142,24 +142,22 @@ sub scanspool() { } sub scanspooldir { - my ($dir) = @_; - my $f; # While we're currently processing - my @list; # List of files to process + my ($dir,$bugs) = @_; my $skip; # Flow control my $walk; # index variable my $taginfo; # Tag info my @archs_with_source = ( @bugcfg::architectures, 'source' ); - chdir($dir) or die "chdir $dir: $!\n"; +# chdir($dir) or die "chdir $dir: $!\n"; - opendir(DIR, $dir) or die "opendir $dir: $!\n"; - @list = grep { s/\.summary$// } - grep { m/^\d+\.summary$/ } - readdir(DIR); - closedir(DIR); + my $d = IO::Dir->new($dir) or die "Unable to opendir: $dir $!\n"; + my @list = grep { s/\.summary$// } + grep { m/^\d+\.summary$/ } + $d->read; + $d->close; - for $f (@list) { + for my $f (@list) { my $bug = Debbugs::Status::read_bug(summary => "$f.summary"); next if (!defined($bug)); @@ -183,8 +181,8 @@ sub scanspooldir { next if $skip==1; my %disttags = (); - for (qw(oldstable stable testing unstable)) { - $disttags{$_} = grep(/^$bug_cfg::debian_releases->{$_}$/, @tags); + for my $release (qw(oldstable stable testing unstable)) { + $disttags{$release} = grep(/^$bugcfg::debian_releases->{$release}$/, @tags); } $disttags{'experimental'} = grep(/^experimental$/, @tags); @@ -234,7 +232,7 @@ sub scanspooldir { } for my $keyword (qw(pending patch help moreinfo unreproducible security upstream), - map {$_.$bug_cfg::debian_releases->{testing}.'-ignore'} keys %{$bug_cfg::debian_releases}) { + map {$bugcfg::debian_releases->{$_}.'-ignore'} keys %{$bugcfg::debian_releases}) { $bi->{$keyword} = grep(/^$keyword$/, @tags); } @@ -251,8 +249,9 @@ sub scanspooldir { my $taginfo = get_taginfo($bi); my $relinfo = get_relinfo($bi); - $bugs{$f} = $bi; + $bugs->{$f} = $bi; } + return $bugs; } @@ -262,7 +261,9 @@ sub readstatus { or die "$filename: $!"; while (1) { - chomp (my $type = ); + my $type = ; + last if not defined $type; + chomp $type; if ($type eq 'package') { chomp (my $package = ); chomp (my $section = ); @@ -326,13 +327,13 @@ sub wwwname() { sub check_worry { my ($bi) = @_; - return ($bi->{'testing'} && !$bi->{$bug_cfg::debian_releases->{testing}.'-ignore'}); + return ($bi->{'testing'} && !$bi->{$bugcfg::debian_releases->{testing}.'-ignore'}); } sub check_worry_stable { my ($bi) = @_; - return ($bi->{'stable'} && !$bi->{$bug_cfg::debian_releases->{stable}.'-ignore'}); + return ($bi->{'stable'} && !$bi->{$bugcfg::debian_releases->{stable}.'-ignore'}); } sub check_worry_unstable { @@ -352,7 +353,7 @@ sub get_taginfo { $taginfo .= $bi->{'unreproducible'} ? "R" : " "; $taginfo .= $bi->{'security'} ? "S" : " "; $taginfo .= $bi->{'upstream'} ? "U" : " "; - $taginfo .= ($bi->{$bug_cfg::debian_releases->{stable}.'-ignore'} || $bi->{$bug_cfg::debian_releases->{testing}.'-ignore'}) ? "I" : " "; + $taginfo .= ($bi->{$bugcfg::debian_releases->{stable}.'-ignore'} || $bi->{$bugcfg::debian_releases->{testing}.'-ignore'}) ? "I" : " "; return $taginfo; }