run lintian on changesfile prior to import rsync
authorMatthias Förste foerste@schlittermann.de
Mon, 19 Sep 2011 16:13:57 +0200
branchrsync
changeset 28 8efaf6179ee8
parent 27 9a44b04eec4f
child 29 677e250ac544
run lintian on changesfile prior to import
bin/rpi
--- a/bin/rpi	Mon Sep 19 13:12:10 2011 +0200
+++ b/bin/rpi	Mon Sep 19 16:13:57 2011 +0200
@@ -14,7 +14,12 @@
 use Pod::Usage;
 use Sys::Hostname::Long;
 
+my %opt = (
+    'run-lintian' => 1,
+);
+
 GetOptions(
+    "l|run-lintian"     => \$opt{run-lintian},
     "h|help"            => sub { pod2usage(-exit => 0, -verbose => 1) },
     "m|man"             => sub {
         pod2usage(
@@ -78,7 +83,7 @@
 sub uploader($);
 sub run_command_and_parse_output($$$$$$);
 sub parse_output($$$$$$$$);
-sub sendmails($$$$);
+sub sendmails($$$$$);
 
 # anything matching these is considered noteworthy and should be sent to someone
 my $important = {
@@ -112,8 +117,9 @@
 # we need to determine uploaders before running reprepro, because it will
 # remove the *.changes files before we are going to parse its output
 my $uploaders = { map { $_ => uploader($_) } glob("$i/*.changes") };
+for my $c (keys %{$uploaders}) { sendmails ({ $uploaders->{$c} => scalar qx{lintian $c 2>&1} }, $valid_receivers, $fallback, $hostname, "[$hostname] Lintian Report"); }
 my $messages = run_command_and_parse_output([@cmd], $uploaders, $important, $unimportant, $log_uncaught, $log_raw);
-sendmails($messages, $valid_receivers, $fallback, $hostname);
+sendmails($messages, $valid_receivers, $fallback, $hostname, "[$hostname] Import Report");
 
 # determine 'uploader' of changes file; 'uploader' means here: either the
 # signer of the changes file or the changer or the maintainer in that order of
@@ -328,9 +334,9 @@
 }
 
 # send the notification mails
-sub sendmails($$$$) {
+sub sendmails($$$$$) {
 
-  my ($messages, $valid_receivers, $fallback, $hostname) = @_;
+  my ($messages, $valid_receivers, $fallback, $hostname, $subject) = @_;
 
   my $from = "$ENV{LOGNAME}\@$hostname";
   my $mfb = $messages->{'fallback'};
@@ -345,7 +351,7 @@
       ($msg, $to) = ("[This is just a test mail to you. If this wasn't a test mail, then it should have been sent to [$u]]\n\n" . $messages->{$u}, $fallback) if $dont_send_to_real_uploader;
 
       sendmail(From => $from,
-	Subject => "[apt] Import Report",
+	Subject => $subject,
 	To => $to,
 	Message => $msg);
       print "[$0]: ", $Mail::Sendmail::log, "\n";
@@ -413,6 +419,16 @@
 C<$fallback> address. Anything matching none of the defined patterns will be
 sent to the C<$fallback> address too. Everything will be printed to stdout.
 
+=head1 OPTIONS
+
+=over
+
+=item B<-l>|B<--[no]run-lintian>
+
+Do or don't run lintian on each changesfile an try to mail results to uploader. (default: do)
+
+=back
+
 =head1 AUTHORS
 
 Matthias Förste L<<foerste@schlittermann.de>>