--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,
);
-my $gop = Getopt::Long::Parser->new();
-$gop->configure('pass_through');
-$gop->getoptions(\%options,
- 'quick|q',
- 'service|s',
- 'sysconfdir|c',
- 'progress!',
- 'spool_dir|spool-dir=s',
- 'verbose|v+',
- 'quiet+',
- 'debug|d+','help|h|?','man|m');
-$gop->getoptions('default');
+Getopt::Long::Configure('pass_through');
+GetOptions(\%options,
+ 'quick|q',
+ 'service|s=s',
+ 'sysconfdir|c=s',
+ 'progress!',
+ 'spool_dir|spool-dir=s',
+ 'verbose|v+',
+ 'quiet+',
+ 'debug|d+','help|h|?','man|m');
+Getopt::Long::Configure('default');
pod2usage() if $options{help};
pod2usage({verbose=>2}) if $options{man};
},
'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;
+if (not defined $subcommand) {
+ $subcommand = 'help';
+ print STDERR "You must provide a subcommand; displaying usage.\n";
+ pod2usage();
+} elsif (not exists $subcommands{$subcommand}) {
+ print STDERR "$subcommand is not a valid subcommand; displaying usage.\n";
+ pod2uage();
+}
+
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});
+$subcommands{$subcommand}{function}->(\%options,$opts,$prog_bar,\%config,\@ARGV);
sub add_bugs {
my ($options,$opts,$p,$config,$argv) = @_;
print STDERR "Unable to stat $bug $!\n";
next;
}
- next if $stat->mtime < $time;
+ if ($options{quick}) {
+ my $rs = $s->resultset('Bug')->search({bug=>$bug})->single();
+ next if defined $rs and $stat->mtime < $rs->last_modified()->epoch();
+ }
my $data = read_bug(bug => $bug,
location => $initialdir);
eval {
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;
}
sub handle_subcommand_arguments {
- my ($argv,$args,$gop) = @_;
+ my ($argv,$args) = @_;
my $subopt = {};
- $gop->getoptionsfromarray($argv,
+ Getopt::Long::GetOptionsFromArray($argv,
$subopt,
keys %{$args},
);