I've adapted the Replay code in DrakX to make it possible to have an
auto-install with selected stages being interactive, either via GTK, Newt
or (theoretically) stdio.

This introduces two new options into the auto-install configuration file:
$o => {
        'interactive' => 'gtk|newt|stdio',
        'interactiveSteps' => [
                                'e.g. doPartitionDisks',
                                'e.g. configureX',
                                'etc.'
                              ]
      }

'Old-style' interactivity specified via "$graphical=1" and "push
@graphical_steps, ..." will still work (the code will automatically create
the new options 'interactive' and 'interactiveSteps').

[ Note: I had to rearrange some code in install2.pm, so that 'interactive'
doesn't automatically get set to 'gtk'. ]

Here are the three patches:





--- install_steps_newt.pm.orig  Sat Jul 14 15:48:33 2001
+++ install_steps_newt.pm       Sat Jul 14 17:00:24 2001
@@ -22,6 +22,7 @@
     my $banner = translate(__("Linux-Mandrake Installation %s"));
     my $l = first(Newt::GetScreenSize) - length($banner) - length($_[0]) + 1;
     Newt::DrawRootText(0, 0, sprintf($banner, ' ' x $l . $_[0]));
+    Newt::Refresh;
 }

 sub new($$) {





--- install2.pm.orig    Sat Jul 14 18:36:38 2001
+++ install2.pm Sat Jul 14 18:53:23 2001
@@ -452,12 +452,6 @@
     modules::read_stage1_conf($_) foreach "/tmp/conf.modules", "/etc/modules.conf";
     modules::read_already_loaded();

-    $o->{interactive} ||= 'gtk';
-    if ($o->{interactive} eq "gtk" && availableMemory < 22 * 1024) {
-       log::l("switching to newt install cuz not enough memory");
-       $o->{interactive} = "newt";
-    }
-

     if ($::auto_install) {
        require install_steps_auto_install;
@@ -471,9 +465,16 @@
     }
     unless ($::auto_install) {
        $o->{interactive} ||= 'gtk';
-       require"install_steps_$o->{interactive}.pm";
     }

+
+    if ($o->{interactive} eq "gtk" && availableMemory < 22 * 1024) {
+       log::l("switching to newt install cuz not enough memory");
+       $o->{interactive} = "newt";
+    }
+    require "install_steps_$o->{interactive}.pm" if $o->{interactive};
+
+
     eval { $o = $::o = install_any::loadO($o, "patch") } if $patch;
     eval { $o = $::o = install_any::loadO($o, $cfg) } if $cfg;

@@ -510,7 +511,6 @@

     my $o_;
     while (1) {
-       require"install_steps_$o->{interactive}.pm";
        $o_ = $::auto_install ?
          install_steps_auto_install->new($o) :
            $o->{interactive} eq "stdio" ?






--- install_steps_auto_install.pm.orig  Sat Jul 14 11:14:50 2001
+++ install_steps_auto_install.pm       Sat Jul 14 18:40:06 2001
@@ -7,8 +7,6 @@

 @ISA = qw(install_steps);

-@graphical_steps = qw(enteringStep beforeInstallPackages installPackages);
-
 use modules;


@@ -22,19 +20,34 @@
 sub new {
     my ($type, $o) = @_;

-    if ($graphical) {
-       require install_steps_gtk;
-       push @ISA, 'interactive_gtk';
-       foreach my $f (@graphical_steps) {
+    # Handle legacy options
+    $o->{interactive} ||= ( $graphical ? 'gtk' : undef );
+    $o->{interactiveSteps} ||= [@graphical_steps];
+
+    if ($o->{interactive}) {
+        my $interactiveClass = "install_steps_$o->{interactive}";
+       require "$interactiveClass.pm";
+       push @ISA, "interactive_$o->{interactive}";
+       push @{$o->{interactiveSteps}}, qw(enteringStep formatMountPartitions 
+beforeInstallPackages installPackages);
+
+       *{"install_steps_auto_install::wait_message"} = sub {
+         local @ISA = ($interactiveClass, @ISA);
+         &{'interactive::wait_message'};
+       };
+
+       foreach my $f (@{$o->{interactiveSteps}}) {
            no strict 'refs';
-           my $pkg = $install_steps_gtk::{$f} ? 'install_steps_gtk' : 
'install_steps_interactive';
-           log::l("install_steps_auto_install: adding function ", $pkg, "::", $f);
-           *{"install_steps_auto_install::$f"} = sub {
-               local @ISA = ('install_steps_gtk', @ISA);
+           my $pkg = eval("\$${interactiveClass}::{$f}") ? $interactiveClass :
+              ( $install_steps_interactive::{$f} ? 'install_steps_interactive' : 
+undef );
+            if ( $pkg ) {
+             log::l("install_steps_auto_install: adding function ", $pkg, "::", $f);
+             *{"install_steps_auto_install::$f"} = sub {
+               local @ISA = ($interactiveClass, @ISA);
                &{$pkg . '::' . $f};
-           };
+             };
+           }
        }
-       goto &install_steps_gtk::new;
+       goto &{$interactiveClass.'::new'};
     } else {
        (bless {}, ref $type || $type)->SUPER::new($o);
     }


Reply via email to