diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-07-06 05:56:16 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-07-06 05:56:16 +0000 |
commit | 6379815088f02d4190f81403ec961a60e30b6759 (patch) | |
tree | 91255da29b74d7a55a93275ac9dca52a1d0bdf3c | |
parent | 2e92e5f731d006c1bbdd5ded2178664f23a23d83 (diff) | |
download | drakx-backup-do-not-use-6379815088f02d4190f81403ec961a60e30b6759.tar drakx-backup-do-not-use-6379815088f02d4190f81403ec961a60e30b6759.tar.gz drakx-backup-do-not-use-6379815088f02d4190f81403ec961a60e30b6759.tar.bz2 drakx-backup-do-not-use-6379815088f02d4190f81403ec961a60e30b6759.tar.xz drakx-backup-do-not-use-6379815088f02d4190f81403ec961a60e30b6759.zip |
- nicer "usage: ..."
- add actions "add-entry" and "remove-entry"
- add option --label
- add option --chainload
- rename --vmlinuz to --image
-rwxr-xr-x | perl-install/standalone/bootloader-config | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/perl-install/standalone/bootloader-config b/perl-install/standalone/bootloader-config index 75b615edd..2f1aed444 100755 --- a/perl-install/standalone/bootloader-config +++ b/perl-install/standalone/bootloader-config @@ -10,33 +10,46 @@ $::isStandalone = 1; #- not using standalone which messes with @ARGV and usage my %options = ( 'action=s' => \ (my $action), + + 'label=s' => \ (my $label), + + 'chainload=s' => \ (my $chainload), + + 'image=s' => \ (my $image), 'kernel-version=s' => \ (my $kernel_version), - 'vmlinuz=s' => \ (my $vmlinuz), 'initrd-options=s' => \ (my $initrd_options), - 'no-short-name' => \ (my $no_short_name), 'no-entry' => \ (my $no_entry), 'no-launch' => \ (my $no_launch), - 'no-initrd' => \ (my $no_initrd), + 'no-initrd' => \ (my $no_initrd), ); -GetOptions(%options) or die "usage: Releve " . join(' ', map { "[--$_]" } keys %options) . "\n"; +GetOptions(%options) or die <<'EOF'; +usage: Releve --action add-kernel (--image <vmlinuz> | --kernel-version <2.6.xxx>) [--label <...>] [--no-short-name] [--initrd-options <options>] + Releve --action remove-kernel (--image <vmlinuz> | --kernel-version <2.6.xxx>) + + Releve --action add-entry (--image <image> | --chainload <device>) --label <...> + Releve --action remove-entry (--image <image> | --chainload <device> | --label <...>) -my @known_actions = qw(add-kernel remove-kernel update-splash remove-splash detectloader); + Releve --action update-splash + Releve --action remove-splash +EOF + +my @known_actions = qw(add-kernel remove-kernel update-splash remove-splash detectloader add-entry remove-entry); $action && member($action, @known_actions) or die "<action> must be one of " . join(' ', @known_actions) . "\n"; -if ($vmlinuz) { - if (my $ver = bootloader::vmlinuz2version($vmlinuz)) { +if ($image) { + if (my $ver = bootloader::vmlinuz2version($image)) { if ($kernel_version) { - $kernel_version eq $ver or die "$kernel_version and $ver don't match (hint: don't pass both --vmlinuz and --kernel-version)\n"; + $kernel_version eq $ver or die "$kernel_version and $ver don't match (hint: don't pass both --image and --kernel-version)\n"; } else { $kernel_version = $ver; } } - $vmlinuz = "/boot/$vmlinuz" if $vmlinuz !~ m!^/!; + $image = "/boot/$image" if $image !~ m!^/!; } elsif ($kernel_version) { - $vmlinuz = "/boot/vmlinuz-$kernel_version"; + $image = "/boot/vmlinuz-$kernel_version"; } @@ -65,13 +78,13 @@ sub remove_kernel() { my ($to_remove, $to_keep) = partition { - $_->{kernel_or_dev} && $_->{kernel_or_dev} eq $vmlinuz; + $_->{kernel_or_dev} && $_->{kernel_or_dev} eq $image; } @{$bootloader->{entries}}; $_->{initrd} && unlink $_->{initrd} foreach @$to_remove; # foreach (@$to_keep) { -# $_->{kernel_or_dev} && bootloader::expand_vmlinuz_symlink($_->{kernel_or_dev}) eq $vmlinuz or next; +# $_->{kernel_or_dev} && bootloader::expand_vmlinuz_symlink($_->{kernel_or_dev}) eq $image or next; # } @{$bootloader->{entries}} = @$to_keep; @@ -85,7 +98,7 @@ sub remove_kernel() { sub add_kernel() { bootloader::create_link_source(); - my $kernel_str = bootloader::vmlinuz2kernel_str($vmlinuz); + my $kernel_str = bootloader::vmlinuz2kernel_str($image); $kernel_str->{use_long_name} = $no_short_name; my $root_part = fsedit::get_root([ fsedit::get_fstab(@$hds) ]); @@ -93,6 +106,7 @@ sub add_kernel() { { root => "/dev/$root_part->{device}", initrd_options => $initrd_options, + if_($label, label => $label), if_($bootloader->{default_vga}, vga => $bootloader->{default_vga}), }, $no_short_name, $no_initrd); @@ -107,6 +121,33 @@ sub modify_bootloader() { } #-############################################################################### +sub add_entry() { + $label or die "you must give a label\n"; + ($image xor $chainload) or die "you must give an image or a chainload\n"; + + my $entry = { + type => $image ? 'image' : 'other', + label => $label, + kernel_or_dev => $image || $other, + }; + bootloader::add_entry($bootloader, $entry); + modify_bootloader(); +} + +sub remove_entry() { + listlength(grep { $_ } $label, $image, $chainload) == 1 or die "you must give one of --label, --image and --chainload\n"; + + my $e = $label ? bootloader::get_label($label, $bootloader) : + find { $_->{kernel_or_dev} && $_->{kernel_or_dev} eq ($image || $chainload) } @{$bootloader->{entries}}; + + if ($e) { + @{$bootloader->{entries}} = grep { $_ != $e } @{$bootloader->{entries}}; + } + + modify_bootloader(); +} + +#-############################################################################### sub update_splash() { foreach (@{$bootloader->{entries}}) { bootloader::make_boot_splash($_->{initrd}, $_->{vga}) if $_->{initrd}; |