aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2006-06-05 16:45:56 +0000
committerFlorent Villard <warly@mandriva.com>2006-06-05 16:45:56 +0000
commite96aadcedbbd36dfa3f7be0f6f3394db9f766805 (patch)
tree79136ec8d8c1c8170bc7495f1fec296b33ff7745
parentbb242a126c171417d2e96842e33529ddf3e52fcd (diff)
downloadiurt-e96aadcedbbd36dfa3f7be0f6f3394db9f766805.tar
iurt-e96aadcedbbd36dfa3f7be0f6f3394db9f766805.tar.gz
iurt-e96aadcedbbd36dfa3f7be0f6f3394db9f766805.tar.bz2
iurt-e96aadcedbbd36dfa3f7be0f6f3394db9f766805.tar.xz
iurt-e96aadcedbbd36dfa3f7be0f6f3394db9f766805.zip
add --chrooted-urpmi option to use urpmi inside the chroot and not urpmi --root
-rwxr-xr-xiurt292
1 files changed, 71 insertions, 21 deletions
diff --git a/iurt2 b/iurt2
index 5a4917b..585afe6 100755
--- a/iurt2
+++ b/iurt2
@@ -45,8 +45,11 @@ my (@params, %run);
$run{todo} = [ ];
@params = (
# [ "one letter option", "long name option", "number of args (-X means ´at least X´)", "help text", "function to call", "log info"]
- [ "", "$program_name", 0, "[--cache] [--concurrent-run] [--config foo value] [--warn] [--verbose integer]
- [--copy_srpm] [--debug] [--distro] [--no_rsync] [--clean user1 user2 user3] [--clean_all] [--shell] [--stop {p|c|i|l|b|a|s}]
+ #
+ # no_rsync, config_help and copy_srpm kept for compatibility reasons
+ #
+ [ "", "$program_name", 0, "[--cache] [--chrooted-urpmi <media prefix>] [--concurrent-run] [--config foo value] [--warn] [--verbose integer]
+ [--copy-srpm] [--debug] [--distro] [--no-rsync] [--clean user1 user2 user3] [--clean-all] [--shell] [--stop {p|c|i|l|b|a|s}]
[--use-system-distrib] [--dir] [--help foo?] [--log filename] [--unionfs]
[--upload [--markrelease] [--source]] [--dir] [--help foo?] [--log filename] [--unionfs]
{--config_help |
@@ -63,12 +66,18 @@ $run{todo} = [ ];
[ "", "cache", 0, "",
"Use the global cache file",
sub { $run{use_cache} = 1 }, "Activating cache use" ],
+ [ "", "copy-srpm", 0, "",
+ "Copy also the regenerated SRPM",
+ sub { $run{copy_srpm} = 1 }, "Activating the copy_srpm mode" ],
[ "", "copy_srpm", 0, "",
"Copy also the regenerated SRPM",
sub { $run{copy_srpm} = 1 }, "Activating the copy_srpm mode" ],
[ "c", "chroot", 0, "",
"Check chroot and update it if needed",
sub { $run{chroot} = 1 }, "Activating chroot updating" ],
+ [ "", "chrooted-urpmi", 1, "<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" ],
[ "", "clean-all", 0, "",
"Clean all remaining chroots for all the users",
sub { $run{clean_all} = 1 }, "Activating clean chroot flag" ],
@@ -84,6 +93,9 @@ $run{todo} = [ ];
[ "", "config", 2, "<configuration keyword> <value>",
"Override a configuration file variable",
sub { my ($key, $value) = @_; $run{config}{$key} = $value }, "Overriding configuration variable" ],
+ [ "", "config-help", 0, "",
+ "Explain configuration files keywords",
+ sub { $run{config_usage} = 1 }, "Activating debug mode" ],
[ "", "config_help", 0, "",
"Explain configuration files keywords",
sub { $run{config_usage} = 1 }, "Activating debug mode" ],
@@ -148,6 +160,9 @@ $run{todo} = [ ];
[ "", "no_rsync", 0, "",
"Do not send build log to the distant rsync server",
sub { $run{no_rsync} = 1 }, "Setting the no rsync warn flag" ],
+ [ "", "no-rsync", 0, "",
+ "Do not send build log to the distant rsync server",
+ sub { $run{no_rsync} = 1 }, "Setting the no rsync warn flag" ],
[ "", "use-system-distrib", 1, "<media>",
"Use the current system urpmi configuration",
sub { $run{use_system_distrib} = shift; 1 }, "Setting system distrib for urpmi configuration" ],
@@ -205,6 +220,8 @@ if (-f $configfile) {
my $urpmi_options = "-v --no-verify-rpm --nolock --auto --ignoresize";
if ($run{use_system_distrib}) {
$config->{basesystem_media_root} ||= $run{use_system_distrib}
+} elsif ($run{chrooted_urpmi}) {
+ $run{chrooted_media} = "$run{chrooted_urpmi}/$run{distro}/$run{my_arch}"
} else {
$urpmi_options .= " --use-distrib $config->{repository}/$run{distro}/$run{my_arch}"
}
@@ -380,7 +397,9 @@ if ($df->{per} == 100) {
if ($run{shell}) {
my ($unionfs_tmp, $chroot_tmp) = create_temp_chroot(\%run, $cache, $unionfs_tmp, $unionfs_dir, $union_id);
add_local_user($chroot_tmp, \%run, $luser, $run{uid});
- add_sudo(\%run, $config, $chroot_tmp, $luser);
+ $run{urpmi_command} = "urpmi $urpmi_options --root $chroot_tmp";
+ add_packages(\%run, $config, $chroot_tmp, $luser, 'sudo', 'urpmi');
+ add_sudoers(\%run, $luser);
if ($run{shell}) {
print {$run{LOG}} "iurt: dumping to a chrooted shell into $chroot_tmp\n";
exec "sudo chroot $chroot_tmp /bin/su $luser -c bash";
@@ -442,13 +461,23 @@ foreach (my $i ; $i < @{$run{todo}}; $i++) {
# FIXME unfortunately urpmi stalls quite often
my $retry = 0;
retry:
- my $match = "urpmi $urpmi_options --root $chroot_tmp";
- if (!clean_process($match, $run{verbose})) {
- dump_cache(\%run);
- die "FATAL iurt: Could not have urpmi working !"
+ if (!$run{chrooted_urpmi}) {
+ my $match = "urpmi $urpmi_options --root $chroot_tmp";
+ if (!clean_process($match, $run{verbose})) {
+ dump_cache(\%run);
+ die "FATAL iurt: Could not have urpmi working !"
+ }
}
my ($unionfs_tmp, $chroot_tmp) = create_temp_chroot(\%run, $cache, $unionfs_tmp, $unionfs_dir, $union_id, $srpm);
+ if ($run{chrooted_urpmi}) {
+ $run{urpmi_command} = "urpmi $urpmi_options --root $chroot_tmp ";
+ add_packages(\%run, $config, $chroot_tmp, $luser, 'urpmi');
+ add_media(\%run, $config, $chroot_tmp);
+ $run{urpmi_command} = "chroot $chroot_tmp urpmi $urpmi_options "
+ } else {
+ $run{urpmi_command} = "urpmi $urpmi_options --root $chroot_tmp"
+ }
my ($srpm_name) = $srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next;
my ($maintainer, $cc);
if (!$run{warn}) {
@@ -520,7 +549,8 @@ retry:
if ($wait_limit > 8) {
$wait_limit = 0; system(qq{sudo pkill -9 urpmi &>/dev/null})
} };
- if (!perform_command("sudo urpmi $urpmi_options --root $chroot_tmp $chroot_tmp/home/$luser/rpm/SRPMS/$srpm",
+ my $path_srpm = $run{chrooted_urpmi} ? "/home/$luser/rpm/SRPMS/" : "$chroot_tmp/home/$luser/rpm/SRPMS/";
+ if (!perform_command("sudo $run{urpmi_command} $path_srpm/$srpm",
\%run, $config,
mail => $config->{admin},
error => "[REBUILD] install of build dependencies of $srpm failed on $run{my_arch}",
@@ -576,7 +606,8 @@ retry:
print {$run{LOG}} "Compiling $srpm\n" if $run{verbose};
my $command = "rpm --rebuild /home/$luser/rpm/SRPMS/$srpm";
if ($run{stop}) {
- add_sudo(\%run, $config, $chroot_tmp, $luser);
+ add_packages(\%run, $config, $chroot_tmp, $luser, 'urpmi', 'sudo');
+ add_sudoers(\%run, $config, $chroot_tmp, $luser);
$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"},
@@ -610,7 +641,7 @@ retry:
}
1
},
- freq => 1) && !glob "$chroot_tmp/home/$luser/rpm/RPMS/*/*.rpm") {
+ freq => 1)) {
# FIXME
# The simple algo used here is :
# try to compile it with unionfs, if it runs out of space, compile it without the next time
@@ -632,7 +663,9 @@ retry:
} else {
goto retry
}
- next
+ if (!glob "$chroot_tmp/home/$luser/rpm/RPMS/*/*.rpm") {
+ next
+ }
}
# do some cleaning if the compilation is successful
delete $cache->{needed}{$srpm} if defined $cache->{needed}{$srpm};
@@ -728,7 +761,11 @@ sub config_usage {
sub clean_all_unionfs {
my ($unionfs_dir) = @_;
print {$run{LOG}} "Cleaning old unionfs remaining dir in $unionfs_dir\n" if $run{verbose} > 1;
- opendir my $dir, $unionfs_dir or die "FATAL iurt: could not open $unionfs_dir ($!)";
+ my $dir;
+ if (!opendir $dir, $unionfs_dir) {
+ print {$run{LOG}} "FATAL iurt: could not open $unionfs_dir ($!)";
+ return
+ }
foreach (readdir $dir) {
/unionfs\.((?:0\.)?\d+)\.(\d+)$/ or next;
clean_unionfs($unionfs_dir, $1, $2);
@@ -1161,7 +1198,7 @@ sub check_chroot {
print {$run{LOG}} "iurt: checking basesystem tar\n" if $run{verbose};
system(qq{sudo pkill -9 -u root -f "urpmi $urpmi_options --root $chroot" &> /dev/null});
clean_chroot($chroot, $run, 1) or die "FATAL iurt: Could no prepare initial chroot";
- perform_command("sudo $config->{install_chroot_binary} $config->{basesystem_media_root} $config->{basesystem_media_root}/media/$config->{basesystem_media} $chroot_tar $chroot 501 basesystem tar rpm-build",
+ perform_command("sudo $config->{install_chroot_binary} $config->{basesystem_media_root} $config->{basesystem_media_root}/media/$config->{basesystem_media} $chroot_tar $chroot 501 basesystem tar rpm-build rpm-mandriva-setup-build",
$run, $config,
mail => $config->{admin},
error => "[REBUILD] Creating the inital chroot for $run->{distro_tag} on $run->{my_arch} failed",
@@ -1443,10 +1480,10 @@ sub create_temp_chroot {
$unionfs_tmp, $chroot_tmp
}
-sub add_sudo {
- my ($run, $config, $chroot, $user) = @_;
+sub add_packages {
+ my ($run, $config, $chroot, $user, @packages) = @_;
my $f;
- perform_command("sudo urpmi $urpmi_options --root $chroot_tmp sudo urpmi",
+ perform_command("sudo $run{urpmi_command} @packages",
$run, $config,
mail => $config->{admin},
timeout => 600,
@@ -1461,10 +1498,11 @@ sub add_sudo {
$wait_limit++;
if ($wait_limit > 10) {
$wait_limit = 0; system(qq{sudo pkill -9 urpmi &>/dev/null})
- } },);
- if (system("sudo urpmi $urpmi_options --root $chroot_tmp sudo urpmi")) {
- die "FATAL iurt: could not install sudo in the $chroot_tmp ($!)"
- }
+ } },)
+}
+
+sub add_sudoers {
+ my ($run, $user) = @_;
my $file = "$chroot/etc/sudoers";
my $f;
if (!open $f, qq{| sudo sh -c "cat > $file"}) {
@@ -1495,4 +1533,16 @@ sub remove_chroot {
$func->("$dir/$user", $prefix)
}
}
- }
+}
+
+sub add_media {
+ my ($run, $config, $chroot) = @_;
+ print {$run->{LOG}} "iurt: adding media $run{chrooted_media} in chroot $chroot\n";
+ perform_command("sudo chroot $chroot_tmp urpmi.addmedia --distrib $run{chrooted_media}",
+ $run, $config,
+ mail => $config->{admin},
+ timeout => 120,
+ freq => 1,
+ retry => 5,
+ debug_mail => $run->{debug})
+}