From: Nishanth Aravamudan <[email protected]>

If no 'default' entry is in yaboot.conf (the only type of bootloader I
tested on), then boottool --set-default= will fail to change the default
and reboots will go back to the first listed kernel. Fix this by
determining if we have found a default line and if not, inserting one at
the top of the file.

Changes from v1:
 * Fixed perl syntax error

Signed-off-by: Nishanth Aravamudan <[email protected]>
---
 client/tools/boottool |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/client/tools/boottool b/client/tools/boottool
index 728e4ef..87c85ab 100755
--- a/client/tools/boottool
+++ b/client/tools/boottool
@@ -298,6 +298,7 @@ sub get_template {
 sub set_default {
   my $self=shift;
   my $newdefault=shift;
+  my $defaultfound=0;
 
   print ("Setting default.\n") if $self->debug()>1;
 
@@ -324,9 +325,13 @@ sub set_default {
   foreach my $index (0..$#config) {
     if ($config[$index] =~ /^\s*default/i) { 
       $config[$index] = "default=$newdefault   # set by $0\n"; 
+      $defaultfound=1;
       last;
     }
   }
+  if (!$defaultfound) {
+    unshift(@config, "default=$newdefault    # set by $0\n");
+  }
   @{$self->{config}} = @config;
 }
 
-- 
1.7.7.6

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to