summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-10 13:19:37 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-10 13:19:37 +0000
commit28f31f742d6fd72a3006ea011b354a3f4e158618 (patch)
treecb50d43c723ed4f0e1de38631d59eb0f9139cd98
parent886eebaca04d73edf3cfccf93836a0d5cf7428df (diff)
downloaddrakiso-28f31f742d6fd72a3006ea011b354a3f4e158618.tar
drakiso-28f31f742d6fd72a3006ea011b354a3f4e158618.tar.gz
drakiso-28f31f742d6fd72a3006ea011b354a3f4e158618.tar.bz2
drakiso-28f31f742d6fd72a3006ea011b354a3f4e158618.tar.xz
drakiso-28f31f742d6fd72a3006ea011b354a3f4e158618.zip
draklive2: clean up mounting/unmounting of external filesystems.
-rwxr-xr-xdraklive230
1 files changed, 13 insertions, 17 deletions
diff --git a/draklive2 b/draklive2
index 5ecb511..2fa83d9 100755
--- a/draklive2
+++ b/draklive2
@@ -28,6 +28,7 @@ use modules;
use run_program;
use Getopt::Long;
use Pod::Usage;
+use Cwd qw(abs_path);
use File::Temp;
use File::Copy qw(mv);
use IO::Handle; #- autoflush
@@ -51,20 +52,19 @@ sub get_langs {
sub mount_system_fs {
my ($live) = @_;
- run_('mount', '-t', 'devtmpfs', '/dev', $live->get_system_root . '/dev');
- run_('mount', '-t', 'proc', '/proc', $live->get_system_root . '/proc');
- run_('mount', '-t', 'sysfs', '/sys', $live->get_system_root . '/sys');
- run_('mount', '-t', 'debugfs', '/sys/kernel/debug/usb', $live->get_system_root . '/sys/kernel/debug/usb');
-}
-
-sub umount_system_fs {
- my ($live) = @_;
- eval { fs::mount::umount($live->get_system_root . $_) } foreach qw(/dev /proc /run /sys/kernel/debug/usb /sys);
+ run_('mount', '-t', 'devtmpfs', '/dev', $live->get_system_root . '/dev');
+ run_('mount', '-t', 'proc', '/proc', $live->get_system_root . '/proc');
+ run_('mount', '-t', 'sysfs', '/sys', $live->get_system_root . '/sys');
}
sub umount_external_fs {
my ($live) = @_;
- eval { fs::mount::umount($live->get_system_root . $_) } foreach map { "/mnt/$_" } all($live->get_system_root . "/mnt");
+ my $system_root = abs_path($live->get_system_root);
+ my @mounts = grep { $_ =~ $system_root } split("\n", cat_('/proc/mounts'));
+ foreach (reverse(@mounts)) {
+ my @field = split(' ' , $_);
+ fs::mount::umount($field[1]);
+ }
}
sub get_absolute_path {
@@ -224,7 +224,7 @@ sub post_install_system {
clean_system_conf_file($live, "/etc/resolv.conf");
write_dist_lists($live);
- umount_system_fs($live);
+ umount_external_fs($live);
umask $previous_umask;
}
@@ -311,9 +311,8 @@ sub write_dist_lists {
sub create_loopback_files {
my ($live) = @_;
- # umount filesystem in the live before creating the loopback
+ # make sure no external filesystems are mounted before creating the loopback
umount_external_fs($live);
- umount_system_fs($live);
my @excluded_files = expand_file_list($live, @{$live->{loopbacks}{exclude}{files} || []});
my @modules_files = expand_file_list($live, @{$live->{loopbacks}{modules} || []});
@@ -417,13 +416,11 @@ sub create_initrd {
my $initrd = $root . '/boot/' . $live->get_initrd_name;
unlink($initrd);
- mount_system_fs($live);
{
my $bootloader = {};
local $::prefix = $root;
bootloader::add_kernel($bootloader, $kernel, { label => 'linux', vga => $live->{system}{vga_mode} }, '', $live->{system}{no_initrd});
}
- umount_system_fs($live);
my $boot_dir = $live->get_builddir . $live->{prefix}{build}{boot};
mkdir_p($boot_dir);
@@ -868,9 +865,8 @@ sub build_iso_image {
sub clean {
my ($live) = @_;
- # umount filesystem in the live before cleaning
+ # make sure no external filesystems are mounted before cleaning
umount_external_fs($live);
- umount_system_fs($live);
rm_rf($_) foreach grep { -e $_ } $live->get_builddir, $live->get_system_root;
}