diff options
-rwxr-xr-x | emi | 2 | ||||
-rwxr-xr-x | iurt2 | 6 | ||||
-rw-r--r-- | lib/Iurt/Config.pm | 5 | ||||
-rw-r--r-- | lib/Iurt/DKMS.pm | 2 | ||||
-rw-r--r-- | lib/Iurt/Mail.pm | 24 | ||||
-rw-r--r-- | lib/Iurt/Process.pm | 8 | ||||
-rwxr-xr-x | ulri | 2 |
7 files changed, 36 insertions, 13 deletions
@@ -271,7 +271,7 @@ sub upload_prefix_in_section { my $cc; $text .= "\nUpload log available in $config->{http_queue}/rejected/$path/$prefix.youri\n"; - sendmail($to, $cc, "Upload failed for $rpms", $text, "Emi the upload bot <$config->{admin}>", 0); + sendmail($to, $cc, "Upload failed for $rpms", $text, "Emi the upload bot <$config->{admin}>", 0, $config); } # should delete the files @@ -470,6 +470,10 @@ my %config_usage = ( desc => 'Name of the packages distribution', default => 'Mageia' }, + email_domain => { + desc => 'Domain to append to usernames when sending emails', + default => 'mageia.org' + }, home => { desc => 'Home dir', default => $HOME @@ -1564,7 +1568,7 @@ sub send_status_mail { } } print "$text\n"; - sendmail($run->{status_mail}, '' , "Iurt report for $run->{my_arch}/$run->{media}", $text, "Iurt the rebuild bot <$config->{admin}>", 0); + sendmail($run->{status_mail}, '' , "Iurt report for $run->{my_arch}/$run->{media}", $text, "Iurt the rebuild bot <$config->{admin}>", 0, $config); } sub find_provides { diff --git a/lib/Iurt/Config.pm b/lib/Iurt/Config.pm index 7093d1d..2005542 100644 --- a/lib/Iurt/Config.pm +++ b/lib/Iurt/Config.pm @@ -239,9 +239,8 @@ sub get_maint { } my $maint = `GET 'http://maintdb.mageia.org/$srpm_name'`; chomp $maint; - my $email_maint = $maint . '@mageia.org'; - $run->{maint}{$srpm} = $email_maint; - $email_maint, $srpm_name; + $run->{maint}{$srpm} = $maint; + $maint, $srpm_name; } sub get_author_email { diff --git a/lib/Iurt/DKMS.pm b/lib/Iurt/DKMS.pm index 7410008..868770c 100644 --- a/lib/Iurt/DKMS.pm +++ b/lib/Iurt/DKMS.pm @@ -262,7 +262,7 @@ sub dkms_compile { "Modules for $name have been built for the current kernel ($kerver) while they should have been build for $modulesdir.", "Please report to the maintainer of $name", )), - "Iurt the rebuild bot <$config->{admin}>", 0); + "Iurt the rebuild bot <$config->{admin}>", 0, $config); next; } diff --git a/lib/Iurt/Mail.pm b/lib/Iurt/Mail.pm index b805db2..6a9edb6 100644 --- a/lib/Iurt/Mail.pm +++ b/lib/Iurt/Mail.pm @@ -8,15 +8,35 @@ our @EXPORT = qw( sendmail ); +sub expand_email { + my($email, $config) = @_; + return $email unless $config->{email_domain}; + my $name = ""; + my $addr = $email; + if ($email =~ /^(.*)<(.*)>$/) { + $name = $1; + $addr = $2; + } + if ($addr =~ /@/) { + return $email; + } + return "$name<$addr\@$config->{email_domain}>"; +} + sub sendmail { - my ($to, $cc, $subject, $text, $from, $debug) = @_; + my ($to, $cc, $subject, $text, $from, $debug, $config) = @_; do { print "Cannot find sender-email-address [$to]\n"; return } unless defined($to); my $MAIL; if (!$debug) { open $MAIL, "| /usr/sbin/sendmail -t" or return } else { open $MAIL, ">&STDOUT" or return } + $to = expand_email($to, $config); my $sender = encode_mimewords($to); $subject = encode_mimewords($subject); print $MAIL "To: $sender\n"; - if ($cc) { $cc = encode_mimewords($cc); print $MAIL "Cc: $cc\n" } + if ($cc) { + $cc = expand_email($cc, $config); + $cc = encode_mimewords($cc); + print $MAIL "Cc: $cc\n" + } print $MAIL "From: $from\n"; print $MAIL "Subject: $subject\n"; print $MAIL "\n"; diff --git a/lib/Iurt/Process.pm b/lib/Iurt/Process.pm index ff95428..88aa544 100644 --- a/lib/Iurt/Process.pm +++ b/lib/Iurt/Process.pm @@ -234,7 +234,7 @@ sub perform_command { sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: broken pipe", "$comment\n$output", "Iurt the build bot <$config->{admin}>", - $opt{debug_mail}); + $opt{debug_mail}, $config); } else { if ($opt{type} eq 'shell') { $comment = "Command failed: $command\n"; @@ -255,7 +255,7 @@ sub perform_command { } plog('ERR', "ERROR: $wr !"); - sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: could not proceed", "$wr\n\n$comment\n$output", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}) if $opt{wait_mail}; + sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: could not proceed", "$wr\n\n$comment\n$output", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}, $config) if $opt{wait_mail}; } } } @@ -287,9 +287,9 @@ sub perform_command { if ($opt{mail} && $config->{sendmail} && !$config->{no_mail}{$opt{mail}}) { if (! ($cache->{warning}{$opt{hash}}{$opt{mail}} % $opt{freq})) { my $cc = join ',', grep { !$config->{no_mail}{$_} } split ',', $opt{cc}; - sendmail($opt{mail}, $cc, $opt{error} , "$comment\n$out", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}); + sendmail($opt{mail}, $cc, $opt{error} , "$comment\n$out", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}, $config); } elsif ($config->{admin}) { - sendmail($config->{admin}, '' , $opt{error}, "$comment\n$out", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}); + sendmail($config->{admin}, '' , $opt{error}, "$comment\n$out", "Iurt the rebuild bot <$config->{admin}>", $opt{debug_mail}, $config); } } $cache->{warning}{$opt{hash}}{$opt{mail}}++; @@ -530,7 +530,7 @@ foreach my $prefix (keys %pkg_tree) { sendmail($to, $cc, "Rebuild failed on $arch for $srpms", $text, - "Ulri the scheduler bot <$config->{admin}>", 0); + "Ulri the scheduler bot <$config->{admin}>", 0, $config); } # clean the log on the compilation machine |