From a3f9dac6bfb95627b67eeb569c09256b7dd142d9 Mon Sep 17 00:00:00 2001 From: Florent Villard Date: Tue, 31 Jan 2006 16:40:01 +0000 Subject: verbose level to limit output messages; fix unionfs cleaning for user created unionfs dir --- iurt2 | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/iurt2 b/iurt2 index 7222dc4..73af1fa 100755 --- a/iurt2 +++ b/iurt2 @@ -47,9 +47,12 @@ $run{todo} = [ ]; [ "", "cache", 0, "", "Use the global cache file", sub { $run{cache} = 1 }, "Activating cache use" ], + [ "", "copy_srpm", 0, "", + "Copy also the regenerated SRPM", + sub { $run{copy_srpm} = 1 }, "Activating the copy_srpm mode" ], [ "c", "chroot", 0, "", "Check chroot and update it if needed", - sub { $run{chroot} = 1 }, "Activating debug mode" ], + sub { $run{chroot} = 1 }, "Activating chroot updating" ], [ "", "config", 2, " ", "Override a configuration file variable", sub { my ($key, $value) = @_; $run{config}{$key} = $value }, "Overriding configuration variable" ], @@ -70,7 +73,7 @@ $run{todo} = [ ]; print *{$run{LOG}}, "command line: @ARGV\n"; 1 }, "Log file" ], - [ "m", "media", -1, "", + [ "m", "media", -1, "", "Media to rebuild", sub { ($run{media}) = @_; 1 }, "Adding a media to rebuild" ], [ "r", "rebuild", -2, " ... ", @@ -83,7 +86,9 @@ $run{todo} = [ ]; if (m,(.*/)([^/]*.src.rpm)$, && -f $_) { push @{$run{todo}}, [ $1, $2 ]; print {$run{LOG}} "iurt: force build for $2 (from $1)\n"; - 0 + } elsif (m,([^/]*.src.rpm)$, && -f $_) { + push @{$run{todo}}, [ './', $1 ]; + print {$run{LOG}} "iurt: force build for $1\n"; } else { die "FATAL iurt: $_ does not seems to be a SRPM\n" } @@ -313,9 +318,9 @@ retry: # if the previous package has been built without unionfs, chroot need to be cleaned clean_chroot($chroot, \%run) if !$unionfs_tmp; $unionfs_tmp = 1; - system(qq{sudo mount -t tmpfs none $tmpfs}) and die "FATAL iurt: could not mount $tmpfs ($!)"; - system(qq{sudo mount -o dirs=$tmpfs=rw:$home/chroot$debug_tag=ro -t unionfs none $chroot}) and die "FATAL iurt: could not mount $tmpfs and $home/chroot with unionfs ($!)"; - system("sudo mount -t proc none $chroot/proc") and die "FATAL iurt: could not mount /proc in the chroot $chroot."; + system(qq{sudo mount -t tmpfs none $tmpfs &>/dev/null}) and die "FATAL iurt: could not mount $tmpfs ($!)"; + system(qq{sudo mount -o dirs=$tmpfs=rw:$home/chroot$debug_tag=ro -t unionfs none $chroot &>/dev/null}) and die "FATAL iurt: could not mount $tmpfs and $home/chroot with unionfs ($!)"; + system("sudo mount -t proc none $chroot/proc &>/dev/null") and die "FATAL iurt: could not mount /proc in the chroot $chroot."; } } else { print {$run{LOG}} "iurt: installing a new chroot for $srpm in $chroot\n" if $run{verbose} > 1; @@ -367,7 +372,7 @@ retry: debug_mail => $run{debug}, error_regexp => 'cannot be installed', wait_regexp => 'database locked', - wait_callback => sub { $wait_limit++; if ($wait_limit > 10) { $wait_limit = 0; system(qq{sudo pkill -9 urpmi}) } }, + wait_callback => sub { $wait_limit++; if ($wait_limit > 10) { $wait_limit = 0; system(qq{sudo pkill -9 urpmi &>/dev/null}) } }, log => "$local_spool/log/", callback => sub { my ($opt, $output) = @_; @@ -402,7 +407,7 @@ retry: timeout => 60, debug_mail => $run{debug}, log => "$local_spool/log/"); # or next; As this failed quite often, do not stop - print {$run{LOG}} "Compiling $srpm\n" if $run{verbose} > 1; + print {$run{LOG}} "Compiling $srpm\n" if $run{verbose}; if (!perform_command(qq{TMP=/home/builder/tmp/ sudo chroot $chroot /bin/su builder -c "rpm --rebuild /home/builder/rpm/SRPMS/$srpm"}, \%run, $config, mail => $maintainer, @@ -466,8 +471,11 @@ retry: exit } else { print {$run{LOG}} "iurt: build successful, copying packages to $local_spool.\n"; - system("cp $chroot/home/builder/rpm/RPMS/*/*.rpm $local_spool") and print {$run{LOG}} "ERROR: could not copy rpm files from $chroot/home/builder/rpm/RPMS/ to $local_spool ($!)\n"; - process_queue($config, \%run, \@wrong_rpm) + system("cp $chroot/home/builder/rpm/RPMS/*/*.rpm $local_spool &>/dev/null") and print {$run{LOG}} "ERROR: could not copy rpm files from $chroot/home/builder/rpm/RPMS/ to $local_spool ($!)\n"; + if ($run{copy_srpm}) { + system("cp $chroot/home/builder/rpm/SRPMS/$srpm $local_spool &>/dev/null") and print {$run{LOG}} "ERROR: could not copy $srpm from $chroot/home/builder/rpm/SRPMS/ to $local_spool ($!)\n"; + } + process_queue($config, \%run, \@wrong_rpm, 1) } } @@ -518,7 +526,7 @@ sub clean_all_unionfs { print {$run{LOG}} "Cleaning old unionfs remaining dir in $unionfs_dir\n" if $run{verbose} > 1; opendir my $dir, $unionfs_dir or die "FATAL iurt: could not open $unionfs_dir ($!)"; foreach (readdir $dir) { - /unionfs\.(\d+)\.(\d+)/ or next; + /unionfs\.((?:0.)\d+)\.(\d+)$/ or next; clean_unionfs($unionfs_dir, $1, $2); } closedir $dir @@ -547,7 +555,7 @@ sub clean_chroot { die => 1); dump_rpmmacros("$chroot/home/builder/.rpmmacros") or return; - system("sudo mount none -t proc $chroot/proc") and return; + system("sudo mount none -t proc $chroot/proc &>/dev/null") and return; 1 } @@ -566,7 +574,7 @@ sub clean { my $ps; my $i; while ($ps = `$cmd "$var"`) { - system(qq{$kill_cmd "$var"}); + system(qq{$kill_cmd "$var" &>/dev/null}); sleep 1; $ps =~ s/\n/,/g; print {$run{LOG}} "Trying to remove previous blocked processes for $var ($ps)\n" if $verbose > 1; @@ -588,7 +596,7 @@ sub clean_unionfs { my $d = "$unionfs_dir/$t.$run.$union_id"; my $last; while (check_mounted($d, $t)) { - system("sudo fuser -k $d"); + system("sudo fuser -k $d &> /dev/null"); print {$run{LOG}} "iurt: umounting $d\n" if $run{verbose} > 2; if (system(qq{sudo umount $d &> /dev/null})) { print {$run{LOG}} "WARNING iurt: could not umount $d ($!)\n" if $run{verbose} > 1; @@ -641,13 +649,15 @@ sub check_needed { } sub process_queue { - my ($config, $run, $wrong_rpm) = @_; - return if !$run->{upload}; + my ($config, $run, $wrong_rpm, $quiet) = @_; + return if !$run->{upload} && $quiet; my $dir = "$config->{local_upload}/iurt/$run->{distro_tag}/$run->{my_arch}"; opendir my $rpmdir, $dir or next; foreach my $rpm (readdir $rpmdir) { my ($rarch, $srpm) = update_srpm($dir, $rpm, $wrong_rpm); $rarch or next; + print {$run{LOG}} "iurt: $rpm\n"; + next if !$run->{upload}; # recheck if the package has not been uploaded in the meantime my $rpms_dir = "$config->{repository}/$run->{distro}/$run->{my_arch}/media/$run->{media}/"; if (! -f "$rpms_dir/$rpm") { @@ -829,7 +839,7 @@ sub kill_for_good { sub check_chroot { my ($chroot, $chroot_tar, $run) = @_; print {$run{LOG}} "iurt: checking basesystem tar\n" if $run{verbose}; - system(qq{sudo pkill -9 -u root -f "urpmi $urpmi_options --root $chroot"}); + system(qq{sudo pkill -9 -u root -f "urpmi $urpmi_options --root $chroot" &> /dev/null}); clean_chroot($chroot, $run, 1) or die "FATAL iurt: Could no prepare initial chroot"; perform_command("sudo $config->{install_chroot_binary} cooker $config->{basesystem_media} $chroot_tar $chroot 501 basesystem tar rpm-build", $run, $config, -- cgit v1.2.1