aboutsummaryrefslogtreecommitdiffstats
path: root/iurt
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2012-12-10 09:38:14 +0000
committerPascal Terjan <pterjan@mageia.org>2012-12-10 09:38:14 +0000
commitb1cd4fbff3d5c841daaab0447c4cd312e2f7913b (patch)
tree53271180e63299e8a099610c266d462805c261db /iurt
parent60979c8038010f5b5b7f32e9c3b387230a7ffeb7 (diff)
downloadiurt-b1cd4fbff3d5c841daaab0447c4cd312e2f7913b.tar
iurt-b1cd4fbff3d5c841daaab0447c4cd312e2f7913b.tar.gz
iurt-b1cd4fbff3d5c841daaab0447c4cd312e2f7913b.tar.bz2
iurt-b1cd4fbff3d5c841daaab0447c4cd312e2f7913b.tar.xz
iurt-b1cd4fbff3d5c841daaab0447c4cd312e2f7913b.zip
Re-indent
Diffstat (limited to 'iurt')
-rwxr-xr-xiurt448
1 files changed, 224 insertions, 224 deletions
diff --git a/iurt b/iurt
index 885162a..a07809a 100755
--- a/iurt
+++ b/iurt
@@ -817,241 +817,241 @@ my $_s = sub {
$run{main} = 1;
sub rebuild_one {
- my ($dir, $srpm, $status) = @_;
- # CM: Set argv[0] (in the C sense) to something we can easily spot and
- # understand in process list
- $0 = "Iurt: $run{distro_tag} $run{my_arch} $run{media} $srpm";
-
- $status or return;
- $done{$srpm} and return;
- $done{$srpm} = 1;
- check_version(\%run, $srpm, \%srpm_version) or return;
- if ($run{debug}) { $run{debug}++ == 2 and exit() }
- $done++;
- plog('NOTIFY', "Build package $srpm [$done/$to_compile]");
- # When rebuilding all the media, src.rpm can be removed from mirror before we work on them
- unless (-f "$dir/$srpm") {
- $cache->{failure}{$srpm} = 1;
- $run{status}{$srpm} = 'missing';
- dump_cache_par(\%run);
- dump_status($local_spool, \%run);
- return;
- }
- # FIXME unfortunately urpmi stalls quite often
- my $retry = 0;
-
- # current rpm is sometime segfaulting, and iurt is them blocked
- # and cannot
- #
- # $cache->{failure}{$srpm} = 1;
- # dump_cache(\%run);
+ my ($dir, $srpm, $status) = @_;
+ # CM: Set argv[0] (in the C sense) to something we can easily spot and
+ # understand in process list
+ $0 = "Iurt: $run{distro_tag} $run{my_arch} $run{media} $srpm";
+
+ $status or return;
+ $done{$srpm} and return;
+ $done{$srpm} = 1;
+ check_version(\%run, $srpm, \%srpm_version) or return;
+ if ($run{debug}) { $run{debug}++ == 2 and exit() }
+ $done++;
+ plog('NOTIFY', "Build package $srpm [$done/$to_compile]");
+ # When rebuilding all the media, src.rpm can be removed from mirror before we work on them
+ unless (-f "$dir/$srpm") {
+ $cache->{failure}{$srpm} = 1;
+ $run{status}{$srpm} = 'missing';
+ dump_cache_par(\%run);
+ dump_status($local_spool, \%run);
+ return;
+ }
+ # FIXME unfortunately urpmi stalls quite often
+ my $retry = 0;
+
+ # current rpm is sometime segfaulting, and iurt is them blocked
+ # and cannot
+ #
+ # $cache->{failure}{$srpm} = 1;
+ # dump_cache(\%run);
retry:
- $urpmi->clean_urpmi_process;
+ $urpmi->clean_urpmi_process;
- if (!$run{use_old_chroot}) {
- $chroot_tmp = create_temp_chroot(\%run, $config,
- $chroot_tmp, $chroot_ref) or return;
- }
+ if (!$run{use_old_chroot}) {
+ $chroot_tmp = create_temp_chroot(\%run, $config,
+ $chroot_tmp, $chroot_ref) or return;
+ }
- if (!$urpmi->urpmi_command($chroot_tmp)) {
- plog('DEBUG', "Creating chroot failed.\nCommand was: $chroot_tmp");
- return;
+ if (!$urpmi->urpmi_command($chroot_tmp)) {
+ plog('DEBUG', "Creating chroot failed.\nCommand was: $chroot_tmp");
+ return;
+ }
+ $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or return;
+ my ($maintainer, $cc);
+ if (!$run{warn}) {
+ ($maintainer) = get_maint(\%run, $srpm);
+ $cc = $maint{$srpm};#, maintainers\@mandriva.com";
+ chomp $maintainer;
+ if (!$maintainer || $maintainer eq 'NOT_FOUND') {
+ $maintainer = $cc;
+ #$cc = 'maintainers@mandriva.com'
}
- $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or return;
- my ($maintainer, $cc);
- if (!$run{warn}) {
- ($maintainer) = get_maint(\%run, $srpm);
- $cc = $maint{$srpm};#, maintainers\@mandriva.com";
- chomp $maintainer;
- if (!$maintainer || $maintainer eq 'NOT_FOUND') {
- $maintainer = $cc;
- #$cc = 'maintainers@mandriva.com'
- }
+ }
+ #($maintainer, $cc) = ($config->{admin},'');
+
+ plog('DEBUG', "creating user $luser in chroot");
+ add_local_user($chroot_tmp, \%run, $config, $luser, $run{uid}) or return;
+
+ my $old_srpm = $srpm;
+ my ($ret, $spec);
+ ($ret, $srpm, $spec) = $urpmi->recreate_srpm(\%run, $config,
+ $chroot_tmp, $dir, $srpm, $luser, $retry);
+ if ($ret == -1) {
+ if (create_build_chroot($run{chroot_path}, $run{chroot_ref}, \%run, $config)) {
+ $retry = 1;
+ goto retry;
+ } else {
+ $ret = 0;
}
- #($maintainer, $cc) = ($config->{admin},'');
-
- plog('DEBUG', "creating user $luser in chroot");
- add_local_user($chroot_tmp, \%run, $config, $luser, $run{uid}) or return;
-
- my $old_srpm = $srpm;
- my ($ret, $spec);
- ($ret, $srpm, $spec) = $urpmi->recreate_srpm(\%run, $config,
- $chroot_tmp, $dir, $srpm, $luser, $retry);
- if ($ret == -1) {
- if (create_build_chroot($run{chroot_path}, $run{chroot_ref}, \%run, $config)) {
- $retry = 1;
- goto retry;
- } else {
- $ret = 0;
- }
- }
- if (!$ret) {
- # CM: experimental: fail if we can't regenerate the srpm
- # This should eliminate bouncers that block the input queue
- #
- $srpm = $old_srpm;
- $cache->{failure}{$srpm} = 1;
- $run{status}{$srpm} = 'recreate_srpm_failure';
- dump_cache_par(\%run);
- dump_status($local_spool, \%run);
- return;
- }
-
- (my $log_dirname = $srpm) =~ s/.*:(.*)\.src.rpm/$1/;
- my $log_dir = "$local_spool/log/$log_dirname/";
-
- # only create the log dir for the new srpm
- mkdir $log_dir;
- -d $log_dir or die "FATAL: could not create $log_dir (check permissions and group ownerships)";
+ }
+ if (!$ret) {
+ # CM: experimental: fail if we can't regenerate the srpm
+ # This should eliminate bouncers that block the input queue
+ #
+ $srpm = $old_srpm;
+ $cache->{failure}{$srpm} = 1;
+ $run{status}{$srpm} = 'recreate_srpm_failure';
+ dump_cache_par(\%run);
+ dump_status($local_spool, \%run);
+ return;
+ }
+
+ (my $log_dirname = $srpm) =~ s/.*:(.*)\.src.rpm/$1/;
+ my $log_dir = "$local_spool/log/$log_dirname/";
+
+ # only create the log dir for the new srpm
+ mkdir $log_dir;
+ -d $log_dir or die "FATAL: could not create $log_dir (check permissions and group ownerships)";
- plog('INFO', "Install build dependencies");
- my $path_srpm = "$chroot_tmp/home/$luser/rpmbuild/SRPMS/";
+ plog('INFO', "Install build dependencies");
+ my $path_srpm = "$chroot_tmp/home/$luser/rpmbuild/SRPMS/";
- # on x86_64 the rpm database is getting corrupted and sometimes
- # rpm do not found anymore installed packages, retrying several
- # time to be sure something is really broken
-
- my $ok = $urpmi->install_packages($srpm, $chroot_tmp, $local_spool, \%pack_provide, 'install_deps', "[REBUILD] install of build dependencies of $srpm failed on $run{my_arch}", { maintainer => $maintainer }, "$path_srpm/$srpm");
- if (!$ok) {
- $run{status}{$srpm} ||= 'install_deps_failure';
- return;
- }
-
- # try to workarround the rpm -qa db4 error(2) from dbcursor->c_get:
- # No such file or directory
- # system("sudo chroot $chroot_tmp rm -rf /var/lib/rpm/__db* &> /dev/null");
- # system("$sudo chroot $chroot_tmp rpm --rebuilddb &> /dev/null");
-
- perform_command("rpm --root $chroot_tmp -qa | sort",
- \%run, $config, $cache,
- logname => "rpm_qa",
- hash => "rpm_qa_$srpm",
- timeout => 60,
- debug_mail => $run{debug},
- log => $log_dir); # or next; As this failed quite often, do not stop
- plog('NOTIFY', "Building $srpm");
- my $command = "rpmbuild --rebuild $run{with_flags} /home/$luser/rpmbuild/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');
- add_sudoers($chroot_tmp, $luser);
- $command = "rpmbuild -b$run{stop} /home/$luser/rpmbuild/SPECS/$spec";
- }
-
- my ($srpm_name) = $srpm =~ /(?:.*:)?(.*)-[^-]+-[^-]+\.src\.rpm$/;
- my $icecream;
- if ($run{icecream}) {
- $icecream = "RPM_BUILD_NCPUS=$run{icecream}";
- }
-
- if (!perform_command(qq(chroot $chroot_tmp /bin/su - $luser -c "TMP=/home/$luser/tmp/ $icecream $command"),
- \%run, $config, $cache,
- use_iurt_root_command => 1,
- mail => $maintainer,
- error => "[REBUILD] $srpm from $run{distro_tag} does not build correctly on $run{my_arch}",
- logname => "build",
- hash => "build_$srpm",
- timeout => $config->{build_timeout}{$srpm_name} || $config->{build_timeout}{default},
- stalled_timeout => $config->{build_stalled_timeout}{$srpm_name} || $config->{build_stalled_timeout}{default},
- srpm => $srpm,
- debug_mail => $run{debug},
- cc => $cc,
- log => $log_dir,
- callback => sub {
- my ($opt, $output) = @_;
- 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, $config->{iurt_root_command}, '--chroot', $chroot_tmp, '/bin/su', '-', $luser, '-c', "$config->{prompt} bash");
- exit();
- }
- plog('DEBUG', "calling callback for $opt->{hash}");
- if ($output =~ m!/bin/ld: cannot find -l(\S*)|configure.*[^W]error.* (?:-l(\S+)|(\S+) includes)!) {
- my $missing = $1;
- my @rpm = find_provides(\%pack_provide, $missing);
- plog(5, "likely @rpm ($missing-devel) needed to rebuilt $srpm is not in build_requires");
- if ($maintainer ne 'NOT_FOUND') {
- $opt->{mail} = $maintainer;
- #$opt->{mail} .= ", other_maint";
- }
- if (!$opt->{mail}) {
- $opt->{mail} = "Maintainer not found <$config->{admin}>";
- }
- if (@rpm > 1) {
- $opt->{error} = "[MISSING_BUILD_REQUIRES_TAG] one of @rpm ($missing-devel), needed to build $srpm, is not in buildrequires";
- } elsif (@rpm == 1) {
- $opt->{error} = "[MISSING_BUILD_REQUIRES_TAG] @rpm ($missing-devel), needed to build $srpm, is not in buildrequires";
- } else {
- $opt->{error} = "[MISSING_BUILD_REQUIRES_TAG] $missing-devel, needed to build $srpm, is not in buildrequires";
- }
- $cache->{buildrequires}{$srpm}{$missing} = \@rpm;
- return;
- }
- 1;
- },
- freq => 1)) {
-
- $cache->{failure}{$srpm} = 1;
- $run{status}{$srpm} = 'build_failure';
- # 20060615
- dump_cache_par(\%run);
- dump_status($local_spool, \%run);
- return;
- }
-
- # do some cleaning if the compilation is successful
- delete $cache->{needed}{$srpm} if defined $cache->{needed}{$srpm};
- delete $cache->{buildrequires}{$srpm} if defined $cache->{buildrequires}{$srpm};
- # FIXME It seems the glob is not correctly expanded any more, so listing the directory content to do so
- opendir my $binfh, "$chroot_tmp/home/$luser/rpmbuild/RPMS/";
- my @packages;
- foreach my $bindir (readdir $binfh) {
- -d "$chroot_tmp/home/$luser/rpmbuild/RPMS/$bindir" or return;
- opendir my $rpmfh, "$chroot_tmp/home/$luser/rpmbuild/RPMS/$bindir";
- push @packages, map { "$chroot_tmp/home/$luser/rpmbuild/RPMS/$bindir/$_" } grep { !/src\.rpm$/ && /\.rpm$/ } readdir $rpmfh;
- }
-
- # 20060810 warly We should fail here, but rpm is currently
- # segfaulting when trying to install packages
+ # on x86_64 the rpm database is getting corrupted and sometimes
+ # rpm do not found anymore installed packages, retrying several
+ # time to be sure something is really broken
+
+ my $ok = $urpmi->install_packages($srpm, $chroot_tmp, $local_spool, \%pack_provide, 'install_deps', "[REBUILD] install of build dependencies of $srpm failed on $run{my_arch}", { maintainer => $maintainer }, "$path_srpm/$srpm");
+ if (!$ok) {
+ $run{status}{$srpm} ||= 'install_deps_failure';
+ return;
+ }
- if ($config->{check_binary_file}) {
- $urpmi->install_packages($srpm, $chroot_tmp, $local_spool, \%pack_provide, 'binary_test', "[REBUILD] binaries packages generated from $srpm do not install correctly", { maintainer => $maintainer } ,@packages) or return;
- } else {
- my $successfile = "$local_spool/log/$srpm/binary_test_$srpm-1.log";
- open my $f, ">$successfile";
- print $f "$srpm build ok";
+ # try to workarround the rpm -qa db4 error(2) from dbcursor->c_get:
+ # No such file or directory
+ # system("sudo chroot $chroot_tmp rm -rf /var/lib/rpm/__db* &> /dev/null");
+ # system("$sudo chroot $chroot_tmp rpm --rebuilddb &> /dev/null");
+
+ perform_command("rpm --root $chroot_tmp -qa | sort",
+ \%run, $config, $cache,
+ logname => "rpm_qa",
+ hash => "rpm_qa_$srpm",
+ timeout => 60,
+ debug_mail => $run{debug},
+ log => $log_dir); # or next; As this failed quite often, do not stop
+ plog('NOTIFY', "Building $srpm");
+ my $command = "rpmbuild --rebuild $run{with_flags} /home/$luser/rpmbuild/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');
+ add_sudoers($chroot_tmp, $luser);
+ $command = "rpmbuild -b$run{stop} /home/$luser/rpmbuild/SPECS/$spec";
+ }
+
+ my ($srpm_name) = $srpm =~ /(?:.*:)?(.*)-[^-]+-[^-]+\.src\.rpm$/;
+ my $icecream;
+ if ($run{icecream}) {
+ $icecream = "RPM_BUILD_NCPUS=$run{icecream}";
+ }
+
+ if (!perform_command(qq(chroot $chroot_tmp /bin/su - $luser -c "TMP=/home/$luser/tmp/ $icecream $command"),
+ \%run, $config, $cache,
+ use_iurt_root_command => 1,
+ mail => $maintainer,
+ error => "[REBUILD] $srpm from $run{distro_tag} does not build correctly on $run{my_arch}",
+ logname => "build",
+ hash => "build_$srpm",
+ timeout => $config->{build_timeout}{$srpm_name} || $config->{build_timeout}{default},
+ stalled_timeout => $config->{build_stalled_timeout}{$srpm_name} || $config->{build_stalled_timeout}{default},
+ srpm => $srpm,
+ debug_mail => $run{debug},
+ cc => $cc,
+ log => $log_dir,
+ callback => sub {
+ my ($opt, $output) = @_;
+ 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, $config->{iurt_root_command}, '--chroot', $chroot_tmp, '/bin/su', '-', $luser, '-c', "$config->{prompt} bash");
+ exit();
+ }
+ plog('DEBUG', "calling callback for $opt->{hash}");
+ if ($output =~ m!/bin/ld: cannot find -l(\S*)|configure.*[^W]error.* (?:-l(\S+)|(\S+) includes)!) {
+ my $missing = $1;
+ my @rpm = find_provides(\%pack_provide, $missing);
+ plog(5, "likely @rpm ($missing-devel) needed to rebuilt $srpm is not in build_requires");
+ if ($maintainer ne 'NOT_FOUND') {
+ $opt->{mail} = $maintainer;
+ #$opt->{mail} .= ", other_maint";
+ }
+ if (!$opt->{mail}) {
+ $opt->{mail} = "Maintainer not found <$config->{admin}>";
+ }
+ if (@rpm > 1) {
+ $opt->{error} = "[MISSING_BUILD_REQUIRES_TAG] one of @rpm ($missing-devel), needed to build $srpm, is not in buildrequires";
+ } elsif (@rpm == 1) {
+ $opt->{error} = "[MISSING_BUILD_REQUIRES_TAG] @rpm ($missing-devel), needed to build $srpm, is not in buildrequires";
+ } else {
+ $opt->{error} = "[MISSING_BUILD_REQUIRES_TAG] $missing-devel, needed to build $srpm, is not in buildrequires";
+ }
+ $cache->{buildrequires}{$srpm}{$missing} = \@rpm;
+ return;
+ }
+ 1;
+ },
+ freq => 1)) {
+
+ $cache->{failure}{$srpm} = 1;
+ $run{status}{$srpm} = 'build_failure';
+ # 20060615
+ dump_cache_par(\%run);
+ dump_status($local_spool, \%run);
+ return;
+ }
+
+ # do some cleaning if the compilation is successful
+ delete $cache->{needed}{$srpm} if defined $cache->{needed}{$srpm};
+ delete $cache->{buildrequires}{$srpm} if defined $cache->{buildrequires}{$srpm};
+ # FIXME It seems the glob is not correctly expanded any more, so listing the directory content to do so
+ opendir my $binfh, "$chroot_tmp/home/$luser/rpmbuild/RPMS/";
+ my @packages;
+ foreach my $bindir (readdir $binfh) {
+ -d "$chroot_tmp/home/$luser/rpmbuild/RPMS/$bindir" or return;
+ opendir my $rpmfh, "$chroot_tmp/home/$luser/rpmbuild/RPMS/$bindir";
+ push @packages, map { "$chroot_tmp/home/$luser/rpmbuild/RPMS/$bindir/$_" } grep { !/src\.rpm$/ && /\.rpm$/ } readdir $rpmfh;
+ }
+
+ # 20060810 warly We should fail here, but rpm is currently
+ # segfaulting when trying to install packages
+
+ if ($config->{check_binary_file}) {
+ $urpmi->install_packages($srpm, $chroot_tmp, $local_spool, \%pack_provide, 'binary_test', "[REBUILD] binaries packages generated from $srpm do not install correctly", { maintainer => $maintainer } ,@packages) or return;
+ } else {
+ my $successfile = "$local_spool/log/$srpm/binary_test_$srpm-1.log";
+ open my $f, ">$successfile";
+ print $f "$srpm build ok";
+ }
+
+ $run{status}{$srpm} = 'ok';
+ delete $cache->{failure}{$srpm} if defined $cache->{failure}{$srpm};
+ if ($run{debug}) {
+ plog("debug mode, skip other packages");
+ exit();
+ } elsif ($run{group}) {
+ # we should not move the package until they are all compiled
+ plog("group mode, keep packages for local media ($srpm is done $done)");
+ $run{done}{$srpm} = $done;
+ $urpmi->add_to_local_media($chroot_tmp, $srpm, $luser);
+ } else {
+ # drop packages and logs if we only want failure logs
+ if ($run{delete_on_success}) {
+ system("rm -rf $local_spool/log/$srpm/");
+ } else {
+ plog('OK', "build successful, copying packages to $local_spool.");
+
+ system("cp $chroot_tmp/home/$luser/rpmbuild/RPMS/*/*.rpm $local_spool &>/dev/null") and plog('ERROR', "ERROR: could not copy rpm files from $chroot_tmp/home/$luser/rpmbuild/RPMS/ to $local_spool ($!)");
}
- $run{status}{$srpm} = 'ok';
- delete $cache->{failure}{$srpm} if defined $cache->{failure}{$srpm};
- if ($run{debug}) {
- plog("debug mode, skip other packages");
- exit();
- } elsif ($run{group}) {
- # we should not move the package until they are all compiled
- plog("group mode, keep packages for local media ($srpm is done $done)");
- $run{done}{$srpm} = $done;
- $urpmi->add_to_local_media($chroot_tmp, $srpm, $luser);
- } else {
- # drop packages and logs if we only want failure logs
- if ($run{delete_on_success}) {
- system("rm -rf $local_spool/log/$srpm/");
- } else {
- plog('OK', "build successful, copying packages to $local_spool.");
-
- system("cp $chroot_tmp/home/$luser/rpmbuild/RPMS/*/*.rpm $local_spool &>/dev/null") and plog('ERROR', "ERROR: could not copy rpm files from $chroot_tmp/home/$luser/rpmbuild/RPMS/ to $local_spool ($!)");
- }
-
- if ($run{copy_srpm}) {
- # replace the old srpm
- unlink "$local_spool/$old_srpm";
-
- system("cp $chroot_tmp/home/$luser/rpmbuild/SRPMS/$srpm $local_spool &>/dev/null") and plog('ERROR', "ERROR: could not copy $srpm from $chroot_tmp/home/$luser/rpmbuild/SRPMS/ to $local_spool ($!)");
- }
- process_queue($config, \%run, \@wrong_rpm, 1);
+ if ($run{copy_srpm}) {
+ # replace the old srpm
+ unlink "$local_spool/$old_srpm";
+
+ system("cp $chroot_tmp/home/$luser/rpmbuild/SRPMS/$srpm $local_spool &>/dev/null") and plog('ERROR', "ERROR: could not copy $srpm from $chroot_tmp/home/$luser/rpmbuild/SRPMS/ to $local_spool ($!)");
}
- dump_status($local_spool, \%run);
- # dump_cache each time so that concurrent process can get updated
- dump_cache_par(\%run) if $run{concurrent_run};
+ process_queue($config, \%run, \@wrong_rpm, 1);
+ }
+ dump_status($local_spool, \%run);
+ # dump_cache each time so that concurrent process can get updated
+ dump_cache_par(\%run) if $run{concurrent_run};
return 1;
}