
boottool takes a --bootloader=type option to suppress the autodetection.
However this has no effect as we always instantiate the base type and it
uses detection to work out which sub-class we are.

This patch contains two fixes.  Firstly, where we know which type of
bootloader we are using it specifically instaniates that type so that
we do not need to perform the redundant detection.  This is particularly
important where you are passing the type specifically because detection
is failing.

Secondly, it removes redundant new operators in each class which cause a
second object to be instantiated and the actual base class initialisation
occurs against a temporary object which is then lost.  This behaviour
prevents the use of the --config_file option when the objects are created
directly.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
 client/tools/boottool |   47 ++++-------------------------------------------
 1 files changed, 4 insertions(+), 43 deletions(-)
diff --git a/client/tools/boottool b/client/tools/boottool
index 725ae15..e980099 100755
--- a/client/tools/boottool
+++ b/client/tools/boottool
@@ -960,16 +960,6 @@ use base 'Linux::Bootloader';
 use vars qw( $VERSION );
 
 
-sub new {
-    my $this = shift;
-    my $class = ref($this) || $this;
-    my $self = bless({}, $class);
-
-    $self->SUPER::new();
-
-    return $self;
-}
-
 sub _set_config_file {
     my $self=shift;
     $self->{'config_file'}='/etc/elilo.conf';
@@ -1168,17 +1158,6 @@ use base 'Linux::Bootloader';
 use vars qw( $VERSION );
 
 
-sub new {
-    my $this = shift;
-    my $class = ref($this) || $this;
-    my $self = bless({}, $class);
-    #my $self = fields::new($class);
-
-    $self->SUPER::new();
-
-    return $self;
-}
-
 sub _set_config_file {
     my $self=shift;
     $self->{'config_file'}='/boot/grub/menu.lst';
@@ -1702,16 +1681,6 @@ use base 'Linux::Bootloader';
 use vars qw( $VERSION );
 
 
-sub new {
-    my $this = shift;
-    my $class = ref($this) || $this;
-    my $self = bless({}, $class);
-
-    $self->SUPER::new();
-
-    return $self;
-}
-
 sub _set_config_file {
     my $self=shift;
     $self->{'config_file'}='/etc/lilo.conf';
@@ -1840,17 +1809,6 @@ use base 'Linux::Bootloader';
 use vars qw( $VERSION );
 
 
-sub new {
-    my $this = shift;
-    my $class = ref($this) || $this;
-    my $self = bless({}, $class);
-
-    $self->SUPER::new();
-
-    return $self;
-}
-
-
 sub _set_config_file {
     my $self=shift;
     $self->{'config_file'}='/etc/yaboot.conf';
@@ -1974,7 +1932,10 @@ if (defined $params{'bootloader-probe'}) {
 
 my $bootloader;
 if ($detected_bootloader =~ m/^(grub|elilo|lilo|yaboot)$/) {
-  $bootloader = new Linux::Bootloader($params{config_file});
+  my $class = "Linux::Bootloader::" . "\u$detected_bootloader";
+  eval "require $class";
+  $bootloader = eval "new $class(\$params{config_file});";
+
 } else { 
   die "ERROR: Bootloader $detected_bootloader not recognized!\n";
 }
