aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2006-05-25 13:37:38 +0000
committerFlorent Villard <warly@mandriva.com>2006-05-25 13:37:38 +0000
commitb4f3eac78c3c19ad2f635c02c01fe730a13f367b (patch)
tree6f5efefd565926b53ea9ac87aadec738f2641472
parent19a658be739b905534c6973c2ea7d61579962b81 (diff)
downloadiurt-b4f3eac78c3c19ad2f635c02c01fe730a13f367b.tar
iurt-b4f3eac78c3c19ad2f635c02c01fe730a13f367b.tar.gz
iurt-b4f3eac78c3c19ad2f635c02c01fe730a13f367b.tar.bz2
iurt-b4f3eac78c3c19ad2f635c02c01fe730a13f367b.tar.xz
iurt-b4f3eac78c3c19ad2f635c02c01fe730a13f367b.zip
fix --stop (no exec anymore, which I do not manage to make work, use a system)
-rwxr-xr-xiurt252
1 files changed, 32 insertions, 20 deletions
diff --git a/iurt2 b/iurt2
index ad198a8..96c77e0 100755
--- a/iurt2
+++ b/iurt2
@@ -105,7 +105,7 @@ $run{todo} = [ ];
"Media to rebuild",
sub { ($run{media}) = @_; 1 }, "Adding a media to rebuild" ],
[ "r", "rebuild", -2, "<distro> <architecture> <srpm 1> <srpm 2> ... <srpm n>",
- "Rebuild the packages, e.g. $program_name -r cooker x86_64 /home/foo/rpm/SRPMS/foo-2.3-12mdk.src.rpm",
+ "Rebuild the packages, e.g. $program_name -r cooker x86_64 /home/foo/rpm/SRPMS/foo-2.3-12mdv2007.0.src.rpm",
sub {
$run{rebuild} = 1;
$run{distro} = shift @_;
@@ -370,10 +370,11 @@ if (!@{$run{todo}} && !$run{debug} && !$run{shell} && !$run{rebuild}) {
unlink "$run{pidfile_home}/$run{pidfile}" if $run{pidfile};
exit
}
+print {$run{LOG}} "iurt: running with pid $$\n";
my $df = df $home;
if ($df->{per} == 100) {
- die "FATAL iurt: not enough space on the filesystem, only $df->{bavail}KB on $home, full at $df->{per}%"
+ die "FATAL iurt: not enough space on the filesystem, only $df->{bavail} KB on $home, full at $df->{per}%"
}
if ($run{shell}) {
@@ -382,7 +383,8 @@ if ($run{shell}) {
add_sudo(\%run, $config, $chroot_tmp, $luser);
if ($run{shell}) {
print {$run{LOG}} "iurt: dumping to a chrooted shell into $chroot_tmp\n";
- exec "sudo chroot $chroot_tmp /bin/su $luser -c bash"
+ exec "sudo chroot $chroot_tmp /bin/su $luser -c bash";
+ die "FATAL iurt: could not exec chroot to $chroot_tmp ($!)"
}
}
@@ -501,6 +503,8 @@ retry:
die;
next
}
+ # This should not be necessairy any more if urpmi *.spec works, but it doesn't
+ #
perform_command(qq{sudo chroot $chroot_tmp su $luser -c "rpm --nodeps -bs /home/$luser/rpm/SPECS/*.spec"},
\%run, $config,
mail => $config->{admin},
@@ -526,7 +530,7 @@ retry:
print {$run{LOG}} "WARNING iurt: urpmi database locked, waiting...\n" if $run{debug};
sleep 30;
$wait_limit++;
- if ($wait_limit > 10) {
+ if ($wait_limit > 8) {
$wait_limit = 0; system(qq{sudo pkill -9 urpmi &>/dev/null})
} },
log => "$local_spool/log/$srpm/",
@@ -588,8 +592,10 @@ retry:
callback => sub {
my ($opt, $output) = @_;
if ($run{stop}) {
- print {$run{LOG}} "iurt: dumping to a chrooted shell into $chroot_tmp\n";
- exec "sudo chroot $chroot_tmp /bin/su $luser -c bash"
+ print {$run{LOG}} "iurt: dumping to a chrooted shell into $chroot_tmp (pid $$)\n";
+ # exec does not work because it seems stdin and out are shared between children
+ system("sudo chroot $chroot_tmp /bin/su $luser -c bash");
+ exit
}
print {$run{LOG}} "iurt: calling callback for $opt->{hash}\n" if $run{debug};
if ($unionfs_tmp && $output =~ /no space left on device/i) {
@@ -1008,7 +1014,7 @@ sub perform_command {
$opt{freq} ||= 24;
print {$run{LOG}} "Timeout $opt{timeout}\n" if $run{verbose} > 2;
# from alarm perldoc
- my $output;
+ my ($output, $comment);
my ($kill, $pipe);
if ($opt{debug}) {
print "Would have rum $command with a timeout of $opt{timeout}\n";
@@ -1023,6 +1029,7 @@ sub perform_command {
if ($opt{log}) {
my $parent_pid = $$;
$pid = fork;
+ #close STDIN; close STDERR;close STDOUT;
my $tot_time;
if (!$pid) {
print {$run{LOG}} "Forking to monitor log size\n" if $run{verbose} > 2;
@@ -1084,19 +1091,20 @@ sub perform_command {
$call_ret == -1 and return 1
}
if ($kill) {
- $output = "Command has been killed after $opt{timeout} seconds: $command\n$output";
+ $comment = "Command has been killed after $opt{timeout} seconds: $command\n";
my ($cmd_to_kill) = $command =~ /sudo(?: chroot \S+)? (.*)/;
clean_process($cmd_to_kill, $run{verbose})
} elsif ($pipe) {
- $output = "Command receives a broken pipe: $command\n$output";
- sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: broken pipe", "$output", 0, 0, $opt{debug_mail});
+ $comment = "Command receives a broken pipe: $command\n";
+ sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: broken pipe", "$comment\n$output", 0, 0, $opt{debug_mail});
} else {
- $output = "Command failed: $command\n$output"
+ $comment = "Command failed: $command\n"
}
- if ($opt{wait_regexp} && $output =~ /$opt{wait_regexp}/) {
+ # Maybe this has to be put before all the commands altering the $output var
+ if ($opt{wait_regexp} && $output =~ /$opt{wait_regexp}/m) {
$opt{wait_callback}(\%opt, $output) if ref $opt{wait_callback};
print {$run->{LOG}} "ERROR iurt: $opt{wait_regexp} !\n";
- sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: could not proceed", "$opt{wait_regexp}\n\n$output", 0, 0, $opt{debug_mail});
+ sendmail($config->{admin}, '' , "$opt{hash} on $run->{my_arch} for $run->{media}: could not proceed", "$opt{wait_regexp}\n\n$comment\n$output", 0, 0, $opt{debug_mail});
if ($opt{die}) {
dump_cache($run);
die "FATAL iurt: $opt{error}."
@@ -1109,18 +1117,18 @@ sub perform_command {
}
if (!$call_ret || $kill || $err || $opt{error_regexp} && $output =~ /$opt{error_regexp}/) {
if ($opt{log} && $config->{log_url}) {
- $output = qq|See $config->{log_url}/$run{distro_tag}/$run{my_arch}/log/$opt{srpm}/\n\n$output|
+ $comment = qq|See $config->{log_url}/$run{distro_tag}/$run{my_arch}/log/$opt{srpm}/\n\n$comment|
}
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} , $output, 0, 0, $opt{debug_mail});
+ sendmail($opt{mail}, $cc, $opt{error} , "$comment\n$output", 0, 0, $opt{debug_mail});
} elsif ($config->{admin}) {
- sendmail($config->{admin}, '' , $opt{error}, $output, 0, 0, $opt{debug_mail});
+ sendmail($config->{admin}, '' , $opt{error}, "$comment\n$output", 0, 0, $opt{debug_mail});
}
}
$cache->{warning}{$opt{hash}}{$opt{mail}}++;
- print {$run->{LOG}} "\n$output\n";
+ print {$run->{LOG}} "\n$comment\n$output\n";
if ($opt{die}) {
dump_cache($run);
die "FATAL iurt: $opt{error}."
@@ -1406,8 +1414,12 @@ sub create_temp_chroot {
$union_id = clean_unionfs($unionfs_dir, $run->{run}, $union_id);
$tmpfs = "$unionfs_dir/tmpfs.$run->{run}.$union_id";
$chroot_tmp = "$unionfs_dir/unionfs.$run->{run}.$union_id";
- mkdir $tmpfs or die "Could not create $tmpfs ($!)";
- mkdir $chroot_tmp or die "Could not create $chroot_tmp ($!)";
+ if (!-d $tmpfs) {
+ mkdir $tmpfs or die "FATAL iurt: Could not create $tmpfs ($!)"
+ }
+ if (! -d $chroot_tmp) {
+ mkdir $chroot_tmp or die "FATAL iurt: Could not create $chroot_tmp ($!)"
+ }
if ($cache->{no_unionfs}{$srpm}) {
$unionfs_tmp = 0;
clean_chroot($chroot_tmp, $run)
@@ -1474,7 +1486,7 @@ sub remove_chroot {
}
} else {
foreach my $user (@{$run->{clean}}) {
- print {$run->{LOG}} "iurt: cleaning old chroot for $user\n";
+ print {$run->{LOG}} "iurt: cleaning old chroot for $user in $dir\n";
$func->("$dir/$user", $prefix)
}
}