aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mageia.org>2012-03-17 23:42:31 +0000
committerPascal Terjan <pterjan@mageia.org>2012-03-17 23:42:31 +0000
commitc2dd485df635e6be732c1623fa7ebf841302340f (patch)
tree59d54956a3b894eccd98ff01b3dbf2a6789ea885 /lib
parente5fefd376242c7024cce11b6b2e62749aed53bd9 (diff)
downloadiurt-c2dd485df635e6be732c1623fa7ebf841302340f.tar
iurt-c2dd485df635e6be732c1623fa7ebf841302340f.tar.gz
iurt-c2dd485df635e6be732c1623fa7ebf841302340f.tar.bz2
iurt-c2dd485df635e6be732c1623fa7ebf841302340f.tar.xz
iurt-c2dd485df635e6be732c1623fa7ebf841302340f.zip
Kill unionfs support
Diffstat (limited to 'lib')
-rw-r--r--lib/Iurt/Chroot.pm149
-rw-r--r--lib/Iurt/Config.pm4
-rw-r--r--lib/Iurt/Urpmi.pm9
3 files changed, 13 insertions, 149 deletions
diff --git a/lib/Iurt/Chroot.pm b/lib/Iurt/Chroot.pm
index eb1bea5..77a1463 100644
--- a/lib/Iurt/Chroot.pm
+++ b/lib/Iurt/Chroot.pm
@@ -12,9 +12,7 @@ use File::Path 'mkpath';
our @EXPORT = qw(
clean_chroot_tmp
- clean_unionfs
clean_all_chroot_tmp
- clean_all_unionfs
clean_chroot
update_chroot
dump_rpmmacros
@@ -207,83 +205,17 @@ sub add_local_user {
}
sub create_temp_chroot {
- my ($run, $config, $cache, $union_id, $chroot_tmp, $chroot_tar, $o_srpm) = @_;
+ my ($run, $config, $cache, $chroot_tmp, $chroot_tar, $o_srpm) = @_;
my $home = $config->{local_home};
my $debug_tag = $run->{debug_tag};
- my $unionfs_dir = $run->{unionfs_dir};
-
- if ($run->{unionfs_tmp}) {
- my $mount_point = "$unionfs_dir/unionfs.$run->{run}.$union_id";
- plog(2, "cleaning temp chroot $mount_point");
- if (!clean_mnt($run, $mount_point, $run->{verbose})) {
- dump_cache_par($run);
- die "FATAL: can't kill remaining processes acceding $mount_point";
- }
- my $tmpfs;
-
- # we cannont just rm -rf $tmpfs, this create defunct processes
- # afterwards (and lock particularly hard the urpmi database)
- #
- $union_id = clean_unionfs($unionfs_dir, $run, $run->{run}, $union_id);
- $tmpfs = "$unionfs_dir/tmpfs.$run->{run}.$union_id";
- $chroot_tmp = "$unionfs_dir/unionfs.$run->{run}.$union_id";
-
- if (!-d $tmpfs) {
- if (!mkpath($tmpfs)) {
- plog("ERROR: Could not create $tmpfs ($!)");
- return;
- }
- }
- if (! -d $chroot_tmp) {
- if (!mkpath($chroot_tmp)) {
- plog("ERROR: Could not create $chroot_tmp ($!)");
- return;
- }
- }
- if ($cache->{no_unionfs}{$o_srpm}) {
- $run->{unionfs_tmp} = 0;
- clean_chroot($chroot_tmp, $chroot_tar, $run, $config);
- } else {
- # if the previous package has been built without unionfs, chroot need to be cleaned
- if (!$run->{unionfs_tmp}) {
- clean_chroot($chroot_tmp, $chroot_tar, $run, $config);
- } else {
- # only detar the chroot if not already
- clean_chroot($chroot_tmp, $chroot_tar, $run, $config, 0, 1);
- }
- $run->{unionfs_tmp} = 1;
- if (system(qq($sudo mount -t tmpfs none $tmpfs &>/dev/null))) {
- plog("ERROR: can't mount $tmpfs ($!)");
- return;
- }
- if (system(qq($sudo mount -o dirs=$tmpfs=rw:$home/chroot_$run->{distro_tag}$debug_tag=ro -t unionfs none $chroot_tmp &>/dev/null))) {
- plog("ERROR: can't mount $tmpfs and $home/chroot_$run->{distro_tag}$debug_tag with unionfs ($!)");
- return;
- }
- if (system("$sudo mount -t proc none $chroot_tmp/proc &>/dev/null")) {
- plog("ERROR: can't mount /proc in chroot $chroot_tmp ($!)");
- return;
- }
- if (!-d "$chroot_tmp/dev/pts") {
- if (sudo($run, $config, "--mkdir", "$chroot_tmp/dev/pts")) {
- plog("ERROR: can't create /dev/pts in chroot $chroot_tmp ($!)");
- return;
- }
- if (system($sudo, "mount", "-t", "devpts", "none", "$chroot_tmp/dev/pts &>/dev/null")) {
- plog("ERROR: can't mount /dev/pts in the chroot $chroot_tmp ($!)");
- return;
- }
- }
- }
- } else {
- plog("Install new chroot");
- plog('DEBUG', "... in $chroot_tmp");
- clean_chroot($chroot_tmp, $chroot_tar, $run, $config) or return;
- update_chroot($chroot_tmp, $run, $config);
- }
- $union_id, $chroot_tmp;
+ plog("Install new chroot");
+ plog('DEBUG', "... in $chroot_tmp");
+ clean_chroot($chroot_tmp, $chroot_tar, $run, $config) or return;
+ update_chroot($chroot_tmp, $run, $config);
+
+ $chroot_tmp;
}
sub remove_chroot {
@@ -329,53 +261,6 @@ sub clean_all_chroot_tmp {
closedir $dir;
}
-sub clean_unionfs {
- my ($unionfs_dir, $_run, $r, $union_id) = @_;
-
- -d "$unionfs_dir/unionfs.$r.$union_id" or return $union_id;
- plog(2, "cleaning unionfs $unionfs_dir/unionfs.$r.$union_id");
- my $nok = 1;
- my $path = "$unionfs_dir/unionfs.$r.$union_id";
-
- while ($nok) {
- $nok = 0;
- foreach my $fs ([ 'proc', 'proc' ], [ 'dev/pts', 'devpts' ]) {
- my ($dir, $type) = @$fs;
- if (-d "$path/$dir" && check_mounted("$path/$dir", $type)) {
- plog(1, "clean_unionfs: umounting $path/$dir\n");
- if (system("$sudo umount $path/$dir &>/dev/null")) {
- plog("ERROR: could not umount $path/$dir");
- }
- }
- }
- foreach my $t ('unionfs', 'tmpfs') {
- # unfortunately quite oftem the unionfs is busy and could not
- # be unmounted
-
- my $d = "$unionfs_dir/$t.$r.$union_id";
- if (-d $d && check_mounted($d, $t)) {
- $nok = 1;
- system("$sudo /sbin/fuser -k $d &> /dev/null");
- plog(3, "umounting $d");
- if (system(qq($sudo umount $d &> /dev/null))) {
- plog(2, "WARNING: could not umount $d ($!)");
- return $union_id + 1;
- }
- }
- }
- }
-
- foreach my $t ('unionfs', 'tmpfs') {
- my $d = "$unionfs_dir/$t.$r.$union_id";
- plog(2, "removing $d");
- if (system($sudo, 'rm', '-rf', $d)) {
- plog("ERROR: removing $d failed ($!)");
- return $union_id + 1;
- }
- }
- $union_id;
-}
-
sub clean_chroot_tmp {
my ($run, $chroot_dir, $dir) = @_;
my $d = "$chroot_dir/$dir";
@@ -590,24 +475,4 @@ sub check_chroot {
create_chroot($chroot, $chroot_tar, $run, $config, $opt);
}
-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 could not open $unionfs_dir ($!)");
- return;
- }
-
- foreach (readdir $dir) {
- /unionfs\.((?:0\.)?\d+)\.(\d*)$/ or next;
- clean_unionfs($unionfs_dir, $run, $1, $2);
- }
-
- closedir $dir;
-}
-
-
1;
diff --git a/lib/Iurt/Config.pm b/lib/Iurt/Config.pm
index 33d822f..0b27dc8 100644
--- a/lib/Iurt/Config.pm
+++ b/lib/Iurt/Config.pm
@@ -198,13 +198,13 @@ sub dump_cache_par {
plog('DEBUG', "loading cache file $filename");
$old_cache = eval(cat_($filename));
- foreach my $k ('rpm_srpm', 'failure', 'no_unionfs', 'queue', 'needed', 'warning', 'buildrequires') {
+ foreach my $k ('rpm_srpm', 'failure', 'queue', 'needed', 'warning', 'buildrequires') {
foreach my $rpm (%{$old_cache->{$k}}) {
$cache->{$k}{$rpm} ||= $old_cache->{$k}{$rpm};
}
}
}
- # $cache = { rpm_srpm => {}, failure => {}, queue => {}, warning => {}, run => 1, needed => {}, no_unionfs => {} }
+ # $cache = { rpm_srpm => {}, failure => {}, queue => {}, warning => {}, run => 1, needed => {} }
}
$Data::Dumper::Indent = 1;
$Data::Dumper::Terse = 1;
diff --git a/lib/Iurt/Urpmi.pm b/lib/Iurt/Urpmi.pm
index ad8709c..3ec70d3 100644
--- a/lib/Iurt/Urpmi.pm
+++ b/lib/Iurt/Urpmi.pm
@@ -294,7 +294,7 @@ sub get_local_provides {
}
sub get_build_requires {
- my ($self, $union_id, $luser) = @_;
+ my ($self, $luser) = @_;
my $run = $self->{run};
my $config = $self->{config};
my $cache = $run->{cache};
@@ -302,9 +302,8 @@ sub get_build_requires {
$run->{todo_requires} = {};
plog("get_build_requires");
- my ($u_id, $chroot_tmp) = create_temp_chroot($run, $config, $cache, $union_id, $run->{chroot_tmp}, $run->{chroot_tar}) or return;
+ my ($u_id, $chroot_tmp) = create_temp_chroot($run, $config, $cache, $run->{chroot_tmp}, $run->{chroot_tar}) or return;
add_local_user($chroot_tmp, $run, $config, $luser, $run->{uid}) or return;
- $union_id = $u_id;
my $urpm = new URPM;
foreach my $p (@{$run->{todo}}) {
@@ -322,7 +321,7 @@ sub get_build_requires {
}
sub order_packages {
- my ($self, $union_id, $provides, $luser) = @_;
+ my ($self, $provides, $luser) = @_;
my $run = $self->{run};
my @packages = @{$run->{todo}};
my $move;
@@ -330,7 +329,7 @@ sub order_packages {
plog(1, "order_packages");
get_local_provides($self) or return;
if (!$run->{todo_requires}) {
- get_build_requires($self, $union_id, $luser) or return;
+ get_build_requires($self, $luser) or return;
}
my %visit;
my %status;