SHA256
1
0
forked from pool/grub2

Accepting request 223241 from home:jnweiger:branches:Base:System

- updating grub2-once
  - added --list switch.
  - improved --help and error handling.

OBS-URL: https://build.opensuse.org/request/show/223241
OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=77
This commit is contained in:
Michael Chang 2014-02-21 03:09:36 +00:00 committed by Git OBS Bridge
parent 42797ef956
commit 929faf54e7
2 changed files with 32 additions and 3 deletions

View File

@ -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) {

View File

@ -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