X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tools%2Fdebianqueued-0.9%2Fdebianqueued;h=fce611e9df1643a76741a6c409de0e56f76f3149;hb=99e73119fc4698d8149ddf4b4397ba93e98efc2b;hp=e84d38528ec697b33dbb5892e9a2541386949260;hpb=761836f71452a6df9a8833cad1fa3e0ca19afe3a;p=dak.git diff --git a/tools/debianqueued-0.9/debianqueued b/tools/debianqueued-0.9/debianqueued index e84d3852..fce611e9 100755 --- a/tools/debianqueued-0.9/debianqueued +++ b/tools/debianqueued-0.9/debianqueued @@ -241,7 +241,7 @@ require 5.002; use strict; use POSIX; -use POSIX qw( sys_stat_h sys_wait_h signal_h ); +use POSIX qw( strftime sys_stat_h sys_wait_h signal_h ); use Net::Ping; use Net::FTP; use Socket qw( PF_INET AF_INET SOCK_STREAM ); @@ -276,11 +276,14 @@ $junk = $conf::no_changes_timeout; $junk = @conf::nonus_packages; $junk = @conf::test_binaries; $junk = @conf::maintainer_mail; +$junk = $conf::mail ||= '/usr/sbin/sendmail'; $conf::target = "localhost" if $conf::upload_method eq "copy"; package main; ($main::progname = $0) =~ s,.*/,,; +my %packages = (); + # extract -r and -k args $main::arg = ""; if (@ARGV == 1 && $ARGV[0] =~ /^-[rk]$/) { @@ -790,6 +793,7 @@ sub process_changes($\@) { elsif (/^Source:\s*/i) { chomp( $pkgname = $' ); $pkgname =~ s/\s+$//; + $main::packages{$pkgname}++; } elsif (/^Files:/i) { while( ) { @@ -2078,6 +2082,7 @@ sub init_mail(;$) { $main::mail_addr = ""; $main::mail_text = ""; + %main::packages = (); $main::mail_subject = $file ? "Processing of $file" : ""; } @@ -2086,7 +2091,6 @@ sub init_mail(;$) { # then send out # sub finish_mail() { - local( *MAIL ); debug( "No mail for $main::mail_addr" ) if $main::mail_addr && !$main::mail_text; @@ -2120,18 +2124,40 @@ sub send_mail($$$) { my $subject = shift; my $text = shift; - debug( "Sending mail to $addr" ); - debug( "executing $conf::mail -s '$subject' -a 'X-Debian: DAK' '$addr'" ); - if (!open( MAIL, "|$conf::mail -s '$subject' -a 'X-Debian: DAK' '$addr'" )) { - msg( "log", "Could not open pipe to $conf::mail: $!\n" ); - return 0; + my $package = keys %main::packages ? join(' ', keys %main::packages) : ""; + + use Email::Send; + + unless (defined($Email::Send::Sendmail::SENDMAIL)) { + $Email::Send::Sendmail::SENDMAIL = $conf::mail; + } + + my $date = sprintf "%s", strftime("%a, %d %B %Y %T %z", (localtime(time))); + my $message = <<__MESSAGE__; +To: $addr +From: Archive Administrator +Subject: $subject +Date: $date +X-Debian: DAK +__MESSAGE__ + + if (length $package) { + $message .= "X-Debian-Package: $package\n"; + } + + $message .= "\n$text"; + $message .= "\nGreetings,\n\n\tYour Debian queue daemon\n"; + + my $mail = Email::Send->new; + for ( qw[Sendmail SMTP] ) { + $mail->mailer($_) and last if $mail->mailer_available($_); } - print MAIL $text; - print MAIL "\nGreetings,\n\n\tYour Debian queue daemon\n"; - if (!close( MAIL )) { - msg( "log", "$conf::mail failed (exit status ", $? >> 8, ")\n" ); + + my $ret = $mail->send($message); + if ($ret && $ret !~ /Message sent|success/) { return 0; } + return 1; }