diff options
Diffstat (limited to 'iurt2')
-rwxr-xr-x | iurt2 | 206 |
1 files changed, 153 insertions, 53 deletions
@@ -27,9 +27,10 @@ # - add icecream compilation support # - add a --group option to compile a set of packages (in progress) # - add a function to update a packages when it obviously need to be recompile -# - Maybe call the function from the initial todo list (thus making the argument ordering important) +# - Maybe call the function from the initial todo list (thus making the +# argument ordering important) # - Change the packager tag in the chroot to have the one who submit the package -# + use strict; use RPM4::Header; use Iurt::Config qw(config_usage get_date get_prefix config_init dump_cache_par get_maint get_date check_arch %arch_comp get_package_prefix); @@ -274,34 +275,130 @@ if (!$run{chrooted_urpmi} && $run{group}) { } my %config_usage = ( - admin => { desc => 'Mail of the administrator of packages builds', default => '' }, - all_media => { desc => 'List of known media', default => { 'main' => [ '' ], 'contrib' => [ '' ] } }, - basesystem_media_root => { desc => 'Name of the media holding basesystem packages', default => sub { my ($config, $run) = @_; "$config->{repository}/$run{distro}/$run{my_arch}/" } }, - basesystem_media => { desc => 'Where to find basesystem packages', default => 'main/release' }, - basesystem_packages => { desc => 'List of packages needed for the chroot creation', default => ['basesystem', 'rpm-build', 'rpm-mandriva-setup-build', 'sudo', 'urpmi' ] }, - cache_home => { desc => 'Where to store the cache files', default => "$HOME/.bugs" }, - cache_min_size => { desc => 'Minimal size to consider a cache file valid', default => 1000000 }, - check_binary_file => { desc => 'Packages rebuild should be checked, however sometime rpm is segfaulting and the test is not correct', default => 0 }, - iurt_root_command => { desc => 'Program to run sudo command', default => '/usr/local/bin/iurt_root_command' }, - distribution => { desc => 'Name of the packages distribution', default => 'Mandriva Linux' }, - home => { desc => 'Home dir', default => $HOME }, - install_chroot_binary => { desc => 'Tool used to create initial chroot', default => 'install-chroot-tar.sh' }, - local_home => { desc => 'Where to build packages', default => $HOME }, - local_upload => { desc => 'Where to store build packages and log', default => '' }, - local_spool => { desc => 'To override the directory where all the results are stored', default => '' }, - log_size_limit => { desc => 'Maximum authorized size for a log file', default => '100M' }, - log_size_date => { desc => 'Number of days log should be kept', default => '30' }, - log_url => { desc => 'Where the log can be seen', default => '' }, - minimum_package_number => { "Minimum number of packages in a synthesis file to consider it valid", default => 1000 }, - max_command_retry => { "Maximum number of retry Iurt will perform for a given command", fault => 20 }, - no_mail => { desc => 'Hash table with people mail address where we should not send any mails', default => {} }, - packager => { desc => 'Name of the build bot', default => 'Iurt' }, - repository => { desc => 'Prefix of the repositories', default => '/mnt/BIG/dis/' }, - rsync_to => { desc => 'Server where the result of the builds should be rsynced (name@server:path format)', default => ''}, - sendmail => { desc => 'If the bot will send mail reports regarding build', default => 0 }, - supported_arch => { desc => 'Table of supported architecture', default => ['i586', 'x86_64'] }, - upload => { desc => 'Where to copy build packages', default => "$HOME/uploads/" }, - vendor => { desc => 'Name of the packages vendor', default => 'Mandriva' }, + admin => { + desc => 'Mail of the administrator of packages builds', + default => '' + }, + all_media => { + desc => 'List of known media', + default => { + 'main' => [ '' ], + 'contrib' => [ '' ] + } + }, + basesystem_media_root => { + desc => 'Name of the media holding basesystem packages', + default => sub { + my ($config, $run) = @_; + "$config->{repository}/$run{distro}/$run{my_arch}/" + } + }, + basesystem_media => { + desc => 'Where to find basesystem packages', + default => 'main/release' + }, + basesystem_packages => { + desc => 'List of packages needed for the chroot creation', + default => [ + 'basesystem', + 'rpm-build', + 'rpm-mandriva-setup-build', + 'sudo', + 'urpmi' + ] + }, + cache_home => { + desc => 'Where to store the cache files', + default => "$HOME/.bugs" + }, + cache_min_size => { + desc => 'Minimal size to consider a cache file valid', + default => 1000000 + }, + check_binary_file => { + desc => 'Packages rebuild should be checked, however sometime rpm is segfaulting and the test is not correct', + default => 0 + }, + iurt_root_command => { + desc => 'Program to run sudo command', + default => '/usr/local/bin/iurt_root_command' + }, + distribution => { + desc => 'Name of the packages distribution', + default => 'Mandriva Linux' + }, + home => { + desc => 'Home dir', + default => $HOME + }, + install_chroot_binary => { + desc => 'Tool used to create initial chroot', + default => 'install-chroot-tar.sh' + }, + local_home => { + desc => 'Where to build packages', + default => $HOME + }, + local_upload => { + desc => 'Where to store build packages and log', + default => '' + }, + local_spool => { + desc => 'To override the directory where all the results are stored', + default => '' + }, + log_size_limit => { + desc => 'Maximum authorized size for a log file', + default => '100M' + }, + log_size_date => { + desc => 'Number of days log should be kept', + default => '30' + }, + log_url => { + desc => 'Where the log can be seen', + default => '' + }, + minimum_package_number => { + "Minimum number of packages in a synthesis file to consider it valid", + default => 1000 + }, + max_command_retry => { + "Maximum number of retry Iurt will perform for a given command", + fault => 20 + }, + no_mail => { + desc => 'Hash table with people mail address where we should not send any mails', + default => {} + }, + packager => { + desc => 'Name of the build bot', + default => 'Iurt' + }, + repository => { + desc => 'Prefix of the repositories', + default => '/mnt/BIG/dis/' + }, + rsync_to => { + desc => 'Server where the result of the builds should be rsynced (name@server:path format)', + default => '' + }, + sendmail => { + desc => 'If the bot will send mail reports regarding build', + default => 0 + }, + supported_arch => { + desc => 'Table of supported architecture', + default => ['i586', 'x86_64'] + }, + upload => { + desc => 'Where to copy build packages', + default => "$HOME/uploads/" + }, + vendor => { + desc => 'Name of the packages vendor', + default => 'Mandriva' + }, ); config_usage() if $run{config_usage}; @@ -632,11 +729,11 @@ do { } plog(5, "calling callback for $opt->{hash}"); if ($run{unionfs_tmp} && $output =~ /no space left on device/i) { - print {$run{LOG}} "ERROR $program_name: running out of space to compile $srpm in unionfs mode, will recompile it in normal mode\n"; + plog("ERROR: running out of space to compile $srpm in unionfs mode, will recompile it in normal mode"); $cache->{no_unionfs}{$srpm} = 1; return 1 } elsif ($run{unionfs_tmp} && $output =~ m,$home,) { - print {$run{LOG}} "ERROR $program_name: seems like building $srpm needs to access /proc/self/exe, which is broken with unionfs, will try to recompile it in non unionfs mode\n"; + plog("ERROR: seems like building $srpm needs to access /proc/self/exe, which is broken with unionfs, will try to recompile it in non unionfs mode"); $cache->{no_unionfs}{$srpm} = 1; return 1 } elsif ($output =~ /bin\/ld: cannot find -l(\S*)|configure.*error.* (?:-l([^\s]+)|([^\s]+) includes)/) { @@ -721,11 +818,14 @@ do { $urpmi->add_to_local_media($chroot_tmp, $srpm, $luser); } else { plog("build successful, copying packages to $local_spool."); - system("cp $chroot_tmp/home/$luser/rpm/RPMS/*/*.rpm $local_spool &>/dev/null") and print {$run{LOG}} "ERROR: could not copy rpm files from $chroot_tmp/home/$luser/rpm/RPMS/ to $local_spool ($!)\n"; + + system("cp $chroot_tmp/home/$luser/rpm/RPMS/*/*.rpm $local_spool &>/dev/null") and plog("ERROR: could not copy rpm files from $chroot_tmp/home/$luser/rpm/RPMS/ to $local_spool ($!)"); + if ($run{copy_srpm}) { # replace the old srpm unlink "$local_spool/$old_srpm"; - system("cp $chroot_tmp/home/$luser/rpm/SRPMS/$srpm $local_spool &>/dev/null") and print {$run{LOG}} "ERROR: could not copy $srpm from $chroot_tmp/home/$luser/rpm/SRPMS/ to $local_spool ($!)\n"; + + system("cp $chroot_tmp/home/$luser/rpm/SRPMS/$srpm $local_spool &>/dev/null") and plog("ERROR: could not copy $srpm from $chroot_tmp/home/$luser/rpm/SRPMS/ to $local_spool ($!)"); } process_queue($config, \%run, \@wrong_rpm, 1) } @@ -827,9 +927,9 @@ sub check_needed { } my $v ||= $version; if ($package) { - print {$run{LOG}} "ERROR $program_name: $srpm needs package $package which requires missing $name $v to be compiled.\n"; + plog("ERROR: $srpm needs package $package which requires missing $name $v to be compiled."); } else { - print {$run{LOG}} "ERROR $program_name: $srpm needs $name $v to be compiled.\n"; + plog("ERROR: $srpm needs $name $v to be compiled."); } # try to recompile it once in a while last if $cache->{warning}{"install_deps_$srpm"}{$maint}++ % 72; @@ -856,7 +956,7 @@ sub process_queue { my $err = system('/usr/bin/scp',"$dir/$rpm", $config->{upload} . "/$config->{extra_subdir}/RPMS/"); # try to keep the opportunity to prevent disk full if ($err){ - print {$run{LOG}} "ERROR process_queue: cannot copy $dir/$rpm to ", $config->{upload}, "/$config->{extra_subdir}/RPMS/ ($!)\n"; + plog("ERROR: process_queue: cannot copy $dir/$rpm to ", $config->{upload}, "/$config->{extra_subdir}/RPMS/ ($!)"); next } } @@ -885,7 +985,7 @@ sub check_pid { chomp $hostname; my $pidfile = $run->{pidfile}; my $lockfile = "$run->{pidfile_home}/$pidfile.$hostname.pid.lock"; - print {$run->{LOG}} "$program_name: trying to lock $lockfile\n"; + plog("trying to lock $lockfile"); open my $lock, ">$lockfile"; my $lock_ok; # lockf seems not to work, try to workarround, but this start to create lock on the lock for the lock of the file. @@ -893,9 +993,9 @@ sub check_pid { if (!$status) { $lock_ok = 1; } else { - print {$run->{LOG}} "ERROR $program_name: could not lock pid file (status $status $!)\n"; + plog("ERROR: could not lock pid file (status $status $!)"); if (! -f "$lockfile.2") { - print {$run->{LOG}} "$program_name: using $lockfile.2 as lock file\n"; + plog("using $lockfile.2 as lock file"); open my $lock2, ">$lockfile.2" or die "FATAL $program_name: could not open lock file $lockfile.2"; print $lock2 $$; close $lock2; @@ -914,10 +1014,10 @@ sub check_pid { my $diff = time - $time; my $msg = "$program_name: an other iurt is running for $run->{my_arch} on $pid_host, pid $pid, since $diff seconds"; if ($diff < 36000) { - print {$run->{LOG}} "$msg\n"; + plog("$msg\n"); exit } else { - print {$run->{LOG}} "$msg, ignoring it\n" + plog("$msg, ignoring it"); } } } @@ -930,7 +1030,7 @@ sub check_pid { my $pid = <$test_PID>; close $test_PID; if (!$pid) { - print {$run->{LOG}} "ERROR $program_name: invalid pidfile ($pid), should be <pid>"; + plog("ERROR: invalid pidfile ($pid), should be <pid>"); unlink $pidfile } if ($pid && getpgrp $pid != -1) { @@ -938,7 +1038,7 @@ sub check_pid { my $state = `ps h -o state $pid`; chomp $state; if ($time < time - 36000 || $state eq 'Z') { - print {$run->{LOG}} "$program_name: an other iurt pid $pid is running for a very long time or is zombie, killing it\n"; + plog("an other iurt pid $pid is running for a very long time or is zombie, killing it"); my $i; while ($i < 5 && getpgrp $pid != -1) { kill_for_good($pid); @@ -946,15 +1046,15 @@ sub check_pid { sleep 1 } } else { - print {$run->{LOG}} "$program_name: an other iurt is running for $run->{my_arch}, pid $pid, since ",time - $time," seconds\n"; + plog("an other iurt is running for $run->{my_arch}, pid $pid, since ",time - $time," seconds"); exit } } else { - print {$run->{LOG}} "$program_name: a previous iurt for $run->{my_arch} seems dead, cleaning.\n"; + plog("a previous iurt for $run->{my_arch} seems dead, cleaning."); unlink $pidfile } } - print {$run->{LOG}} "$program_name: setting $pidfile pid lock\n"; + plog("setting $pidfile pid lock"); open my $PID, ">$pidfile" or die "FATAL $program_name: could not open pidfile $pidfile for writing"; print $PID $$; close $PID; @@ -972,7 +1072,7 @@ sub check_media { # We could rely on only parsing the synthesis, hoping that they are correct, however this scan is very fast, so... foreach my $subdir (@{$config->{all_media}{$run->{media}}}) { my $rpms_dir = "$config->{repository}/$run->{distro}/$run->{my_arch}/media/$run->{media}/$subdir/"; - print {$run->{LOG}} "$program_name: checking current packages in $rpms_dir\n"; + plog("checking current packages in $rpms_dir"); opendir my $rpmdir, $rpms_dir or die "Could not open $rpms_dir: $!"; my $urpmi = $run->{urpmi}; foreach my $rpm (readdir $rpmdir) { @@ -989,7 +1089,7 @@ sub check_media { foreach my $subdir (@{$config->{all_media}{$m}}) { my $synthesis_file = "$config->{repository}/$run->{distro}/$run->{my_arch}/media/$m/$subdir/media_info/synthesis.hdlist.cz"; if (-f $synthesis_file) { - print {$run->{LOG}} "Parsing $synthesis_file\n"; + plog("Parsing $synthesis_file"); if (open my $syn, "zcat $synthesis_file |") { my @prov; my $nb; @@ -1029,9 +1129,9 @@ sub check_media { sub search_packages { my ($clean, $cache, $provides, $run, $maint, $srpm_version, @dir) = @_; my ($to_compile, %rep, %done_rpm); - print {$run->{LOG}} "iurt search_package: @dir\n"; + plog("iurt search_package: @dir"); foreach my $dir (@dir) { - print {$run->{LOG}} "$program_name: checking SRPMS dir $dir\n"; + plog("checking SRPMS dir $dir"); opendir my $rpmdir, $dir or next; foreach my $srpm (readdir $rpmdir) { # this is for the output of the new svn system @@ -1086,7 +1186,7 @@ sub add_sudoers { my $file = "$chroot/etc/sudoers"; my $f; if (!open $f, qq{| $sudo sh -c "cat > $file"}) { - print {$run->{LOG}} "ERROR $program_name: could not open $file ($!)\n"; + plog("ERROR: could not open $file ($!)"); return 0 } print $f qq{Cmnd_Alias RPM=/bin/rpm,/usr/sbin/urpmi,/usr/sbin/urpme,/usr/sbin/urpmi.addmedia,/usr/sbin/urpmi.update,/usr/sbin/urpmi.removemedia @@ -1094,7 +1194,7 @@ root ALL=(ALL) ALL $user ALL=(ALL) NOPASSWD:RPM }; close $f; - print {$run->{LOG}} "$program_name: adding sudo for /bin/rpm, /usr/sbin/urpmi and /usr/sbin/urpme\n"; + plog("adding sudo for /bin/rpm, /usr/sbin/urpmi and /usr/sbin/urpme"); -f $file or return 0; 1 } |