--help, -h display this help
--man, -m display manual
+=head1 SUBCOMMANDS
+
+=head2 help
+
+Display this manual
+
+=head2 bugs
+
+Add bugs
+
+=head2 versions
+
+Add versions
+
+=head2 maintainers
+
+Add source maintainers
+
=head1 OPTIONS
=over
Output more information about what is happening. Probably not useful
if you also set --progress.
-=item B<--debug, -d
+=item B<--debug, -d>
Debug verbosity.
use vars qw($DEBUG);
-use Debbugs::Common qw(checkpid lockpid get_hashname getparsedaddrs getbugcomponent make_list);
+use Debbugs::Common qw(checkpid lockpid get_hashname getparsedaddrs getbugcomponent make_list getsourcemaintainers);
use Debbugs::Config qw(:config);
use Debbugs::Status qw(read_bug split_status_fields);
use Debbugs::Log;
verbose => 0,
quiet => 0,
quick => 0,
- service => 'debbugs',
+ service => $config{debbugs_db},
progress => 0,
);
},
'logs' => {function => \&add_logs,
},
+ 'help' => {function => sub {pod2usage({verbose => 2});}}
);
my @USAGE_ERRORS;
my $prog_bar;
if ($options{progress}) {
$prog_bar = eval "Term::ProgressBar->new({count => 1,ETA=>q(linear)})";
- warn "Unable to initialize progress bar: $@" if not $p;
+ warn "Unable to initialize progress bar: $@" if not $prog_bar;
}
+my ($subcommand) = shift @ARGV;
+
my $opts =
- handle_arguments(\@ARGV,$subcommands{$subcommand}{arguments},$gop);
-$subcommands{$subcommand}{function}->($options,$opts,$prog_bar,$config,\@ARGV);
+ handle_subcommand_arguments(\@ARGV,$subcommands{$subcommand}{arguments},$gop);
+$subcommands{$subcommand}{function}->(\%options,$opts,$prog_bar,\%config,\@ARGV);
sub add_bugs {
my ($options,$opts,$p,$config,$argv) = @_;
my $s = db_connect($options);
my @files = @{$argv};
- $p->target(@files) if $p;
+ $p->target(scalar @files) if $p;
for my $file (@files) {
my $fh = IO::File->new($file,'r') or
die "Unable to open $file for reading: $!";
my $sp;
if (not defined $src_pkgs{$versions[$i][0]}) {
$src_pkgs{$versions[$i][0]} =
- $s->resultset('SrcPkg')->find({pkg => $versions[$i][0]});
+ $s->resultset('SrcPkg')->find_or_create({pkg => $versions[$i][0]});
}
$sp = $src_pkgs{$versions[$i][0]};
# There's probably something wrong if the source package
# doesn't exist, but we'll skip it for now
next unless defined $sp;
- my $sv = $s->resultset('SrcVer')->find({src_pkg_id=>$sp->id(),
+ my $sv = $s->resultset('SrcVer')->find({src_pkg=>$sp->id(),
ver => $versions[$i][1],
});
if (defined $ancestor_sv and defined $sv and not defined $sv->based_on()) {
my ($options,$opts,$p,$config,$argv) = @_;
my @files = @{$argv};
-
+ return unless @files;
+ my $s = db_connect($options);
my %arch;
- $p->target(@files) if $p;
+ $p->target(scalar @files) if $p;
for my $file (@files) {
my $fh = IO::File->new($file,'r') or
die "Unable to open $file for reading: $!";
+ my $f_stat = stat($file);
while (<$fh>) {
chomp;
next unless length $_;
($binarch) = $file =~ /_([^\.]+)\.debinfo/;
}
my $sp = $s->resultset('SrcPkg')->find_or_create({pkg => $srcname});
- my $sv = $s->resultset('SrcVer')->find_or_create({src_pkg_id=>$sp->id(),
+ my $sv = $s->resultset('SrcVer')->find_or_create({src_pkg =>$sp->id(),
ver => $srcver});
my $arch;
if (defined $arch{$binarch}) {
$arch{$binarch} = $arch;
}
my $bp = $s->resultset('BinPkg')->find_or_create({pkg => $binname});
- $s->resultset('BinVer')->find_or_create({bin_pkg_id => $bp->id(),
- src_ver_id => $sv->id(),
- arch_id => $arch->id(),
+ $s->resultset('BinVer')->find_or_create({bin_pkg => $bp->id(),
+ src_ver => $sv->id(),
+ arch => $arch->id(),
ver => $binver,
});
}
sub add_maintainers {
my ($options,$opts,$p,$config,$argv) = @_;
- my $maintainers = getmaintainers();
+ my $s = db_connect($options);
+ my $maintainers = getsourcemaintainers();
$p->target(scalar keys %{$maintainers}) if $p;
for my $pkg (keys %{$maintainers}) {
my $maint = $maintainers->{$pkg};
find({name => $maint});
if (not defined $maint_r) {
# get e-mail address of maintainer
- my $e_mail = getparsedaddrs($maint);
+ my $addr = getparsedaddrs($maint);
+ my $e_mail = $addr->address();
+ my $full_name = $addr->phrase();
+ $full_name =~ s/^\"|\"$//g;
+ $full_name =~ s/^\s+|\s+$//g;
# find correspondent
my $correspondent = $s->resultset('Correspondent')->
find_or_create({addr => $e_mail});
+ if (length $full_name) {
+ my $c_full_name = $correspondent->find_or_create_related('correspondent_full_names',
+ {full_name => $full_name}) if length $full_name;
+ $c_full_name->update({last_seen => 'NOW()'});
+ }
$maint_r =
$s->resultset('Maintainer')->
find_or_create({name => $maint,
correspondent => $correspondent,
});
}
- # add the maintainer to the source package
+ # add the maintainer to the source package for packages with
+ # no maintainer
+ $s->txn_do(sub {
+ $s->resultset('SrcPkg')->search({pkg => $pkg})->
+ search_related_rs('src_vers',{ maintainer => undef})->
+ update_all({maintainer => $maint_r->id()});
+ });
$p->update() if $p;
}
$p->remove() if $p;