diff options
Diffstat (limited to 'draklive2')
-rwxr-xr-x | draklive2 | 30 |
1 files changed, 13 insertions, 17 deletions
@@ -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; } |