diff options
author | Florent Villard <warly@mandriva.com> | 2006-10-11 05:48:29 +0000 |
---|---|---|
committer | Florent Villard <warly@mandriva.com> | 2006-10-11 05:48:29 +0000 |
commit | e0506d99106f53f4ff6073358d9913edcd568182 (patch) | |
tree | 4a6061e471698e6b464641bb63e2ed4a0ba5a1f3 /iurt2 | |
parent | 8230409ff4881836dd415edf6f375b6b229999e0 (diff) | |
download | iurt-e0506d99106f53f4ff6073358d9913edcd568182.tar iurt-e0506d99106f53f4ff6073358d9913edcd568182.tar.gz iurt-e0506d99106f53f4ff6073358d9913edcd568182.tar.bz2 iurt-e0506d99106f53f4ff6073358d9913edcd568182.tar.xz iurt-e0506d99106f53f4ff6073358d9913edcd568182.zip |
move recreate_srpm to Urpmi; scp the resulting packages instead of copy; clean the chroot after the build
Diffstat (limited to 'iurt2')
-rwxr-xr-x | iurt2 | 102 |
1 files changed, 17 insertions, 85 deletions
@@ -31,12 +31,12 @@ # use strict; use RPM4::Header; -use Iurt::Config qw(config_usage get_date get_prefix config_init dump_cache_par get_maint get_date get_prefix); +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); use Data::Dumper; use URPM; use Iurt::DKMS; use Iurt::Urpmi; -use Iurt::Chroot qw(add_local_user create_temp_chroot remove_chroot clean_all_chroot_tmp clean_unionfs check_build_chroot); +use Iurt::Chroot qw(add_local_user create_temp_chroot remove_chroot clean_all_chroot_tmp clean_unionfs check_build_chroot clean_chroot); use Iurt::Process qw(perform_command clean kill_for_good); use Iurt::Mail qw(sendmail); use File::NCopy qw(copy); @@ -47,20 +47,13 @@ use MDK::Common; use Filesys::Df qw(df); my $program_name = 'iurt2'; -my $VERSION = '0.5.10'; +my $VERSION = '0.5.15'; # sessing parameters my $sudo = '/usr/bin/sudo'; my $arg = @ARGV; my (@params, %run); $run{program_name} = $program_name; -my %arch_comp = ( - 'i586' => { 'i386' => 1, 'i486' => 1, 'i586' => 1 }, - 'i686' => { 'i386' => 1, 'i486' => 1, 'i586' => 1, 'i686' => 1 }, - 'x86_64' => { 'x86_64' => 1 }, - 'ppc' => { 'ppc' => 1 }, - 'ppc64' => { 'ppc' => 1, 'ppc64' => 1 }, -); - + $run{todo} = [ ]; @params = ( # [ "one letter option", "long name option", "number of args (-X means ´at least X´)", "help text", "function to call", "log info"] @@ -177,8 +170,7 @@ $run{todo} = [ ]; } else { die "FATAL $program_name: $_ does not seems to be a SRPM\n" } - my $hdr = RPM4::Header->new($_); - if (check_arch($hdr)) { + if (check_arch($_, $run{my_arch})) { print {$run{LOG}} "$program_name: force build for $2 (from $1)\n"; push @{$run{todo}}, [ $path, $srpm, 1 ] } else { @@ -316,8 +308,6 @@ if ($run{distro} ne 'cooker') { $config->{upload} =~ s/cooker/contrib/g; } --d $config->{upload} or usage($program_name, \@params, "$config->{upload} does not exist"); - my $lock = $run{media}; my $local; if (!$lock && $run{chroot}) { @@ -521,8 +511,8 @@ my $rebuild; $run{group} = 0 if @{$run{todo}} == 1; if ($run{group}) { $rebuild = 1; - $urpmi->order_packages($union_id, $luser) or die "FATAL $program_name: could not order packages"; - $urpmi->set_local_media("$local_spool/$run{run}/") + $urpmi->set_local_media($local_spool); + $urpmi->order_packages($union_id, \%provides, $luser) or die "FATAL $program_name: could not order packages"; } do { $rebuild = 0; @@ -566,7 +556,7 @@ do { print {$run{LOG}} "$program_name: adding local user $luser into $chroot_tmp...\n" if $run{verbose}; add_local_user($chroot_tmp, \%run, $config, $luser, $run{uid}) or next; - my $ret = recreate_srpm(\%run, $config, $chroot_tmp, $dir, $srpm, $luser, $retry); + my ($ret, $srpm, $spec) = $urpmi->recreate_srpm(\%run, $config, $chroot_tmp, $dir, $srpm, $luser, $retry); if ($ret == -1) { $retry = 1; goto retry @@ -598,7 +588,7 @@ do { 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(\%run, $chroot_tmp, $luser); - $command = "rpm -b$run{stop} /home/$luser/rpm/SPECS/*.spec" + $command = "rpm -b$run{stop} /home/$luser/rpm/SPECS/$spec" } if (!perform_command(qq{TMP=/home/$luser/tmp/ $sudo chroot $chroot_tmp /bin/su $luser -c "$command"}, \%run, $config, $cache, @@ -720,10 +710,12 @@ do { dump_cache_par(\%run) if $run{concurrent_run}; } if ($run{group} && $rebuild) { - $urpmi->order_packages($union_id) + $urpmi->order_packages($union_id, $luser) } } while ($rebuild); +clean_chroot($chroot_tmp, $chroot_tar, \%run, $config, 1); + print {$run{LOG}} "$program_name: reprocess generated packages queue\n" if $run{verbose}; process_queue($config, \%run, \@wrong_rpm); @@ -830,10 +822,10 @@ sub process_queue { # 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") { - my $ok = copy "$dir/$rpm", "$config->{upload}/$config->{extra_subdir}/RPMS/"; + my $err = system('/usr/bin/scp',"$dir/$rpm", $config->{upload} . "/$config->{extra_subdir}/RPMS/"); # try to keep the opportunity to prevent disk full - if (!$ok){ - print {$run{LOG}} "ERROR process_queue: cannot copy $dir/$rpm to $config->{upload}/$config->{extra_subdir}/RPMS/ ($!)\n"; + if ($err){ + print {$run{LOG}} "ERROR process_queue: cannot copy $dir/$rpm to ", $config->{upload}, "/$config->{extra_subdir}/RPMS/ ($!)\n"; next } } @@ -846,15 +838,6 @@ sub process_queue { closedir $rpmdir; } -sub check_arch { - my ($hdr) = @_; - my (@exclusive_arch) = $hdr->queryformat('%{EXCLUSIVEARCH}'); - return if ! grep { $arch_comp{$run{my_arch}}{$_} || $_ eq '(none)' } @exclusive_arch; - my (@exclude_arch) = $hdr->queryformat('%{EXCLUDEARCH}'); - return if grep { $_ eq $run{my_arch} } @exclude_arch; - 1 -} - sub check_version { my ($srpm, $srpm_version) = @_; my ($srpm_name) = $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm/; @@ -1039,11 +1022,11 @@ sub search_packages { $run->{status}{$srpm} = 'missing_buildrequires' if !$check_needed; -f "$dir/$srpm" or next; if (!$cache->{queue}{$srpm} && $check_needed) { - my $hdr = RPM4::Header->new("$dir/$srpm"); - if (!check_arch($hdr)) { + if (!check_arch("$dir/$srpm", $run{my_arch})) { $run->{status}{$srpm} = 'not_on_this_arch'; next } + my $hdr = RPM4::Header->new("$dir/$srpm"); my $changelog = $hdr->queryformat("%{CHANGELOGNAME}"); my ($mail) = $changelog =~ /<(.*@.*)>/; $maint{$srpm} = $mail; @@ -1085,57 +1068,6 @@ $user ALL=(ALL) NOPASSWD:RPM 1 } - - -sub recreate_srpm { - my ($run, $config, $chroot_tmp, $dir, $srpm, $luser, $retry) = @_; -# recreate a new srpm for buildarch condition in the spec file - print {$run->{LOG}} "$program_name: copying $srpm to $chroot_tmp\n" if $run->{verbose} > 1; - perform_command("sudo cp $dir/$srpm $chroot_tmp/home/$luser/rpm/SRPMS/", - \%run, $config, $cache, - mail => $config->{admin}, - error => "[REBUILD] cannot copy $srpm to $chroot_tmp", - debug_mail => $run->{debug}, - hash => "copy_$srpm") or return; - - my %opt = ( mail => $config->{admin}, - error => "[REBUILD] cannot install $srpm in $chroot_tmp", - debug_mail => $run->{debug}, - hash => "install_$srpm", - retry => $retry, - callback => sub { - my ($opt, $output) = @_; - print {$run->{LOG}} "calling callback for $opt->{hash}\n" if $run->{debug}; - if ($output =~ /warning: (group|user) .* does not exist - using root|Header V3 DSA signature/i) { - return 1 - } elsif ($output =~ /user $luser does not exist|cannot write to \%sourcedir/) { - print {$run->{LOG}} "WARNING $program_name: chroot seems corrupted...\n" if $run->{verbose} > 1; - $opt->{error} = "[CHROOT] chroot is corrupted"; - $opt->{retry} = 1 if !$opt->{retry}; - return - } - 1 - }); - print {$run->{LOG}} "$program_name: recreating src.rpm...\n" if $run->{verbose}; - if (!perform_command(qq{$sudo chroot $chroot_tmp su $luser -c "rpm -i /home/$luser/rpm/SRPMS/$srpm"}, - \%run, $config, $cache, %opt)) { - print {$run->{LOG}} "ERROR $program_name: chrooting failed (retry $opt{retry}\n" if $run->{debug}; - if ($opt{retry}) { - check_build_chroot($run->{chroot_path}, $run->{chroot_tar}, \%run, $config) or return; - return -1 - } - return - } - # 20060515 This should not be necessairy any more if urpmi *.spec works, but it doesn't - # - perform_command(qq{$sudo chroot $chroot_tmp su $luser -c "rpm --nodeps -bs /home/$luser/rpm/SPECS/*.spec"}, - \%run, $config, $cache, - mail => $config->{admin}, - error => "[REBUILD] cannot create $srpm in $chroot_tmp", - debug_mail => $run->{debug}, - hash => "create_$srpm") -} - sub dump_status { my ($local_spool, $run) = @_; my $media = $run->{media} ? "$run->{media}." : ""; |