diff options
-rwxr-xr-x | emi | 33 |
1 files changed, 27 insertions, 6 deletions
@@ -28,8 +28,9 @@ # PREFIX : sprintf "$year%02d%02d%02d%02d%02d.$user.$host.${$}_", $mon, $mday, $hour, $min, $sec; use strict; -use Iurt::Config qw(config_usage get_date config_init dump_cache init_cache); +use Iurt::Config qw(config_usage get_date config_init dump_cache init_cache get_repsys_conf); use Iurt::Process qw(check_pid); +use Iurt::Mail qw(sendmail); use Iurt::File qw(check_upload_tree); use Data::Dumper; my %run; @@ -43,10 +44,13 @@ my $HOME = $ENV{HOME}; my $configfile = "$HOME/.upload.conf"; my %config_usage = ( + admin => { desc => 'mail address of the bot administrator', default => 'warly@mandriva.com' }, arch => { desc => "List of arch", default => [ 'i586', 'x86_64', 'ppc' , 'sparc', 'sparc64' ], }, + default_mail_domain => { desc => "Default mail domain to append", default => 'mandriva.org' }, + http_queue => { desc => 'Address where log can be consulted', default => 'http://svn.mandriva.com/queue/'}, mandatory_arch => { desc => 'List of mandatory architecture to be able to upload', default => [ 'i586', 'x86_64' ], @@ -55,7 +59,9 @@ my %config_usage = ( root => { desc => 'Architecture root dir', default => "/mnt/BIG/dis/" }, cache_home => { desc => 'Where to store the cache files', default => "$HOME/.bugs" }, upload_user => { desc => 'User who is uploading packages', default => 'mandrake' }, + repsys_conf => { desc => 'Path of the repsys.conf file which includes login mail corresponding', default => '/etc/repsys.conf' }, queue => { desc => 'root directory of the various upload queues', default => '/home/mandrake/uploads/'}, + ssh_option => { desc => "SSH options", default => "-o ConectTimeout=20" }, ); my $config; @@ -69,6 +75,8 @@ config_usage(\%config_usage, $config) if $run{config_usage}; config_init(\%config_usage, $config, \%run); +my $mail = get_repsys_conf($config->{repsys_conf}); + $run{pidfile_home} = $config->{tmp}; $run{pidfile} = "upload"; my $pidfile = check_pid(\%run); @@ -111,12 +119,15 @@ foreach my $prefix (keys %pkg_tree) { print {$run{LOG}} "$program_name: processing $prefix in $path\n"; my %missing; foreach my $mandatory_arch (@{$config->{mandatory_arch}}, 'src') { - print {$run{LOG}} "$program_name: checking if mandatory architecture $mandatory_arch is present\n"; + print {$run{LOG}} "$program_name: checking if mandatory architecture $mandatory_arch is present: "; if (!$pkg_tree{$prefix}{arch}{$mandatory_arch} ){ if (!$cache->{arch}{$prefix}{$mandatory_arch}) { $missing{$mandatory_arch} = 1; + print {$run{LOG}} "no\n"; $ok = 0 } + } else { + print {$run{LOG}} "yes\n" } } if ($ok) { @@ -146,12 +157,24 @@ foreach my $prefix (keys %pkg_tree) { my $err = link "$done/$path/${prefix}_$rpm", "$reject/$path/${prefix}_$rpm"; print {$run{LOG}} "ERROR $program_name: link of $rpm failed ($!)\n" } - link "$done/$path/$prefix.youri", "$reject/$path/$prefix.youri" + link "$done/$path/$prefix.youri", "$reject/$path/$prefix.youri"; + my ($user) = $prefix =~ /\d{14}\.(\w+)\.\w+\.\d+/; + if ($user) { + my $text = qq{The upload of the following packages failed:\n}; + my $rpms; + foreach my $rpm (@{$pkg_tree{$prefix}{rpms}}) { + $rpms .= "$rpm "; + $text .= "- $rpm\n" + } + my $to = $mail->{$user} || "$user\@mandriva.com, $user\@mandriva.org"; + $text .= "\nUpload log available in $config->{http_queue}/rejected/$path/$prefix.youri\n"; + sendmail($to, $config->{admin} , "Upload failed for $rpms", $text, "Emi the upload bot <$config->{admin}>", 0) + } # should delete the files } # delete the files which should have heen either put in queue or rejected unlink $_ foreach @packages; - unlink $done/$path/$prefix.youri + unlink "$done/$path/$prefix.youri" } else { print {$run{LOG}} "WARNING $program_name: mandatory arch (", join(' ', keys %missing),") are missing for $prefix, waiting\n" } @@ -161,5 +184,3 @@ foreach my $prefix (keys %pkg_tree) { unlink $pidfile; exit; - - |