aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2006-11-06 13:50:13 +0000
committerFlorent Villard <warly@mandriva.com>2006-11-06 13:50:13 +0000
commit0aa7000627e5b1088a8a2ee75798f17ff0095635 (patch)
tree48fe48d11a77a29ef34182ec17f99585391fdc99
parentf9ffb6a98f5ebf339286138690c820b148fb0f26 (diff)
downloadiurt-0aa7000627e5b1088a8a2ee75798f17ff0095635.tar
iurt-0aa7000627e5b1088a8a2ee75798f17ff0095635.tar.gz
iurt-0aa7000627e5b1088a8a2ee75798f17ff0095635.tar.bz2
iurt-0aa7000627e5b1088a8a2ee75798f17ff0095635.tar.xz
iurt-0aa7000627e5b1088a8a2ee75798f17ff0095635.zip
do not create a log dir for the first srpm; use a more explicit shell in chroot mode
-rwxr-xr-xiurt238
1 files changed, 15 insertions, 23 deletions
diff --git a/iurt2 b/iurt2
index 48a9140..0efe583 100755
--- a/iurt2
+++ b/iurt2
@@ -40,6 +40,7 @@ use Iurt::Urpmi;
use Iurt::Chroot qw(add_local_user create_temp_chroot remove_chroot clean_all_chroot_tmp clean_unionfs check_build_chroot clean_chroot);
use Iurt::Process qw(perform_command clean kill_for_good);
use Iurt::Mail qw(sendmail);
+use Iurt::Util qw(plog_init plog);
use File::NCopy qw(copy);
# I did not manage to make locks work over the network
#use File::lockf;
@@ -48,7 +49,7 @@ use MDK::Common;
use Filesys::Df qw(df);
my $program_name = 'iurt2';
-my $VERSION = '0.5.19';
+my $VERSION = '0.5.21';
# sessing parameters
my $sudo = '/usr/bin/sudo';
my $arg = @ARGV;
@@ -234,6 +235,8 @@ open(my $LOG, ">&STDERR");
$run{LOG} = $LOG;
print "$program_name version $VERSION\n";
+plog_init($program_name, $LOG, $run{verbose});
+
my $todo = parseCommandLine($program_name, \@ARGV, \@params);
@ARGV and usage($program_name, \@params, "@ARGV, too many arguments");
foreach my $t (@$todo) {
@@ -466,7 +469,7 @@ if ($run{shell}) {
add_sudoers(\%run, $chroot_tmp, $luser);
if ($run{shell}) {
plog("dumping to a chrooted shell into $chroot_tmp");
- exec "$sudo chroot $chroot_tmp /bin/su $luser -c bash";
+ exec "$sudo chroot $chroot_tmp /bin/su $luser -c \"PS1='[\[\033[01;33m\]iurt $run{distro} \[\033[00m\]\u@\h \W]\$ ' bash\"";
die "FATAL $program_name: could not exec chroot to $chroot_tmp ($!)"
}
}
@@ -490,8 +493,8 @@ my $s = sub {
dump_cache_par(\%run);
$Data::Dumper::Indent = 0;
$Data::Dumper::Terse = 1;
- print {$run{LOG}} "Running environment:\n", Data::Dumper->Dump([\%run]), "\n\n" if $run{verbose} > 5;
- print {$run{LOG}} "Configuration:\n",Data::Dumper->Dump([$config]),"\n\n";
+ plog(6, "Running environment:\n", Data::Dumper->Dump([\%run]), "\n");
+ plog(0, "Configuration:\n", Data::Dumper->Dump([$config]),"\n");
}
exit
};
@@ -521,7 +524,6 @@ do {
check_version($srpm, \%srpm_version) or next;
if ($run{debug}) { $run{debug}++ == 2 and exit }
$done++;
- mkdir "$local_spool/log/$srpm";
plog("packages $srpm [$done/$to_compile]");
# FIXME unfortunately urpmi stalls quite often
my $retry = 0;
@@ -561,6 +563,8 @@ do {
} elsif (!$ret) {
next
}
+ # only create the log dir for the new srpm
+ mkdir "$local_spool/log/$srpm";
plog(1, "installing build dependencies of $srpm...");
my $path_srpm = "$chroot_tmp/home/$luser/rpm/SRPMS/";
@@ -581,7 +585,7 @@ do {
timeout => 60,
debug_mail => $run{debug},
log => "$local_spool/log/$srpm/"); # or next; As this failed quite often, do not stop
- print {$run{LOG}} "Compiling $srpm\n" if $run{verbose};
+ plog(1, "Compiling $srpm");
my $command = "rpm --rebuild /home/$luser/rpm/SRPMS/$srpm";
if ($run{stop}) {
$urpmi->install_packages('chroot', $chroot_tmp, $local_spool, \%pack_provide, 'configure', "[ADMIN] installation of urpmi and sudo failed in the chroot $run{my_arch}", { check => 1, maintainer => $config->{admin} }, 'urpmi', 'sudo');
@@ -604,7 +608,7 @@ do {
if ($run{stop}) {
plog("dumping to a chrooted shell into $chroot_tmp (pid $$)");
# exec does not work because it seems stdin and out are shared between children
- system("$sudo chroot $chroot_tmp /bin/su $luser -c bash");
+ system("$sudo chroot $chroot_tmp /bin/su $luser -c \"PS1='[\[\033[01;33m\]iurt $run{distro} \[\033[00m\]\u@\h \W]\$ ' bash\"");
exit
}
plog(5, "calling callback for $opt->{hash}");
@@ -722,7 +726,7 @@ process_queue($config, \%run, \@wrong_rpm);
dump_cache_par(\%run);
print {$run{LOG}} "ERROR $program_name: RPM with a wrong SRPM name\n" if @wrong_rpm;
-if (open my $file, ">$local_spool/log/wrong_srpm_names.log") {
+if (@wrong_rpm && open my $file, ">$local_spool/log/wrong_srpm_names.log") {
foreach (@wrong_rpm) {
print $file "$_->[1] -> $_->[0] (", $cache->{rpm_srpm}{$_->[1]},")\n";
}
@@ -750,11 +754,11 @@ exit;
sub clean_all_unionfs {
my ($run, $unionfs_dir) = @_;
- print {$run{LOG}} "Cleaning old unionfs remaining dir in $unionfs_dir\n" if $run{verbose} > 1;
+ plog(2, "Cleaning old unionfs remaining dir in $unionfs_dir");
my $dir;
if (!opendir $dir, $unionfs_dir) {
- print {$run{LOG}} "FATAL $program_name: could not open $unionfs_dir ($!)";
- return
+ plog(0, "FATAL $program_name: could not open $unionfs_dir ($!)");
+ return;
}
foreach (readdir $dir) {
/unionfs\.((?:0\.)?\d+)\.(\d*)$/ or next;
@@ -1177,15 +1181,3 @@ sub check_sudo_access {
0
}
-# Print messages to log file. If two parameters are given, the first
-# one is the log level.
-#
-sub plog {
- if ($#_) {
- print {$run{LOG}} "$program_name: $_[1]\n"
- if ($_[0] >= $run{verbose});
- } else {
- print {$run{LOG}} "$program_name: $_[0]\n";
- }
-}
-