diff options
Diffstat (limited to 'iurt2')
-rwxr-xr-x | iurt2 | 114 |
1 files changed, 44 insertions, 70 deletions
@@ -38,8 +38,8 @@ 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 clean_chroot); -use Iurt::Process qw(perform_command clean kill_for_good); +use Iurt::Chroot qw(add_local_user create_temp_chroot remove_chroot clean_unionfs clean_all_unionfs clean_all_chroot_tmp check_build_chroot clean_chroot); +use Iurt::Process qw(perform_command clean kill_for_good sudo); use Iurt::Mail qw(sendmail); use Iurt::Util qw(plog_init plog); use File::NCopy qw(copy); @@ -51,7 +51,7 @@ use MDK::Common; use Filesys::Df qw(df); my $program_name = 'iurt2'; -my $VERSION = '0.5.21'; +my $VERSION = '0.6.2'; # sessing parameters my $sudo = '/usr/bin/sudo'; my $arg = @ARGV; @@ -109,9 +109,21 @@ $run{todo} = [ ]; [ "c", "chroot", 0, "", "Check chroot and update it if needed", sub { $run{chroot} = 1 }, "Activating chroot updating" ], - [ "", "chrooted-urpmi", 1, "<media prefix>", + [ "", "chrooted-urpmi", [ + [ "", "chrooted-urpmi", 1, "", + "Create urpmi media inside the chroot instead of using --root (media prefix is like http:///server.mandriva.com/dis/)", + sub { + my ($tmp, @arg) = @_; + $tmp->[0] ||= {}; + push @$tmp, @arg; + 1 + }, "Setting chrooted-urpmi options"], + ["m", "media", -1, "<media1> <media2> ... <median>", + "Media to add instead of --distrib", + sub { my ($tmp, @media) = @_; $tmp->[0]{media} = \@media; 1 }, "Limiting rebuild to the kernel in the given media regexp"], + ] , "[options] <media prefix>", "Create urpmi media inside the chroot instead of using --root (media prefix is like http:///server.mandriva.com/dis/)", - sub { $run{chrooted_urpmi} = shift }, "Activating chroot updating" ], + sub { my ($opt, $media) = @_; $opt->{rooted_media} = $media; $run{chrooted_urpmi} = $opt; 1 }, "Activating chroot media" ], [ "", "clean-all", 0, "", "Clean all remaining chroots for all the users", sub { $run{clean_all} = 1 }, "Activating clean chroot flag" ], @@ -237,38 +249,30 @@ open(my $LOG, ">&STDERR"); $run{LOG} = $LOG; print "$program_name version $VERSION\n"; -my $todo = parseCommandLine($program_name, \@ARGV, \@params); -@ARGV and usage($program_name, \@params, "@ARGV, too many arguments"); - plog_init($program_name, $LOG, $run{verbose}); +my $todo = parseCommandLine($program_name, \@ARGV, \@params); +@ARGV and usage($program_name, \@params, "@ARGV, too many arguments"); foreach my $t (@$todo) { plog(6, "$t->[2]"); - &{$t->[0]}(@{$t->[1]}) or plog("ERROR: $t->[2]"); + &{$t->[0]}(@{$t->[1]}) or print {$run{LOG}} "ERROR: $t->[2]\n"; } - $run{distro_tag} = $run{distro}; $run{distro_tag} =~ s,/,-,g; -chomp(my $real_arch = `uname -m`); +my $real_arch = `uname -m`; +chomp $real_arch; my $HOME = $ENV{HOME}; my $configfile = "$HOME/.iurt.$run{distro_tag}.conf"; - plog(2, "loading config file $configfile"); my $config; if (-f $configfile) { - $config = do $configfile or - die "FATAL $program_name: syntax error in $configfile"; + $config = do $configfile or die "FATAL $program_name: syntax error in $configfile"; } else { $config = {} } - -my $urpmi = Iurt::Urpmi->new( - run => \%run, - config => $config, - urpmi_options => "-v --no-verify-rpm --nolock --auto --ignoresize" -); +my $urpmi = Iurt::Urpmi->new(run => \%run, config => $config, urpmi_options => "-v --no-verify-rpm --nolock --auto --ignoresize"); $run{urpmi} = $urpmi; if (!$run{chrooted_urpmi} && $run{group}) { @@ -400,16 +404,12 @@ my %config_usage = ( desc => 'Name of the packages vendor', default => 'Mandriva' }, -); - + ); config_usage() if $run{config_usage}; - $run{my_arch} or usage($program_name, \@params, "no architecture given (media $run{media}, run{my_arch} $run{my_arch}, todo @{$run{todo}})"); - if (!$arch_comp{$real_arch}{$run{my_arch}}) { die "FATAL $program_name: could not compile $run{my_arch} binaries on a $real_arch" } - config_init(\%config_usage, $config, \%run); $config->{upload} .= $run{distro}; @@ -547,14 +547,6 @@ if (!-d $chroot_tmp) { $chroot_tmp = "$config->{local_home}/chroot_tmp/$run{user}/$chroot_name.$run{run}"; $run{chroot_tmp} = $chroot_tmp; -# now exit if there is nothing to do and it was just a cleaning pass -if ($run{no_compile} || !@{$run{todo}} && !$run{debug} && !$run{shell} && !$run{rebuild}) { - send_status_mail(\%run, $config, $cache) if ($run{status_mail}); - plog("no package to compile :("); - unlink "$run{pidfile_home}/$run{pidfile}" if $run{pidfile}; - exit -} - my $chroot = "$config->{local_home}/$chroot_name"; $run{chroot_path} = $chroot; my $chroot_tar = "$chroot.$run{my_arch}.tar.gz"; @@ -563,6 +555,14 @@ if ($run{chroot} || !-d "$chroot/dev") { check_build_chroot($chroot, $chroot_tar, \%run, $config) or die "FATAL $program_name: could not prepare initial chroot" } +# now exit if there is nothing to do and it was just a cleaning pass +if ($run{no_compile} || !@{$run{todo}} && !$run{debug} && !$run{shell} && !$run{rebuild}) { + send_status_mail(\%run, $config, $cache) if ($run{status_mail}); + plog("no package to compile :("); + unlink "$run{pidfile_home}/$run{pidfile}" if $run{pidfile}; + exit +} + plog("running with pid $$"); $run{prefix} = get_prefix($luser); @@ -620,15 +620,8 @@ if ($run{group}) { $urpmi->set_local_media($local_spool); $urpmi->order_packages($union_id, \%provides, $luser) or die "FATAL $program_name: could not order packages"; } - - -# -# The build loop -# - do { $rebuild = 0; - foreach (my $i ; $i < @{$run{todo}}; $i++) { my ($dir, $srpm, $status) = @{$run{todo}[$i]}; @@ -839,14 +832,20 @@ do { } } while ($rebuild); -clean_chroot($chroot_tmp, $chroot_tar, \%run, $config, 1) if !$run{debug}; - +my ($unionfs_dir) = $run{unionfs_dir} =~ /(.*)\/[^\/]+\/?/; +if (!$run{debug}) { + if ($run{unionfs}) { + clean_unionfs("$unionfs_dir/$run{user}", \%run, $run{run}, $union_id); + } else { + clean_chroot($chroot_tmp, $chroot_tar, \%run, $config, 1) + } +} plog(1, "reprocess generated packages queue"); process_queue($config, \%run, \@wrong_rpm); dump_cache_par(\%run); -plog("ERROR: RPM with a wrong SRPM name") if @wrong_rpm; +print {$run{LOG}} "ERROR $program_name: RPM with a wrong SRPM name\n" if @wrong_rpm; if (@wrong_rpm && open my $file, ">$local_spool/log/wrong_srpm_names.log") { foreach (@wrong_rpm) { print $file "$_->[1] -> $_->[0] (", $cache->{rpm_srpm}{$_->[1]},")\n"; @@ -867,35 +866,10 @@ if ($config->{rsync_to} && !$run{no_rsync}) { # one last try to clean plog(1, "try to clean remaining unionfs"); if ($run{unionfs}) { - my ($dir) = $run{unionfs_dir} =~ /(.*)\/[^\/]+\/?/; - remove_chroot(\%run, $dir, \&clean_all_unionfs) + remove_chroot(\%run, $unionfs_dir, \&clean_all_unionfs) } unlink "$run{pidfile_home}/$run{pidfile}" if $run{pidfile}; - - - exit; - - -# -# Subroutines -# - -sub clean_all_unionfs { - my ($run, $unionfs_dir) = @_; - plog(2, "Cleaning old unionfs remaining dir in $unionfs_dir"); - my $dir; - if (!opendir $dir, $unionfs_dir) { - plog(0, "FATAL $program_name: could not open $unionfs_dir ($!)"); - return; - } - foreach (readdir $dir) { - /unionfs\.((?:0\.)?\d+)\.(\d*)$/ or next; - clean_unionfs($unionfs_dir, \%run, $1, $2); - } - closedir $dir -} - sub check_needed { my ($srpm, $cache, $provides) = @_; if (!defined $cache->{needed}{$srpm} && !ref $cache->{needed}{$srpm}) { return 1 } @@ -1181,7 +1155,7 @@ sub search_packages { closedir $rpmdir } $to_compile -} +} sub add_sudoers { my ($run, $chroot, $user) = @_; |