From 2b33659766debe3a7ccf79fdcada539cacddfd20 Mon Sep 17 00:00:00 2001 From: Florent Villard Date: Wed, 18 Jan 2006 15:40:25 +0000 Subject: proc was not correctly mounted; add a no_mail config option, add a force_build option to force srpm build --- iurt2 | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/iurt2 b/iurt2 index 12fee78..f0fbd7a 100755 --- a/iurt2 +++ b/iurt2 @@ -35,13 +35,26 @@ use File::NCopy qw(copy); use MIME::Words qw(encode_mimewords); use Fcntl ':flock'; -my ($debug, $unionfs, $nocheckchroot); +# maybe time to switch to mkcd::parse_command_line +my ($debug, $unionfs, $nocheckchroot, $force_build, @todo); my @argv = grep { - if (/--debug/) { $debug = 1; 0 } - elsif (/--unionfs/) { $unionfs = 1; 0 } - elsif (/--nocheckchroot/) { $nocheckchroot = 1; 0 } - elsif (/--./) { usage("$_ is an unknown option") } - else { 1 } + if ($force_build && !/--/) { + if (m,(.*/)([^/]*.src.rpm)$, && -f $_) { + push @todo, [ $1, $2 ]; + print STDERR "iurt: force build for $2 (from $1)\n"; + 0 + } else { + die "FATAL iurt: $_ does not seems to be a SRPM\n" + } + } else { + $force_build = 0; + if (/--debug/) { $debug = 1; 0 } + elsif (/--unionfs/) { $unionfs = 1; 0 } + elsif (/--nocheckchroot/) { $nocheckchroot = 1; 0 } + elsif (/--force_build/) { $force_build = 1; 0 } + elsif (/--./) { usage("$_ is an unknown option") } + else { 1 } + } } @ARGV; my $distro_version = shift @argv; @@ -52,7 +65,7 @@ my $media = shift @argv; my @special_srpm_dir = @argv; my $urpmi_options = "-v --no-verify-rpm --nolock --auto"; -$my_arch or usage("no architecture given"); +$my_arch or usage("no architecture given (media $media, my_arch $my_arch, todo @todo)"); my $real_arch = `uname -m`; chomp $real_arch; my %arch_comp = ( @@ -90,6 +103,7 @@ $config->{basesystem_media} ||= "$config->{repository}/$distro_version/$my_arch/ $config->{all_media} ||= [ 'main', 'contrib' ]; $config->{log_size_limit} ||= '100M'; $config->{log_size_date} ||= '30'; +$config->{no_mail} ||= { }; $config->{upload} .= $distro_version; $config->{upload} =~ s/community//g; @@ -201,7 +215,6 @@ foreach my $m (@{$config->{all_media}}) { my %maint; -my @todo; -d "$config->{upload}/build/$my_arch" or mkdir "$config->{upload}/build/$my_arch"; my $clean; my %rep; @@ -212,7 +225,7 @@ my %done_rpm; # my $to_compile; foreach my $dir ("$config->{repository}/$distro_version/SRPMS/$media/", @special_srpm_dir) { - print "iurt: checking SRPMS dir $dir\n"; + print STDERR "iurt: checking SRPMS dir $dir\n"; opendir my $rpmdir, $dir or next; foreach my $srpm (readdir $rpmdir) { # this is for the output of the new svn system @@ -289,12 +302,9 @@ if (!$nocheckchroot) { debug_mail => $debug, die => 1); -} else { - dump_rpmmacros("$chroot/home/builder/.rpmmacros") or die "FATAL iurt: could not dump rpm macros" } +dump_rpmmacros("$chroot/home/builder/.rpmmacros") or die "FATAL iurt: could not dump rpm macros"; if ($unionfs) { - dump_rpmmacros("$chroot/home/builder/.rpmmacros") or return; - system("sudo mount none -t proc $chroot/proc") and die "FATAL iurt: could not mount /proc in the chroot."; $unionfs_dir = "$config->{local_home}/iurt_unionfs$debug_tag"; -d $unionfs_dir or mkdir $unionfs_dir } @@ -346,6 +356,7 @@ foreach (my $i ; $i < @todo; $i++) { mkdir $chroot or die "Could not create $chroot ($!)"; 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=ro -t unionfs none $chroot}) and die "FATAL iurt: could not mount $tmpfs and $home/chroot with unionfs ($!)"; + system("sudo mount none -t proc $chroot/proc") and die "FATAL iurt: could not mount /proc in the chroot."; } else { print STDERR "iurt: installing a new chroot for $srpm in $chroot\n"; clean_chroot($chroot) @@ -385,7 +396,7 @@ foreach (my $i ; $i < @todo; $i++) { $version ||= 0; chomp $other_maint; print "missing dep: $missing_deps ($other_maint)\n"; - if ($other_maint && $other_maint ne 'not_found') { + if ($other_maint && $other_maint ne 'NOT_FOUND') { $opt->{mail} = $other_maint; $opt->{error} = "[missing] $missing_deps, needed to build $srpm, is not available on $my_arch"; } @@ -515,6 +526,8 @@ sub usage { --debug: Compile one package in debug mode (do not send mail, create chroot_debug directory). This mode can be used on a system where a iurt is already running. + --force_build ... + list of extra srpm to build --unionfs: Use a tmpfs mounted with the chroot via unionfs as build chroot. This is much faster but you need some memory. --nocheckchroot: start building without the inital check of the chroot. @@ -573,6 +586,7 @@ sub clean { sub clean_unionfs { my ($unionfs_dir, $run, $union_id) = @_; + system("sudo umount $unionfs_dir/unionfs.$run.$union_id/proc") and print STDERR "ERROR iurt: could not umount $unionfs_dir/unionfs.$run.$union_id/proc\n"; foreach my $t ("unionfs",'tmpfs') { # unfortunately quite oftem the unionfs is busy and could not be unmounted my $d = "$unionfs_dir/$t.$run.$union_id"; @@ -663,6 +677,7 @@ sub update_srpm { sub dump_cache { my $filename = $cachefile; + return if $debug; open my $file, ">$filename.tmp" or die "FATAL iurt dump_cache: cannot open $filename.tmp"; flock($file,LOCK_EX); seek($file, 0, 2); @@ -773,7 +788,7 @@ sub perform_command { return 0 } if ($err || $opt{error_regexp} && $output =~ /$opt{error_regexp}/) { - if ($opt{mail} && $config->{sendmail}) { + if ($opt{mail} && $config->{sendmail} && !$config->{no_mail}{$opt{mail}}) { if (! ($cache->{warning}{$opt{hash}}{$opt{mail}} % $opt{freq})) { sendmail($opt{mail}, $opt{cc} , $opt{error} , $output, 0, 0, $opt{debug_mail}); } elsif ($config->{admin}) { -- cgit v1.2.1