aboutsummaryrefslogtreecommitdiffstats
path: root/iurt2
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2006-01-06 18:38:26 +0000
committerFlorent Villard <warly@mandriva.com>2006-01-06 18:38:26 +0000
commite856d5bdaede33b19566a4c2ea93bd7936592dfa (patch)
tree3b5af13c856a207ec19696bbc53f8930a83ad199 /iurt2
parent74c69d40d245199435f3263e56cbd73f4d82cc08 (diff)
downloadiurt-e856d5bdaede33b19566a4c2ea93bd7936592dfa.tar
iurt-e856d5bdaede33b19566a4c2ea93bd7936592dfa.tar.gz
iurt-e856d5bdaede33b19566a4c2ea93bd7936592dfa.tar.bz2
iurt-e856d5bdaede33b19566a4c2ea93bd7936592dfa.tar.xz
iurt-e856d5bdaede33b19566a4c2ea93bd7936592dfa.zip
Try to be more robust regarding unionfs mounting/unmounting
Diffstat (limited to 'iurt2')
-rwxr-xr-xiurt255
1 files changed, 41 insertions, 14 deletions
diff --git a/iurt2 b/iurt2
index dc0f389..8d8d48c 100755
--- a/iurt2
+++ b/iurt2
@@ -250,6 +250,7 @@ my $run = $cache->{run}++;
my $debug_tag = '_debug' if $debug;
my $chroot = "$config->{local_home}/chroot$debug_tag";
my $chroot_tar = "$chroot-$distro_tag.$my_arch.tar.gz";
+my $unionfs_dir;
if (!$nocheckchroot) {
print "iurt: checking basesystem tar\n";
system(qq{sudo pkill -9 -u root -f "urpmi $urpmi_options --root $chroot"});
@@ -263,7 +264,8 @@ if (!$nocheckchroot) {
if ($unionfs) {
clean_chroot($chroot) or die "FATAL iurt: Could no prepare initial chroot";
- $chroot = "$config->{local_home}/unionfs$debug_tag"
+ $unionfs_dir = "$config->{local_home}/iurt_unionfs$debug_tag";
+ -d $unionfs_dir or mkdir $unionfs_dir
}
}
@@ -275,11 +277,11 @@ if (!-d "$config->{local_home}/iurt/$distro_tag/") {
mkdir "$local_spool/log"
}
}
-
my %done;
my $wait_limit;
my $done;
my $home = $config->{local_home};
+my $union_id = 1;
foreach (my $i ; $i < @todo; $i++) {
my ($dir, $srpm) = @{$todo[$i]};
$done{$srpm} and next;
@@ -291,18 +293,14 @@ foreach (my $i ; $i < @todo; $i++) {
if (!$done % 10) { dump_cache() }
print "iurt: packages $srpm [$done/$to_compile]\n";
if ($unionfs) {
- foreach my $t ("unionfs",'tmpfs') {
- my $d = "$home/$t";
- while (check_mounted($d, $t)) {
- print STDERR "iurt: umounting $d\n";
- system(qq{sudo umount $d}) and die "FATAL iurt: could not umount $d"
- }
- print STDERR "iurt: removing $d\n";
- system(qq{sudo rm -rf $d});
- mkdir "$d";
- }
- system(qq{sudo mount -t tmpfs none $home/tmpfs}) and die "FATAL iurt: could not mount $home/tmpfs ($!)";
- system(qq{sudo mount -o dirs=$home/tmpfs=rw:$home/chroot=ro -t unionfs unionfs $home/unionfs}) and die "FATAL iurt: could not mount $home/tmpfs and $home/chroot with unionfs ($!)";
+ my $tmpfs;
+ $union_id = clean_unionfs($unionfs_dir, $union_id);
+ $tmpfs = "$unionfs_dir/tmpfs.$run.$union_id";
+ $chroot = "$unionfs_dir/unionfs.$run.$union_id";
+ mkdir $tmpfs or die "Could not create $tmpfs ($!)";
+ mkdir $chroot or die "Could not create $chroot ($!)";
+ system(qq{sudo mount -t tmpfs none $tmpfs}) and die "FATAL iurt: could not mount $tmpfs ($!)";
+ system(qq{sudo mount -o dirs=$tmpfs=rw:$home/chroot=ro -t unionfs none $chroot}) and die "FATAL iurt: could not mount $tmpfs and $home/chroot with unionfs ($!)";
} else {
print STDERR "iurt: installing a new chroot for $srpm in $chroot\n";
clean_chroot($chroot)
@@ -415,6 +413,14 @@ if ($config->{rsync_to}) {
system("rsync -alHPe 'ssh -c arcfour' $local_spool/log/ $config->{rsync_to}/$distro_tag/$my_arch/log/");
}
+# one last try to clean
+print STDERR "iurt: try to clean remaining unionfs\n";
+if ($unionfs) {
+ for (my $i = 1; $i <= $union_id; $i++) {
+ clean_unionfs($unionfs_dir, $union_id);
+ }
+}
+
unlink $pidfile;
exit;
@@ -461,6 +467,27 @@ sub clean_chroot {
1
}
+sub clean_unionfs {
+ my ($unionfs_dir, $union_id) = @_;
+ foreach my $t ("unionfs",'tmpfs') {
+ # unfortunately quite oftem the unionfs is busy and could not be unmounted
+ my $d = "$unionfs_dir/$t.$run.$union_id";
+ while (check_mounted($d, $t)) {
+ system("sudo fuser -k $d");
+ print STDERR "iurt: umounting $d\n";
+ if (system(qq{sudo umount $d})) {
+ print STDERR "WARNING iurt: could not umount $d ($!)\n";
+ $union_id++;
+ return $union_id
+ }
+ }
+ print STDERR "iurt: removing $d\n";
+ system(qq{sudo rm -rf $d});
+ }
+ $union_id
+}
+
+
sub check_mounted {
my ($mount_point, $type) = @_;
open my $mount, '/proc/mounts' or die 'FATAL iurt: could not open /proc/mounts';