Accepting request 223322 from Base:System
- updating grub2-once - added --list switch. - improved --help and error handling. (forwarded request 223241 from jnweiger) OBS-URL: https://build.opensuse.org/request/show/223322 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=86
This commit is contained in:
commit
fa440d7e07
28
grub2-once
28
grub2-once
@ -1,4 +1,8 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# (C) 2014 mchang@suse.com
|
||||
#
|
||||
# 2014-02-20 jw@suse.de
|
||||
|
||||
use strict;
|
||||
|
||||
@ -37,9 +41,9 @@ if (@ARGV == 2 && ($ARGV[0] eq "--show-mapped")) {
|
||||
$id_name = $ARGV[0];
|
||||
}
|
||||
|
||||
die "wrong command line options" if ($id_name eq "");
|
||||
die "wrong command line options, try --help\n" if ($id_name eq "");
|
||||
|
||||
open(SYSCONF, "</etc/sysconfig/bootloader") || die "no bootloader sysconfig";
|
||||
open(SYSCONF, "</etc/sysconfig/bootloader") || die "cannot read bootloader sysconfig: $!\n";
|
||||
|
||||
$grub2_dir = "";
|
||||
while (<SYSCONF>) {
|
||||
@ -55,9 +59,16 @@ while (<SYSCONF>) {
|
||||
|
||||
close (SYSCONF);
|
||||
|
||||
if ($id_name eq "--help" or $id_name eq "-h")
|
||||
{
|
||||
print "Usage: grub2-once [--show-mapped ID | --list | ID | NAME_SUBSTRING ]\n";
|
||||
system "$grub2_reboot \"--help\"";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
die "no grub2_dir" if ($grub2_dir eq "");
|
||||
|
||||
open(MENU, "<$grub2_dir/grub.cfg") || die "no grub.cfg in $grub2_dir";
|
||||
open(MENU, "<$grub2_dir/grub.cfg") || die "cannot read grub.cfg in $grub2_dir: $!\n";
|
||||
undef $/;
|
||||
|
||||
while (<MENU>) {
|
||||
@ -70,6 +81,17 @@ my $ret = "";
|
||||
my $name = "";
|
||||
my $id = -1;
|
||||
|
||||
if ($id_name eq '--list')
|
||||
{
|
||||
my $c = 0;
|
||||
foreach my $e (@menuentry)
|
||||
{
|
||||
printf "%6d %s\n", $c, $e;
|
||||
$c++;
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($id_name =~ m!^[0-9]+$!) {
|
||||
|
||||
if ($id_name < @menuentry) {
|
||||
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 20 14:43:21 UTC 2014 - jw@suse.com
|
||||
|
||||
- updating grub2-once
|
||||
- added --list switch.
|
||||
- improved --help and error handling.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Feb 11 03:02:21 UTC 2014 - mchang@suse.com
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user