diff options
Diffstat (limited to 'perl-install/standalone/bootloader-config')
-rwxr-xr-x | perl-install/standalone/bootloader-config | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/perl-install/standalone/bootloader-config b/perl-install/standalone/bootloader-config index 1eea36be8..187ca3eed 100755 --- a/perl-install/standalone/bootloader-config +++ b/perl-install/standalone/bootloader-config @@ -54,7 +54,7 @@ if ($image) { } $image = "/boot/$image" if $image !~ m!^/!; } elsif ($kernel_version) { - $image = "/boot/vmlinuz-$kernel_version"; + $image = find { -e $_ } map { "/boot/$_-$kernel_version" } qw(vmlinux uImage vmlinuz); } @@ -64,6 +64,9 @@ fs::get_info_from_fstab($all_hds); my $bootloader = bootloader::read($all_hds); if (!$bootloader) { if (member($action, 'add-kernel', 'remove-kernel')) { + if ($no_initrd) { + die "Cannot find a bootloader installed and initrd build suppressed\n"; + } warn "Cannot find a boot loader installed. Only taking care of initrd\n"; } else { die "Cannot find a boot loader installed\n"; @@ -88,13 +91,19 @@ sub remove_kernel() { remove_now_broken_boot_symlinks(); if (!$bootloader) { - #- removing the initrd for weird configs where no mdv bootloader is configured + #- removing the initrd for weird configs where no mga bootloader is configured my $kernel_str = bootloader::vmlinuz2kernel_str($image) or die "bad kernel name $image\n"; my $initrd_long = bootloader::kernel_str2initrd_long($kernel_str); unlink "/boot/$initrd_long"; return; } + remove_kernel_generic() if bootloader::main_method($bootloader->{method}) ne 'grub2'; + + modify_bootloader(); +} + +sub remove_kernel_generic() { my %proposed_labels; my @new_entries; @@ -129,45 +138,44 @@ sub remove_kernel() { my ($kernel_str, $v) = @$_; bootloader::add_kernel($bootloader, $kernel_str, $v); } - - modify_bootloader(); } #-############################################################################### sub add_kernel() { configure_ide_controller(); - bootloader::create_link_source(); my $kernel_str = bootloader::vmlinuz2kernel_str($image) or die "bad kernel name $image\n"; if (!$bootloader) { - #- building the initrd for weird configs where no mdv bootloader is configured + #- building the initrd for weird configs where no mga bootloader is configured my $fake_bootloader = { vga => undef }; my %opts = (initrd_options => $initrd_options); my $initrd_long = bootloader::kernel_str2initrd_long($kernel_str); - bootloader::mkinitrd($kernel_str->{version}, $fake_bootloader, { %opts }, "/boot/$initrd_long"); + bootloader::mkinitrd($kernel_str->{version}, $fake_bootloader, \%opts, "/boot/$initrd_long"); return; } - my $root_part = fs::get::root([ fs::get::fstab($all_hds) ]) or die "can not find root partition\n"; + my $root_part = fs::get::root_([ fs::get::fstab($all_hds) ]) or warn "cannot find root partition in /etc/fstab\n"; + $root_part ||= fs::get::root_from_mounted() or die "cannot find root partition\n"; my %opts = ( root => fs::wild_device::from_part('', $root_part), initrd_options => $initrd_options, if_($label, label => $label), (grep_each { member($::a, 'vga', 'lock') } %{$bootloader->{default_options}}), ); - #- short name - bootloader::add_kernel($bootloader, $kernel_str, { %opts }, 0, $no_initrd) if !$no_short_name; - #- long name - $kernel_str->{use_long_name} = 1; - bootloader::add_kernel($bootloader, $kernel_str, { %opts }, 1, $no_initrd); + #- short name + bootloader::add_kernel($bootloader, $kernel_str, { %opts }, 0, $no_initrd) if !$no_short_name; + + #- long name + $kernel_str->{use_long_name} = 1; + bootloader::add_kernel($bootloader, $kernel_str, { %opts }, 1, $no_initrd); modify_bootloader(); } -sub configure_ide_controller { +sub configure_ide_controller() { my $modules_conf = modules::any_conf->read; if ($modules_conf->get_alias('ide-controller') || $modules_conf->get_probeall('ide-controller')) { @@ -269,7 +277,7 @@ sub migrate_to_uuids() { } } -sub _migrate_to_uuids__fstab() { +sub _migrate_to_uuids__fstab { my ($fstab) = @_; my @raw_fstab = fs::read_fstab('', '/etc/fstab', 'keep_freq_passno', 'verbatim_credentials'); @@ -279,10 +287,10 @@ sub _migrate_to_uuids__fstab() { _should_prefer_UUID($part) or next; my $part_ = find { fs::get::is_same_hd($part, $_) } @$fstab - or log::l("migrate_to_uuids: do not know $part->{device}, can not migrate it"), next; + or log::l("migrate_to_uuids: do not know $part->{device}, cannot migrate it"), next; $part->{device_UUID} = $part_->{device_UUID} - or log::l("migrate_to_uuids: no UUID for $part->{device}, can not migrate it"), next; + or log::l("migrate_to_uuids: no UUID for $part->{device}, cannot migrate it"), next; $part->{prefer_device_UUID} = 1; $part->{prefer_device} = 0; delete $part->{device_alias} if $part->{device_alias} && $part->{device_alias} =~ m!\bmapper/!; # see fs::dmraid::migrate_device_names() for more @@ -319,7 +327,7 @@ sub _add_uuid_to_swap { my $ids = fs::type::call_blkid($part); $ids->{ID_FS_VERSION} eq '2' - or log::l("ERROR: do not know swap version $ids->{ID_FS_VERSION}, so can not add UUID to it"), return; + or log::l("ERROR: do not know swap version $ids->{ID_FS_VERSION}, so cannot add UUID to it"), return; my $uuid = run_program::get_stdout('uuidgen'); log::l("adding UUID=$uuid to $part->{device}"); |