diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-04-27 16:01:29 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-04-27 16:01:29 +0000 |
commit | cb82d9b00802ca2df4f6355ae2516ceb5e4ac98d (patch) | |
tree | e1ac433fb8f7c36a358950578567b55c676e2552 /rescue/install_bootloader | |
parent | 5842eb000d9f2e23be3c368f88754e3c4daa36ea (diff) | |
download | drakx-backup-do-not-use-cb82d9b00802ca2df4f6355ae2516ceb5e4ac98d.tar drakx-backup-do-not-use-cb82d9b00802ca2df4f6355ae2516ceb5e4ac98d.tar.gz drakx-backup-do-not-use-cb82d9b00802ca2df4f6355ae2516ceb5e4ac98d.tar.bz2 drakx-backup-do-not-use-cb82d9b00802ca2df4f6355ae2516ceb5e4ac98d.tar.xz drakx-backup-do-not-use-cb82d9b00802ca2df4f6355ae2516ceb5e4ac98d.zip |
use module bootloader.pm to handle more bootloaders (esp. grub)
Diffstat (limited to 'rescue/install_bootloader')
-rwxr-xr-x | rescue/install_bootloader | 86 |
1 files changed, 46 insertions, 40 deletions
diff --git a/rescue/install_bootloader b/rescue/install_bootloader index 10812d41f..59248a016 100755 --- a/rescue/install_bootloader +++ b/rescue/install_bootloader @@ -12,46 +12,52 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # - -sub cat_ { local *F; open F, $_[0] or $_[1] ? die "cat of file $_[0] failed: $!\n" : return; my @l = <F>; wantarray ? @l : join '', @l } -sub chomp_ { my @l = map { my $l = $_; chomp $l; $l } @_; wantarray ? @l : $l[0] } - -system('guessmounts') and die; - -#- this is dangerous, try to take care -my @mounts = cat_('/proc/mounts'); -grep { (split)[1] =~ m|^/mnt$| } @mounts or die "Your root device isn't mounted on /mnt (according to /proc/mounts)\n"; --x '/mnt/sbin/lilo' or die "/mnt/sbin/lilo isn't executable, exiting.\n"; --r '/mnt/etc/lilo.conf' or die "/mnt/etc/lilo.conf isn't readable, exiting.\n"; -my ($f) = grep { -f $_ } map { "/mnt/etc/$_" } 'mandrakelinux-release', 'mandrake-release'; -$f && cat_($f) =~ /Mandrake/ or die "$f doesn't contain 'Mandrake', exiting.\n"; - -print "About to re-install Boot Loader of following Mandriva Linux distribution:\n\t", - chomp_(cat_ "/mnt/etc/mandrake-release"), +use lib qw(../perl-install /usr/lib/libDrakX); +use common; +use bootloader; +use fs; + +$::prefix = '/mnt'; + +my $release = common::mandrake_release($::prefix) || + do { + system('guessmounts') == 0 or die 'guessmounts failed'; + common::mandrake_release($::prefix); + }; + +if ($release) { + $release =~ /Mandrake|Mandriva/ or die "release file doesn't contain 'Mandriva', exiting.\n"; +} elsif (fs::get::mntpoint2part($::prefix, [ fs::read_fstab('', '/proc/mounts') ])) { + die "unknown distribution mounted in $::prefix\n"; +} else { + die "Your root device isn't mounted on $::prefix\n"; +} + +my @main_methods = bootloader::configured_main_methods(); + +my $main_method; +if (@main_methods == 0) { + die "Cannot find a configured boot loader\n"; +} elsif (@main_methods == 1) { + ($main_method) = @main_methods; +} else { + while (1) { + print "Configuration files for Boot Loaders ", join(' and ', @main_methods), " were found.\n"; + print "Which one one should be installed? "; + chomp($main_method = <STDIN>); + if (member($main_method, @main_methods)) { + last; + } else { + print "bad choice\n"; + } + } +} + +my $install = $bootloader::{'install_raw_' . $main_method} or die "unknown bootloader method install_raw_$main_method\n"; + +print "About to re-install Boot Loader $main_method of following Mandriva Linux distribution:\n\t", + $release, "\n=> ok? <press Enter to continue, 'n' and Enter to cancel> "; <STDIN> =~ /^n/i and exit 0; -exec '/mnt/sbin/lilo', '-r', '/mnt'; - -die "error: couldn't exec /mnt/sbin/lilo.\n"; - - -#------------------------------------------------- -#- $Log$ -#- Revision 1.4 2005/04/19 13:10:25 prigaux -#- mandriva switch -#- -#- Revision 1.3 2004/09/28 06:24:30 prigaux -#- handle /etc/mandrakelinux-release -#- -#- Revision 1.2 2004/07/20 02:42:12 prigaux -#- MandrakeSoft -> Mandrakesoft -#- -#- Revision 1.1 2001/10/24 22:34:01 gc -#- - add a GUI to the rescue -#- - provide guessmounts with better efficiency and output, go to console, and reboot -#- - provide install_bootloader which runs lilo from /mnt if it seems safe -#- - add lsparts to rescue, which prints partitions with detected types -#- -#- -#- +$install->(); |