]> git.donarmstrong.com Git - debbugs.git/blobdiff - bin/debbugs-loadsql
the developer prepare option to debbugs-installsql is superfluous
[debbugs.git] / bin / debbugs-loadsql
index a0da985d6a29a2196cc875c6433eff2bde63e6a6..7dd652783b15ef54d28302120f0a88aa2ab6498d 100755 (executable)
@@ -142,6 +142,7 @@ use DateTime;
 use File::stat;
 use File::Basename;
 use File::Spec;
+use File::Find;
 use IO::Dir;
 use IO::File;
 use IO::Uncompress::AnyUncompress;
@@ -163,6 +164,7 @@ Getopt::Long::Configure('pass_through');
 GetOptions(\%options,
            'quick|q',
            'service|s=s',
+          'dsn=s',
            'sysconfdir|c=s',
            'progress!',
            'spool_dir|spool-dir=s',
@@ -183,7 +185,9 @@ my %subcommands =
      'versions' => {function => \&add_versions,
                    },
      'debinfo' => {function => \&add_debinfo,
-                   arguments => {'0|null' => 0},
+                   arguments => {'0|null' => 0,
+                                'debinfo_dir|debinfo-dir=s' => 0,
+                               },
                   },
      'maintainers' => {function => \&add_maintainers,
                       },
@@ -368,6 +372,15 @@ sub add_debinfo {
     my ($options,$opts,$p,$config,$argv) = @_;
 
     my @files = @{$argv};
+    if (exists $opts->{debinfo_dir} and not @files) {
+       find(sub {
+                if (-f $_ and /\.debinfo$/) {
+                    push @files, $File::Find::name;
+                }
+            },
+            $opts->{debinfo_dir}
+           );
+    }
     if (not @files) {
        {
           local $/ = "\n";
@@ -426,12 +439,12 @@ sub add_maintainers {
     my ($options,$opts,$p,$config,$argv) = @_;
 
     my $s = db_connect($options);
-    my $maintainers = getsourcemaintainers();
+    my $maintainers = getsourcemaintainers() // {};
     $p->target(2) if $p;
     ## get all of the maintainers, and add the missing ones
     my $maints = $s->resultset('Maintainer')->
        get_maintainers(values %{$maintainers});
-    $p->update();
+    $p->update() if $p;
     my @svs = $s->resultset('SrcVer')->
        search({maintainer => undef
               },
@@ -746,7 +759,8 @@ sub db_connect {
     my ($options) = @_;
     # connect to the database; figure out how to handle errors
     # properly here.
-    my $s = Debbugs::DB->connect($options->{service}) or
+    my $s = Debbugs::DB->connect($options->{dsn} //
+                                $options->{service}) or
         die "Unable to connect to database: ";
 }