diff options
author | Olivier Blin <blino@mageia.org> | 2012-05-06 19:56:57 +0000 |
---|---|---|
committer | Olivier Blin <blino@mageia.org> | 2012-05-06 19:56:57 +0000 |
commit | f23c861fa4281617cc4349911dc1bc4e5fbc5830 (patch) | |
tree | 2107ad549ca3d05aef8809ae212c7e2a7afc58ea | |
parent | ee5f628326127b9aff0f32e7d74acccc5bd69b66 (diff) | |
download | drakiso-f23c861fa4281617cc4349911dc1bc4e5fbc5830.tar drakiso-f23c861fa4281617cc4349911dc1bc4e5fbc5830.tar.gz drakiso-f23c861fa4281617cc4349911dc1bc4e5fbc5830.tar.bz2 drakiso-f23c861fa4281617cc4349911dc1bc4e5fbc5830.tar.xz drakiso-f23c861fa4281617cc4349911dc1bc4e5fbc5830.zip |
factorize code mounting and unmounting system and external mountpoints
-rwxr-xr-x | draklive | 42 |
1 files changed, 23 insertions, 19 deletions
@@ -244,8 +244,7 @@ sub post_install_system { #- workaround buggy installation of directories that are not owned by any packages umask 022; - run_('mount', '-t', 'proc', '/proc', $live->get_system_root . '/proc'); - run_('mount', '-t', 'sysfs', '/sys', $live->get_system_root . '/sys'); + mount_system_fs($live); #- copy resolv.conf for name resolution to work when adding media cp_f("/etc/resolv.conf", $live->get_system_root . "/etc/"); @@ -361,9 +360,7 @@ EOF clean_system_conf_file($live, "/etc/resolv.conf"); write_dist_lists($live); - run_('umount', $live->get_system_root . '/sys'); - run_('umount', $live->get_system_root . '/proc/bus/usb'); - run_('umount', $live->get_system_root . '/proc'); + umount_system_fs($live); umask $previous_umask; } @@ -395,11 +392,20 @@ sub write_dist_lists { output_p($langs_file, map { lang::l2name($_) . " (" . $_ . ")\n" } sort(@langs)); } -sub umount_external_filesystem { +sub mount_system_fs { + my ($live) = @_; + run_('mount', '-t', 'proc', '/proc', $live->get_system_root . '/proc'); + run_('mount', '-t', 'sysfs', '/sys', $live->get_system_root . '/sys'); +} + +sub umount_system_fs { + my ($live) = @_; + eval { fs::mount::umount($live->get_system_root . $_) } foreach qw(/proc/bus/usb /proc /sys); +} + +sub umount_external_fs { my ($live) = @_; - eval { fs::mount::umount($live->get_system_root . $_) } foreach - (map { "/mnt/$_" } all($live->get_system_root . "/mnt")), - qw(/proc/bus/usb /proc /sys); + eval { fs::mount::umount($live->get_system_root . $_) } foreach map { "/mnt/$_" } all($live->get_system_root . "/mnt"); } sub expand_file_list { @@ -441,7 +447,8 @@ sub list_loopback_modules { sub create_loopback_files { my ($live) = @_; # umount filesystem in the live before creating the loopback - umount_external_filesystem($live); + 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} || []}); @@ -509,8 +516,7 @@ sub create_initrd { my ($live) = @_; my $root = $live->get_system_root; - run_('mount', '-t', 'proc', 'none', $root . '/proc'); - run_('mount', '-t', 'sysfs', 'none', $root . '/sys'); + mount_system_fs($live); if (!$use_dracut && need_media_specific_boot($live)) { MDV::Draklive::Initrd::create_media_initrd($live); @@ -518,8 +524,7 @@ sub create_initrd { MDV::Draklive::Initrd::create_classical_initrd($live); } - run_('umount', $root . '/sys'); - run_('umount', $root . '/proc'); + umount_system_fs($live); if (need_media_specific_boot($live)) { my $rootfs_initrd = $root . '/boot/' . $live->get_initrd_name; @@ -538,8 +543,7 @@ sub create_bootloader { -e $root . $vmlinuz_long or die "can not find kernel $kernel\n"; if ($live->{system}{gfxboot}) { - run_('mount', '-t', 'proc', 'none', $root . '/proc'); - run_('mount', '-t', 'sysfs', 'none', $root . '/sys'); + mount_system_fs($live); #- would be run by bootloader::add_boot_splash and make-boot-splash, but not called when we don't generate an initrd run_({ root => $root }, '/usr/share/bootsplash/scripts/switch-themes', '-u'); @@ -554,8 +558,7 @@ sub create_bootloader { warn "no gfxmenu file\n"; } - run_('umount', $root . '/sys'); - run_('umount', $root . '/proc'); + umount_system_fs($live); } # this will copy (among other things) the gfxboot theme to the media @@ -1622,7 +1625,8 @@ sub copy_wizard { sub clean { my ($live) = @_; # umount filesystem in the live before cleaning - umount_external_filesystem($live); + umount_external_fs($live); + umount_system_fs($live); rm_rf($_) foreach grep { -e $_ } $live->get_builddir, $live->get_system_root; } |