]> git.donarmstrong.com Git - debbugs.git/blob - bin/debbugs-loadsql
fix extraneous one
[debbugs.git] / bin / debbugs-loadsql
1 #! /usr/bin/perl
2 # debbugs-loadsql is part of debbugs, and is released
3 # under the terms of the GPL version 2, or any later version, at your
4 # option. See the file README and COPYING for more information.
5 # Copyright 2012 by Don Armstrong <don@donarmstrong.com>.
6
7
8 use warnings;
9 use strict;
10
11 use Getopt::Long qw(:config no_ignore_case);
12 use Pod::Usage;
13
14 =head1 NAME
15
16 debbugs-loadsql -- load debbugs sql database
17
18 =head1 SYNOPSIS
19
20 debbugs-loadsql [options] [subcommand]
21
22  Options:
23   --quick, -q only load changed things
24   --progress Show progress bar
25   --service, -s service name
26   --sysconfdir, -c postgresql service config dir
27   --spool-dir debbugs spool directory
28   --debug, -d debugging level (Default 0)
29   --help, -h display this help
30   --man, -m display manual
31
32 =head1 SUBCOMMANDS
33
34 =head2 help
35
36 Display this manual
37
38 =head2 bugs
39
40 Add bugs (subject, number, etc) to the database
41
42    --preload create all bugs first, then add information
43
44 =head2 versions
45
46 Add version descendant information (which version is based on which version) to
47 the database
48
49 =head2 maintainers
50
51 Add source maintainers to the BTS
52
53 =head2 configuration
54
55 Add debbugs configuration information (tags, severity, etc)
56
57 =head2 suites
58
59 Add suite information from ftp distribution
60
61   --ftpdists location of FTP mirror
62
63 =head2 logs
64
65 Add bug logs
66
67 =head2 packages
68
69 Add package information from the ftp archive
70
71   --ftpdists location of FTP mirror
72   --suites Suite to operate on
73
74 =head2 debinfo
75
76 Add package information from a debinfo file
77
78   --null -0 names of debinfo files are null separated
79
80 =head1 OPTIONS
81
82 =over
83
84 =item B<--quick, -q>
85
86 Only load changed bugs
87
88 =item B<--progress>
89
90 Show progress bar (requires Term::ProgressBar)
91
92 =item B<--service,-s>
93
94 Postgreql service to use; defaults to debbugs
95
96 =item B<--sysconfdir,-c>
97
98 System configuration directory to use; if not set, defaults to the
99 postgresql default. [Operates by setting PGSYSCONFDIR]
100
101 =item B<--spool-dir>
102
103 Debbugs spool directory; defaults to the value configured in the
104 debbugs configuration file.
105
106 =item B<--verbose>
107
108 Output more information about what is happening. Probably not useful
109 if you also set --progress.
110
111 =item B<--debug, -d>
112
113 Debug verbosity.
114
115 =item B<--help, -h>
116
117 Display brief useage information.
118
119 =item B<--man, -m>
120
121 Display this manual.
122
123 =back
124
125
126 =cut
127
128
129 use vars qw($DEBUG);
130
131 use Debbugs::Common (qw(checkpid lockpid get_hashname getparsedaddrs getbugcomponent make_list getsourcemaintainers),
132                      qw(hash_slice));
133 use Debbugs::Config qw(:config);
134 use Debbugs::Status qw(read_bug split_status_fields);
135 use Debbugs::Log;
136 use Debbugs::DB;
137 use Debbugs::DB::Load qw(:load_bug :load_package :load_suite);
138 use DateTime;
139 use File::stat;
140 use File::Basename;
141 use File::Spec;
142 use IO::Dir;
143 use IO::File;
144 use IO::Uncompress::AnyUncompress;
145 use Encode qw(decode_utf8);
146
147 my %options =
148     (debug           => 0,
149      help            => 0,
150      man             => 0,
151      verbose         => 0,
152      quiet           => 0,
153      quick           => 0,
154      service         => $config{debbugs_db},
155      progress        => 0,
156     );
157
158 Getopt::Long::Configure('pass_through');
159 GetOptions(\%options,
160            'quick|q',
161            'service|s=s',
162            'sysconfdir|c=s',
163            'progress!',
164            'spool_dir|spool-dir=s',
165            'verbose|v+',
166            'quiet+',
167            'debug|d+','help|h|?','man|m');
168 Getopt::Long::Configure('default');
169
170 pod2usage() if $options{help};
171 pod2usage({verbose=>2}) if $options{man};
172
173 $DEBUG = $options{debug};
174
175 my %subcommands =
176     ('bugs' => {function => \&add_bugs,
177                 arguments => {'preload' => 0},
178                },
179      'versions' => {function => \&add_versions,
180                    },
181      'debinfo' => {function => \&add_debinfo,
182                    arguments => {'0|null' => 0},
183                   },
184      'maintainers' => {function => \&add_maintainers,
185                       },
186      'configuration' => {function => \&add_configuration,
187                         },
188      'suites' => {function => \&add_suite,
189                   arguments => {'ftpdists=s' => 1,
190                                },
191                  },
192      'logs' => {function => \&add_logs,
193                },
194      'packages' => {function => \&add_packages,
195                     arguments => {'ftpdists=s' => 1,
196                                   'suites=s@' => 0,
197                                  },
198                    },
199      'help' => {function => sub {pod2usage({verbose => 2});}}
200     );
201
202 my @USAGE_ERRORS;
203 $options{verbose} = $options{verbose} - $options{quiet};
204
205 if ($options{progress}) {
206     eval "use Term::ProgressBar";
207     push @USAGE_ERRORS, "You asked for a progress bar, but Term::ProgressBar isn't installed" if $@;
208 }
209
210
211 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
212
213 if (exists $options{sysconfdir}) {
214     if (not defined $options{sysconfdir} or not length $options{sysconfdir}) {
215         delete $ENV{PGSYSCONFDIR};
216     } else {
217         $ENV{PGSYSCONFDIR} = $options{sysconfdir};
218     }
219 }
220
221 if (exists $options{spool_dir} and defined $options{spool_dir}) {
222     $config{spool_dir} = $options{spool_dir};
223 }
224
225 my $prog_bar;
226 if ($options{progress}) {
227     $prog_bar = eval "Term::ProgressBar->new({count => 1,ETA=>q(linear)})";
228     warn "Unable to initialize progress bar: $@" if not $prog_bar;
229 }
230
231
232 my ($subcommand) = shift @ARGV;
233 if (not defined $subcommand) {
234     $subcommand = 'help';
235     print STDERR "You must provide a subcommand; displaying usage.\n";
236     pod2usage();
237 } elsif (not exists $subcommands{$subcommand}) {
238     print STDERR "$subcommand is not a valid subcommand; displaying usage.\n";
239     pod2usage();
240 }
241
242 binmode(STDOUT,':encoding(UTF-8)');
243 binmode(STDERR,':encoding(UTF-8)');
244
245 my $opts =
246     handle_subcommand_arguments(\@ARGV,$subcommands{$subcommand}{arguments});
247 $subcommands{$subcommand}{function}->(\%options,$opts,$prog_bar,\%config,\@ARGV);
248
249 sub add_bugs {
250     my ($options,$opts,$p,$config,$argv) = @_;
251     chdir($config->{spool_dir}) or
252         die "chdir $config->{spool_dir} failed: $!";
253
254     my $verbose = $options->{debug};
255
256     my $initialdir = "db-h";
257
258     if (defined $argv->[0] and $argv->[0] eq "archive") {
259         $initialdir = "archive";
260     }
261     my $s = db_connect($options);
262
263
264     my $time = 0;
265     my $start_time = time;
266     my %tags;
267     my %severities;
268     my %queue;
269
270     if ($opts->{preload}) {
271         my @bugs;
272         walk_bugs([(@{$argv}?@{$argv} : $initialdir)],
273                   undef,
274                   'summary',
275                   undef,
276                   sub {
277                       push @bugs,shift;
278                   });
279         $s->resultset('Bug')->quick_insert_bugs(@bugs);
280     }
281     walk_bugs([(@{$argv}?@{$argv} : $initialdir)],
282               $p,
283               'summary',
284               $verbose,
285               sub {
286                   my $bug = shift;
287                   my $stat = stat(getbugcomponent($bug,'summary',$initialdir));
288                   if (not defined $stat) {
289                       print STDERR "Unable to stat $bug $!\n";
290                       next;
291                   }
292                   if ($options{quick}) {
293                       my $rs = $s->resultset('Bug')->search({bug=>$bug})->single();
294                       next if defined $rs and $stat->mtime < $rs->last_modified()->epoch();
295                   }
296                   my $data = read_bug(bug => $bug,
297                                       location => $initialdir);
298                   eval {
299                       load_bug(db => $s,
300                                data => split_status_fields($data),
301                                tags => \%tags,
302                                severities => \%severities,
303                                queue => \%queue);
304                   };
305                   if ($@) {
306                       use Data::Dumper;
307                       print STDERR Dumper($data) if $DEBUG;
308                       die "failure while trying to load bug $bug\n$@";
309                   }
310               }
311              );
312     handle_load_bug_queue(db => $s,
313                           queue => \%queue);
314 }
315
316 sub add_versions {
317     my ($options,$opts,$p,$config,$argv) = @_;
318
319     my $s = db_connect($options);
320
321     my @files = @{$argv};
322     $p->target(scalar @files) if $p;
323     for my $file (@files) {
324         my $fh = IO::File->new($file,'r') or
325             die "Unable to open $file for reading: $!";
326         my @versions;
327         my %src_pkgs;
328         while (<$fh>) {
329             chomp;
330             next unless length $_;
331             if (/(\w[-+0-9a-z.]+) \(([^\(\) \t]+)\)/) {
332                 push @versions, [$1,$2];
333             }
334         }
335         close($fh);
336         my $ancestor_sv;
337         for my $i (reverse 0..($#versions)) {
338             my $sp;
339             if (not defined $src_pkgs{$versions[$i][0]}) {
340                 $src_pkgs{$versions[$i][0]} =
341                     $s->resultset('SrcPkg')->find_or_create({pkg => $versions[$i][0]});
342             }
343             $sp = $src_pkgs{$versions[$i][0]};
344             # There's probably something wrong if the source package
345             # doesn't exist, but we'll skip it for now
346             next unless defined $sp;
347             my $sv = $s->resultset('SrcVer')->find({src_pkg=>$sp->id(),
348                                                     ver => $versions[$i][1],
349                                                    });
350             if (defined $ancestor_sv and defined $sv and not defined $sv->based_on()) {
351                 $sv->update({based_on => $ancestor_sv->id()})
352             }
353             $ancestor_sv = $sv;
354         }
355         $p->update() if $p;
356     }
357     $p->remove() if $p;
358 }
359
360 sub add_debinfo {
361     my ($options,$opts,$p,$config,$argv) = @_;
362
363     my @files = @{$argv};
364     if (not @files) {
365        {
366            if ($opts->{0}) {
367                local $/ = "\0";
368            }
369            while (<STDIN>) {
370                push @files, $_;
371            }
372        }
373     }
374     return unless @files;
375     my $s = db_connect($options);
376     my %arch;
377     $p->target(scalar @files) if $p;
378     for my $file (@files) {
379         my $fh = IO::File->new($file,'r') or
380             die "Unable to open $file for reading: $!";
381         my $f_stat = stat($file);
382         while (<$fh>) {
383             chomp;
384             next unless length $_;
385             my ($binname, $binver, $binarch, $srcname, $srcver) = split;
386             # if $srcver is not defined, this is probably a broken
387             # .debinfo file [they were causing #686106, see commit
388             # 49c85ab8 in dak.] Basically, $binarch didn't get put into
389             # the file, so we'll fudge it from the filename.
390             if (not defined $srcver) {
391                 ($srcname,$srcver) = ($binarch,$srcname);
392                 ($binarch) = $file =~ /_([^\.]+)\.debinfo/;
393             }
394             my $sp = $s->resultset('SrcPkg')->find_or_create({pkg => $srcname});
395             # update the creation date if the data we have is earlier
396             my $ct_date = DateTime->from_epoch(epoch => $f_stat->ctime);
397             if ($ct_date < $sp->creation) {
398                 $sp->creation($ct_date);
399                 $sp->last_modified(DateTime->now);
400                 $sp->update;
401             }
402             my $sv = $s->resultset('SrcVer')->find_or_create({src_pkg =>$sp->id(),
403                                                               ver => $srcver});
404             if (not defined $sv->upload_date() or $ct_date < $sv->upload_date()) {
405                 $sv->upload_date($ct_date);
406                 $sv->update;
407             }
408             my $arch;
409             if (defined $arch{$binarch}) {
410                 $arch = $arch{$binarch};
411             } else {
412                 $arch = $s->resultset('Arch')->find_or_create({arch => $binarch});
413                 $arch{$binarch} = $arch;
414             }
415             my $bp = $s->resultset('BinPkg')->find_or_create({pkg => $binname});
416             $s->resultset('BinVer')->find_or_create({bin_pkg => $bp->id(),
417                                                      src_ver => $sv->id(),
418                                                      arch    => $arch->id(),
419                                                      ver        => $binver,
420                                                     });
421         }
422         $p->update() if $p;
423     }
424     $p->remove() if $p;
425 }
426
427 sub add_maintainers {
428     my ($options,$opts,$p,$config,$argv) = @_;
429
430     my $s = db_connect($options);
431     my $maintainers = getsourcemaintainers();
432     $p->target(2) if $p;
433     ## get all of the maintainers, and add the missing ones
434     my $maints = $s->resultset('Maintainer')->
435         get_maintainers(values %{$maintainers});
436     $p->update();
437     my @svs = $s->resultset('SrcVer')->
438         search({maintainer => undef
439                },
440               {join => 'src_pkg',
441                group_by => 'me.src_pkg, src_pkg.pkg',
442                result_class => 'DBIx::Class::ResultClass::HashRefInflator',
443                columns => [qw(me.src_pkg src_pkg.pkg)],
444               }
445               )->all();
446     $p->target(2+@svs) if $p;
447     $p->update() if $p;
448     for my $sv (@svs) {
449         if (exists $maintainers->{$sv->{src_pkg}{pkg}}) {
450             my $pkg = $sv->{src_pkg}{pkg};
451             my $maint = $maints->
452                {$maintainers->{$pkg}};
453             $s->txn_do(sub {$s->resultset('SrcVer')->
454                                 search({maintainer => undef,
455                                         'src_pkg.pkg' => $pkg
456                                        },
457                                       {join => 'src_pkg'}
458                                       )->update({maintainer => $maint})
459                                   });
460         }
461         $p->update() if $p;
462     }
463     $p->remove() if $p;
464 }
465
466 sub add_configuration {
467     my ($options,$opts,$p,$config,$argv) = @_;
468
469     my $s = db_connect($options);
470
471     # tags
472     # add all tags
473     my %tags;
474     for my $tag (@{$config{tags}}) {
475         $tags{$tag} = 1;
476         $s->resultset('Tag')->find_or_create({tag => $tag});
477     }
478     # mark obsolete tags
479     for my $tag ($s->resultset('Tag')->search_rs()->all()) {
480         next if exists $tags{$tag->tag};
481         $tag->obsolete(1);
482         $tag->update;
483     }
484
485     # severities
486     my %sev_names;
487     my $order = -1;
488     for my $sev_name (($config{default_severity},@{$config{severity_list}})) {
489         # add all severitites
490         my $sev = $s->resultset('Severity')->find_or_create({severity => $sev_name});
491         # mark strong severities
492         if (grep {$_ eq $sev_name} @{$config{strong_severities}}) {
493             $sev->strong(1);
494         }
495         $sev->ordering($order);
496         $sev->update();
497         $order++;
498         $sev_names{$sev_name} = 1;
499     }
500     # mark obsolete severities
501     for my $sev ($s->resultset('Severity')->search_rs()->all()) {
502         next if exists $sev_names{$sev->severity()};
503         $sev->obsolete(1);
504         $sev->update();
505     }
506 }
507
508 sub add_suite {
509     my ($options,$opts,$p,$config,$argv) = @_;
510     # suites
511
512     my $s = db_connect($options);
513     my $dist_dir = IO::Dir->new($opts->{ftpdists});
514     my @dist_names =
515         grep { $_ !~ /^\./ and
516                -d $opts->{ftpdists}.'/'.$_ and
517                not -l $opts->{ftpdists}.'/'.$_
518            } $dist_dir->read;
519     while (my $dist = shift @dist_names) {
520         my $dist_dir = $opts->{ftpdists}.'/'.$dist;
521         my ($dist_info,$package_files) =
522             read_release_file($dist_dir.'/Release');
523         load_suite($s,$dist_info);
524     }
525 }
526
527 sub add_logs {
528     my ($options,$opts,$p,$config,$argv) = @_;
529
530     chdir($config->{spool_dir}) or
531         die "chdir $config->{spool_dir} failed: $!";
532
533     my $verbose = $options->{debug};
534
535     my $initialdir = "db-h";
536
537     if (defined $argv->[0] and $argv->[0] eq "archive") {
538         $initialdir = "archive";
539     }
540     my $s = db_connect($options);
541
542
543     my $time = 0;
544     my $start_time = time;
545
546     walk_bugs([(@{$argv}?@{$argv} : $initialdir)],
547               $p,
548               'log',
549               $verbose,
550               sub {
551                   my $bug = shift;
552                   my $stat = stat(getbugcomponent($bug,'log',$initialdir));
553                   if (not defined $stat) {
554                       print STDERR "Unable to stat $bug $!\n";
555                       next;
556                   }
557                   if ($options{quick}) {
558                       my $rs = $s->resultset('Bug')->search({bug=>$bug})->single();
559                       next if defined $rs and $stat->mtime < $rs->last_modified()->epoch();
560                   }
561                   eval {
562                       load_bug_log(db => $s,
563                                    bug => $bug);
564                   };
565                   if ($@) {
566                       die "failure while trying to load bug log $bug\n$@";
567                   }
568               });
569 }
570
571 sub add_packages {
572     my ($options,$opts,$p,$config,$argv) = @_;
573
574     my $dist_dir = IO::Dir->new($opts->{ftpdists});
575     my @dist_names =
576         grep { $_ !~ /^\./ and
577                -d $opts->{ftpdists}.'/'.$_ and
578                not -l $opts->{ftpdists}.'/'.$_
579            } $dist_dir->read;
580     my %s_p;
581     while (my $dist = shift @dist_names) {
582         my $dist_dir = $opts->{ftpdists}.'/'.$dist;
583         my ($dist_info,$package_files) =
584             read_release_file($dist_dir.'/Release');
585         $s_p{$dist_info->{Codename}} = $package_files;
586     }
587     my $tot = 0;
588     for my $suite (keys %s_p) {
589         for my $component (keys %{$s_p{$suite}}) {
590             $tot += scalar keys %{$s_p{$suite}{$component}};
591         }
592     }
593     $p->target($tot) if $p;
594     my $i = 0;
595     my $avg_pkgs = 0;
596     my $tot_suites = scalar keys %s_p;
597     my $done_suites=0;
598     my $completed_pkgs=0;
599     # parse packages files
600     for my $suite (keys %s_p) {
601         my @pkgs;
602         for my $component (keys %{$s_p{$suite}}) {
603             my @archs = keys %{$s_p{$suite}{$component}};
604             if (grep {$_ eq 'source'} @archs) {
605                 @archs = ('source',grep {$_ ne 'source'} @archs);
606             }
607             for my $arch (@archs) {
608                 my $pfh =  open_compressed_file($s_p{$suite}{$component}{$arch}) or
609                     die "Unable to open $s_p{$suite}{$component}{$arch} for reading: $!";
610                 local $_;
611                 local $/ = '';  # paragraph mode
612                 while (<$pfh>) {
613                     my %pkg;
614                     for my $field (qw(Package Maintainer Version Source)) {
615                         /^\Q$field\E: (.*)/m;
616                         $pkg{$field} = $1;
617                     }
618                     next unless defined $pkg{Package} and
619                         defined $pkg{Version};
620                     push @pkgs,[$arch,$component,\%pkg];
621                 }
622             }
623         }
624         my $s = db_connect($options);
625         if ($avg_pkgs==0) {
626             $avg_pkgs = @pkgs;
627         }
628         $p->target($avg_pkgs*($tot_suites-$done_suites-1)+
629                    $completed_pkgs+@pkgs) if $p;
630         load_packages($s,
631                       $suite,
632                       \@pkgs,
633                       $p);
634         $avg_pkgs=($avg_pkgs*$done_suites + @pkgs)/($done_suites+1);
635         $completed_pkgs += @pkgs;
636         $done_suites++;
637     }
638     $p->remove() if $p;
639 }
640
641 sub handle_subcommand_arguments {
642     my ($argv,$args) = @_;
643     my $subopt = {};
644     Getopt::Long::GetOptionsFromArray($argv,
645                               $subopt,
646                               keys %{$args},
647                              );
648     my @usage_errors;
649     for my $arg  (keys %{$args}) {
650         next unless $args->{$arg};
651         my $r_arg = $arg; # real argument name
652         $r_arg =~ s/[=\|].+//g;
653         if (not defined $subopt->{$r_arg}) {
654             push @usage_errors, "You must give a $r_arg option";
655         }
656     }
657     pod2usage(join("\n",@usage_errors)) if @usage_errors;
658     return $subopt;
659 }
660
661 sub get_lock{
662     my ($subcommand,$config,$options) = @_;
663     if (not lockpid($config->{spool_dir}.'/lock/debbugs-loadsql-$subcommand')) {
664         if ($options->{quick}) {
665             # If this is a quick run, just exit
666             print STDERR "Another debbugs-loadsql is running; stopping\n" if $options->{verbose};
667             exit 0;
668         }
669         print STDERR "Another debbugs-loadsql is running; stopping\n";
670         exit 1;
671     }
672 }
673
674 sub db_connect {
675     my ($options) = @_;
676     # connect to the database; figure out how to handle errors
677     # properly here.
678     my $s = Debbugs::DB->connect($options->{service}) or
679         die "Unable to connect to database: ";
680 }
681
682 sub open_compressed_file {
683     my ($file) = @_;
684     my $fh;
685     my $mode = '<:encoding(UTF-8)';
686     my @opts;
687     if ($file =~ /\.gz$/) {
688         $mode = '-|:encoding(UTF-8)';
689         push @opts,'gzip','-dc';
690     }
691     if ($file =~ /\.xz$/) {
692         $mode = '-|:encoding(UTF-8)';
693         push @opts,'xz','-dc';
694     }
695     if ($file =~ /\.bz2$/) {
696         $mode = '-|:encoding(UTF-8)';
697         push @opts,'bzip2','-dc';
698     }
699     open($fh,$mode,@opts,$file);
700     return $fh;
701 }
702
703 sub read_release_file {
704     my ($file) = @_;
705     # parse release
706     my $rfh =  open_compressed_file($file) or
707         die "Unable to open $file for reading: $!";
708     my %dist_info;
709     my $in_sha1;
710     my %p_f;
711     while (<$rfh>) {
712         chomp;
713         if (s/^(\S+):\s*//) {
714             if ($1 eq 'SHA1'or $1 eq 'SHA256') {
715                 $in_sha1 = 1;
716                 next;
717             }
718             $dist_info{$1} = $_;
719         } elsif ($in_sha1) {
720             s/^\s//;
721             my ($sha,$size,$f) = split /\s+/,$_;
722             next unless $f =~ /(?:Packages|Sources)(?:\.gz|\.xz)$/;
723             next unless $f =~ m{^([^/]+)/([^/]+)/([^/]+)$};
724             my ($component,$arch,$package_source) = ($1,$2,$3);
725             $arch =~ s/binary-//;
726             next if exists $p_f{$component}{$arch};
727             $p_f{$component}{$arch} = File::Spec->catfile(dirname($file),$f);
728         }
729     }
730     return (\%dist_info,\%p_f);
731 }
732
733 sub walk_bugs {
734     my ($dirs,$p,$what,$verbose,$sub) = @_;
735     my @dirs = @{$dirs};
736     my $tot_dirs = @dirs;
737     my $done_dirs = 0;
738     my $avg_subfiles = 0;
739     my $completed_files = 0;
740     while (my $dir = shift @dirs) {
741         printf "Doing dir %s ...\n", $dir if $verbose;
742
743         opendir(DIR, "$dir/.") or die "opendir $dir: $!";
744         my @subdirs = readdir(DIR);
745         closedir(DIR);
746
747         my @list = map { m/^(\d+)\.$what$/?($1):() } @subdirs;
748         $tot_dirs -= @dirs;
749         push @dirs, map { m/^(\d+)$/ && -d "$dir/$1"?("$dir/$1"):() } @subdirs;
750         $tot_dirs += @dirs;
751         if ($avg_subfiles == 0) {
752             $avg_subfiles = @list;
753         }
754
755         $p->target($avg_subfiles*($tot_dirs-$done_dirs)+$completed_files+@list) if $p;
756         $avg_subfiles = ($avg_subfiles * $done_dirs + @list) / ($done_dirs+1);
757         $done_dirs += 1;
758
759         for my $bug (@list) {
760             $completed_files++;
761             $p->update($completed_files) if $p;
762             print "Up to $completed_files bugs...\n" if ($completed_files % 100 == 0 && $verbose);
763             $sub->($bug);
764         }
765     }
766     $p->remove() if $p;
767 }
768
769
770
771 __END__