From 60ef896e8f72211ff3d411cfc40a9834c30d42db Mon Sep 17 00:00:00 2001 From: Florent Villard Date: Sat, 7 Jan 2006 10:56:54 +0000 Subject: Better urpmi killing pattern, do not match maintainer on NOT_FOUND, check invalid options --- iurt2 | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/iurt2 b/iurt2 index 4b6a3d2..3ada7c9 100755 --- a/iurt2 +++ b/iurt2 @@ -38,6 +38,7 @@ 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 } } @ARGV; @@ -47,9 +48,9 @@ $distro_tag =~ s,/,-,g; my $my_arch = shift @argv; my $media = shift @argv; my @special_srpm_dir = @argv; -my $urpmi_options = "-v --no-verify-rpm -s --auto "; +my $urpmi_options = "-v --no-verify-rpm -s --auto"; -$my_arch or usage(); +$my_arch or usage("no architecture given"); my $real_arch = `uname -m`; chomp $real_arch; my %arch_comp = ( @@ -84,6 +85,7 @@ $config->{install_chroot_binary} ||= 'install-chroot-tar.sh'; $config->{distribution} ||= 'Mandriva Linux'; $config->{vendor} ||= 'Mandriva'; $config->{basesystem_media} ||= "$config->{repository}/$distro_version/$my_arch/media/main/"; +$config->{all_media} ||= [ 'main', 'contrib' ]; $config->{upload} .= $distro_version; $config->{upload} =~ s/community//g; @@ -149,6 +151,8 @@ my @wrong_rpm; # in that case, @supported_arch may be removed # #foreach my $arch (@{$config->{supported_arch}}) { +# +# We could rely on only parsing the synthesis, hoping that they are correct, however this scan is very fast, so. my $rpms_dir = "$config->{repository}/$distro_version/$my_arch/media/$media/"; print STDERR "iurt: checking current packages in $rpms_dir\n"; opendir my $rpmdir, $rpms_dir or die "Could not open $rpms_dir: $!"; @@ -163,7 +167,7 @@ closedir $rpmdir; my %provides; my %pack_provide; -foreach my $m ('main', 'contrib') { +foreach my $m (@{$config->{all_media}}) { my $synthesis_file = "$config->{repository}/$distro_version/$my_arch/media/$m/media_info/synthesis.hdlist.cz"; if (-f $synthesis_file) { print STDERR "Parsing $synthesis_file\n"; @@ -326,14 +330,14 @@ foreach (my $i ; $i < @todo; $i++) { my $maintainer = `rpmmon -s -p $srpm_name`; my $cc = "$maint{$srpm}, maintainers\@mandriva.com"; chomp $maintainer; - if (!$maintainer) { + if (!$maintainer || $maintainer eq 'NOT_FOUND') { $maintainer = $cc; $cc = 'maintainers@mandriva.com' } #($maintainer, $cc) = ($config->{admin},''); print "Installing build dependencies of $srpm...\n"; # FIXME unfortunately urpmi stalls quite often - if (!clean_urpmi($chroot)) { + if (!clean_urpmi($home)) { dump_cache(); die "FATAL iurt: Could not have urpmi working !" } @@ -361,7 +365,7 @@ foreach (my $i ; $i < @todo; $i++) { $version ||= 1; chomp $other_maint; print "Missing Dep: $missing_deps ($other_maint)\n"; - if ($other_maint) { + 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"; } @@ -516,7 +520,7 @@ sub clean_unionfs { while (check_mounted($d, $t)) { system("sudo fuser -k $d"); print STDERR "iurt: umounting $d\n"; - if (system(qq{sudo umount $d})) { + if (system(qq{sudo umount $d &> /dev/null})) { print STDERR "WARNING iurt: could not umount $d ($!)\n"; $union_id++; return $union_id @@ -682,6 +686,7 @@ sub perform_command { die unless $@ eq "alarm\n"; # propagate unexpected errors return 0 } else { + my $err = $?; if ($kill) { $output = "Command has been killed after $opt{timeout} seconds: $command\n$output" } else { @@ -700,7 +705,7 @@ sub perform_command { } return 0 } - if ($? || $opt{error_regexp} && $output =~ /$opt{error_regexp}/) { + if ($err || $opt{error_regexp} && $output =~ /$opt{error_regexp}/) { if ($opt{mail} && $config->{sendmail}) { if (! $cache->{warning}{$opt{hash}}{$opt{mail}} % $opt{freq}) { sendmail($opt{mail}, $opt{cc} , $opt{error} , $output, 0, 0, $opt{debug_mail}); -- cgit v1.2.1