aboutsummaryrefslogtreecommitdiffstats
path: root/iurt2
diff options
context:
space:
mode:
Diffstat (limited to 'iurt2')
-rwxr-xr-xiurt2113
1 files changed, 80 insertions, 33 deletions
diff --git a/iurt2 b/iurt2
index 75443d4..df07289 100755
--- a/iurt2
+++ b/iurt2
@@ -220,6 +220,9 @@ $run{todo} = [];
], "[options]",
"Upload the rebuild packages",
sub { $run{upload} = 1 }, "Setting the upload flag" ],
+ [ "", "use-old-chroot", 1, "<chroot path>",
+ "Use the given chroot as chroot (usefull for debugging)",
+ sub { ($run{use_old_chroot}) = @_ }, "Using given chroot" ],
[ "", "no_rsync", 0, "",
"Do not send build log to the distant rsync server",
sub { $run{no_rsync} = 1 }, "Setting the no rsync warn flag" ],
@@ -263,8 +266,8 @@ $run{todo} = [];
open(my $LOG, ">&STDERR");
$run{LOG} = sub { print $LOG @_ };
-#plog_init($program_name, $LOG, $run{verbose}, 1);
-plog_init($program_name, $LOG, 7, 1); # CM: hardcoded for now, will fix ASAP
+plog_init($program_name, $LOG, $run{verbose}, 1);
+#plog_init($program_name, $LOG, 7, 1); # CM: hardcoded for now, will fix ASAP
# Display version information
@@ -587,7 +590,7 @@ check_sudo_access()
my $debug_tag = $run{debug} && '_debug';
$run{debug_tag} = $debug_tag;
-if ($run{unionfs}) {
+if ($run{unionfs} && !$run{use_old_chroot}) {
plog(1, "adding unionfs module");
sudo(\%run, $config, "--modprobe", "unionfs") or $run{unionfs} = 0;
if ($run{unionfs}) {
@@ -603,26 +606,37 @@ $run{done} = \%done;
my $home = $config->{local_home};
my $union_id = 1;
$run{unionfs_tmp} = $run{unionfs};
-my $chroot_name = "chroot_$run{distro_tag}$debug_tag";
-my $chroot_tmp = "$config->{local_home}/chroot_tmp";
-if (!-d $chroot_tmp) {
- mkdir $chroot_tmp;
-} else {
- remove_chroot(\%run, $chroot_tmp, \&clean_all_chroot_tmp, $chroot_name);
-}
+my ($chroot_name, $chroot_tmp, $chroot, $chroot_tar);
+$chroot_name = "chroot_$run{distro_tag}$debug_tag";
+if (!$run{use_old_chroot}) {
+ $chroot_tmp = "$config->{local_home}/chroot_tmp";
-$chroot_tmp = "$config->{local_home}/chroot_tmp/$run{user}";
-if (!-d $chroot_tmp) {
- mkdir $chroot_tmp;
-}
-$chroot_tmp = "$config->{local_home}/chroot_tmp/$run{user}/$chroot_name.$run{run}";
-$run{chroot_tmp} = $chroot_tmp;
+ if (!-d $chroot_tmp) {
+ mkdir $chroot_tmp;
+ } else {
+ remove_chroot(\%run, $chroot_tmp, \&clean_all_chroot_tmp, $chroot_name);
+ }
+
+ $chroot_tmp = "$config->{local_home}/chroot_tmp/$run{user}";
+ if (!-d $chroot_tmp) {
+ mkdir $chroot_tmp;
+ }
+ $chroot_tmp = "$config->{local_home}/chroot_tmp/$run{user}/$chroot_name.$run{run}";
+ $run{chroot_tmp} = $chroot_tmp;
-my $chroot = "$config->{local_home}/$chroot_name";
+ $chroot = "$config->{local_home}/$chroot_name";
+} else {
+ plog(1, "using given chroot $run{use_old_chroot}");
+ $chroot_tmp = $run{use_old_chroot};
+ $chroot = $run{use_old_chroot};
+}
$run{chroot_path} = $chroot;
-my $chroot_tar = "$chroot.$run{my_arch}.tar.gz";
+$chroot_tar = "$config->{local_home}/$chroot_name.$run{my_arch}.tar.gz";
$run{chroot_tar} = $chroot_tar;
+# 20061222 warly
+# even in use_old_chroot mode we create the chroot if it does not exist (useful
+# if the option is used for the first time
if ($run{chroot} || !-d "$chroot/dev") {
check_build_chroot($chroot, $chroot_tar, \%run, $config) or die "FATAL $program_name: could not prepare initial chroot";
}
@@ -644,11 +658,12 @@ if ($df->{per} >= 99) {
}
if ($run{shell}) {
- ($union_id, my $chroot_tmp) = create_temp_chroot(\%run, $config,
+ if (!$run{use_old_chroot}) {
+ ($union_id, my $chroot_tmp) = create_temp_chroot(\%run, $config,
$cache, $union_id, $chroot_tmp, $chroot_tar)
or die "FATAL $program_name: could not create temporary chroot";
- add_local_user($chroot_tmp, \%run, $config, $luser, $run{uid})
- or die "FATAL $program_name: could not add local user";
+ }
+ add_local_user($chroot_tmp, \%run, $config, $luser, $run{uid}) or die "FATAL $program_name: could not add local user";
#$urpmi->set_command($chroot_tmp);
$urpmi->urpmi_command($chroot_tmp, $luser);
@@ -701,14 +716,13 @@ if ($run{group}) {
$urpmi->order_packages($union_id, \%provides, $luser)
or die "FATAL $program_name: could not order packages";
}
-
-
#
# The build loop
#
-
+my $prev_done = $done;
do {
$rebuild = 0;
+ $done = $prev_done;
for (my $i; $i < @{$run{todo}}; $i++) {
my ($dir, $srpm, $status) = @{$run{todo}[$i]};
@@ -734,9 +748,11 @@ do {
retry:
$urpmi->clean_urpmi_process;
- my ($u_id, $chroot_tmp) = create_temp_chroot(\%run, $config,
+ if (!$run{use_old_chroot}) {
+ (my $u_id, $chroot_tmp) = create_temp_chroot(\%run, $config,
$cache, $union_id, $chroot_tmp, $chroot_tar, $srpm) or next;
- $union_id = $u_id;
+ $union_id = $u_id;
+ }
$urpmi->urpmi_command($chroot_tmp, $luser);
$srpm =~ /(.*)-[^-]+-[^-]+\.src\.rpm$/ or next;
@@ -923,11 +939,11 @@ retry:
plog("debug mode, skip other packages");
exit();
} elsif ($run{group}) {
- $rebuild = 1;
- plog("group mode, keep packages for local media");
+ # 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 {
+ } else {
plog('OK', "build successful, copying packages to $local_spool.");
system("cp $chroot_tmp/home/$luser/rpm/RPMS/*/*.rpm $local_spool &>/dev/null") and plog('ERR', "ERROR: could not copy rpm files from $chroot_tmp/home/$luser/rpm/RPMS/ to $local_spool ($!)");
@@ -943,13 +959,31 @@ retry:
# dymp_cache each time so that concurrent process can get updated
dump_cache_par(\%run) if $run{concurrent_run};
}
- if ($run{group} && $rebuild) {
- $urpmi->order_packages($union_id, $luser);
+ if ($run{group}) {
+ for (my $i; $i < @{$run{todo}}; $i++) {
+ my (undef, $srpm) = @{$run{todo}[$i]};
+ if (!$run{done}{$srpm}) {
+ $rebuild = $urpmi->order_packages($union_id, \%provides, $luser);
+ last
+ }
+ }
+ if ($prev_done == $done) {
+ $rebuild = 0;
+ if ($done == @{$run{todo}}) {
+ plog('OK', "all packages succesfully compiled, copying packages to $local_spool.");
+ system("cp $chroot_tmp/home/$luser/rpm/RPMS/*/*.rpm $local_spool &>/dev/null") and plog('ERR', "ERROR: could not copy rpm files from $chroot_tmp/home/$luser/rpm/RPMS/ to $local_spool ($!)");
+ if ($run{copy_srpm}) {
+ system("cp $chroot_tmp/home/$luser/rpm/SRPMS/*.src.rpm $local_spool &>/dev/null") and plog('ERR', "ERROR: could not copy SRPMS from $chroot_tmp/home/$luser/rpm/SRPMS/ to $local_spool ($!)");
+ }
+ } else {
+ plog('FAIL', "some packages could not be compiled.");
+ }
+ }
}
} while $rebuild;
my ($unionfs_dir) = $run{unionfs_dir} =~ m!(.*)/[^/]+/?!;
-if (!$run{debug}) {
+if (!$run{debug} && !$run{use_old_chroot}) {
if ($run{unionfs}) {
clean_unionfs("$unionfs_dir/$run{user}", \%run, $run{run}, $union_id);
} else {
@@ -980,7 +1014,7 @@ if ($config->{rsync_to} && !$run{no_rsync}) {
# one last try to clean
plog('DEBUG', "clean remaining unionfs");
-if ($run{unionfs}) {
+if ($run{unionfs} && !$run{use_old_chroot}) {
remove_chroot(\%run, $unionfs_dir, \&clean_all_unionfs);
}
unlink "$run{pidfile_home}/$run{pidfile}" if $run{pidfile};
@@ -1415,3 +1449,16 @@ sub check_sudo_access() {
0;
}
+__END__
+
+Discussion
+
+20061222 Warly
+ Group building
+ For the group building, we need to order the source packages, the problem is that we do not
+ really know what will be the provides of the resulting packages before building the.
+ We could guess them by looking to older version, but that means that we need to have an access to
+ the media deps files (synthesis should be enough).
+ We can also perform a first pass of build to check which package build and then what are their
+ provides. For the second pass, we will them be able to use the previously build packages to
+ solve buildrequires.