summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2001-08-13 19:06:50 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2001-08-13 19:06:50 +0000
commit17b65ec06df7108085989f2e0398e1b834cd0358 (patch)
tree6c4a056dfeac594066fd7d41c621d390fedd3d17
parent0fc25337f6b7397a892d6724cb6dc3886d6f01f8 (diff)
downloaddrakx-backup-do-not-use-17b65ec06df7108085989f2e0398e1b834cd0358.tar
drakx-backup-do-not-use-17b65ec06df7108085989f2e0398e1b834cd0358.tar.gz
drakx-backup-do-not-use-17b65ec06df7108085989f2e0398e1b834cd0358.tar.bz2
drakx-backup-do-not-use-17b65ec06df7108085989f2e0398e1b834cd0358.tar.xz
drakx-backup-do-not-use-17b65ec06df7108085989f2e0398e1b834cd0358.zip
initial revision for drakautoinst
- put %installSteps in a separate package (steps.pm) (for drakxtools) - use additional fields {auto} and {noauto}, by step, to ease interactive auto install and oem stuff - in install2.pm, perform each step either from the interactive class or from install_steps, according to the {auto} flag - id, tell each step to not try to be automatic if {noauto} - in the install, have auto install bootdisk created in install_any so we can always write a bootdisk (from install_steps) for further use from drakautoinst in standalone - interactive version of install_steps_auto_install is now inheriting from the interactive class, so we can click on a previous automatic step and have it interactively during an interactive auto install
-rw-r--r--perl-install/install2.pm176
-rw-r--r--perl-install/install_any.pm83
-rw-r--r--perl-install/install_steps.pm1
-rw-r--r--perl-install/install_steps_auto_install.pm32
-rw-r--r--perl-install/install_steps_interactive.pm68
-rwxr-xr-xperl-install/standalone/drakautoinst137
-rw-r--r--perl-install/steps.pm51
7 files changed, 369 insertions, 179 deletions
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index 24f949d83..e838db001 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -8,6 +8,7 @@ use vars qw($o $version);
#-######################################################################################
#- misc imports
#-######################################################################################
+use steps;
use common;
use install_any qw(:all);
use install_steps;
@@ -26,53 +27,6 @@ use log;
use fs;
#-$::corporate=1;
-#-######################################################################################
-#- Steps table
-#-######################################################################################
-my (%installSteps, @orderedInstallSteps);
-{
- my @installStepsFields = qw(text redoable onError hidden needs icon);
- #entered reachable toBeDone next done;
- my @installSteps = (
- selectLanguage => [ __("Choose your language"), 1, 1, '', '', 'default' ],
- selectInstallClass => [ __("Select installation class"), 1, 1, '', '', 'default' ],
- setupSCSI => [ __("Hard drive detection"), 1, 0, '', '', 'harddrive' ],
- selectMouse => [ __("Configure mouse"), 1, 1, '', "selectInstallClass", 'mouse' ],
- selectKeyboard => [ __("Choose your keyboard"), 1, 1, '', "selectInstallClass", 'keyboard' ],
- miscellaneous => [ __("Security"), 1, 1, '!$::expert', '', 'security' ],
- doPartitionDisks => [ __("Setup filesystems"), 1, 0, '', "selectInstallClass", 'default' ],
- formatPartitions => [ __("Format partitions"), 1, -1, '$o->{isUpgrade}', "doPartitionDisks", 'default' ],
- choosePackages => [ __("Choose packages to install"), 1, -2, '!$::expert', "formatPartitions", 'default' ],
- installPackages => [ __("Install system"), 1, -1, '', ["formatPartitions", "selectInstallClass"], '' ],
- setRootPassword => [ __("Set root password"), 1, 1, '', "installPackages", 'rootpasswd' ],
- addUser => [ __("Add a user"), 1, 1, '', "installPackages", 'user' ],
- configureNetwork => [ __("Configure networking"), 1, 1, '', "formatPartitions", 'network' ],
-#- installCrypto => [ __("Cryptographic"), 1, 1, '!$::expert', "configureNetwork" ],
- summary => [ __("Summary"), 1, 0, '', "installPackages", 'default' ],
- configureServices => [ __("Configure services"), 1, 1, '!$::expert', "installPackages", 'services' ],
-if_((arch() !~ /alpha/) && (arch() !~ /ppc/),
- createBootdisk => [ __("Create a bootdisk"), 1, 0, '', "installPackages", 'bootdisk' ],
-),
- setupBootloader => [ __("Install bootloader"), 1, 1, '', "installPackages", 'bootloader' ],
- configureX => [ __("Configure X"), 1, 1, '', ["formatPartitions", "setupBootloader"], 'X' ],
- exitInstall => [ __("Exit install"), 0, 0, '!$::expert && !$::live', '', 'default' ],
-);
- for (my $i = 0; $i < @installSteps; $i += 2) {
- my %h; @h{@installStepsFields} = @{ $installSteps[$i + 1] };
- $h{next} = $installSteps[$i + 2];
- $h{entered} = 0;
- $h{onError} = $installSteps[$i + 2 * $h{onError}];
- $h{reachable} = !$h{needs};
- $installSteps{ $installSteps[$i] } = \%h;
- push @orderedInstallSteps, $installSteps[$i];
- }
- $installSteps{first} = $installSteps[0];
-}
-#-#####################################################################################
-#-INTERNAL CONSTANT
-#-#####################################################################################
-
-my @install_classes = qw(normal developer server);
#-#######################################################################################
#-$O
@@ -102,8 +56,8 @@ $o = $::o = {
#- keyboard => 'de',
#- display => "192.168.1.19:1",
- steps => \%installSteps,
- orderedSteps => \@orderedInstallSteps,
+ steps => \%steps::installSteps,
+ orderedSteps => \@steps::orderedInstallSteps,
#- for the list of fields available for user and superuser, see @etc_pass_fields in install_steps.pm
#- intf => { eth0 => { DEVICE => "eth0", IPADDR => '1.2.3.4', NETMASK => '255.255.255.128' } },
@@ -119,6 +73,13 @@ $o = $::o = {
};
+
+sub installStepsCall {
+ my ($o, $auto, $fun, @args) = @_;
+ eval($auto ? "install_steps::$fun".'($o, @args)' : '$o->'."$fun".'(@args)');
+ #- TODO check $@ (when the method doesn't exist for example) ? I fail to do that
+}
+
#-######################################################################################
#- Steps Functions
#- each step function are called with two arguments : clicked(because if you are a
@@ -127,7 +88,9 @@ $o = $::o = {
#------------------------------------------------------------------------------
sub selectLanguage {
- $o->selectLanguage($_[1] == 1);
+ my ($clicked, $ent_number, $auto) = @_;
+
+ installStepsCall($o, $auto, 'selectLanguage', $ent_number == 1);
addToBeDone {
lang::write_langs($o->{prefix}, $o->{langs});
@@ -140,24 +103,27 @@ sub selectLanguage {
#------------------------------------------------------------------------------
sub selectMouse {
+ my ($clicked, $ent_number, $auto) = @_;
+
require pkgs;
- my ($first_time) = $_[1] == 1;
+ my ($first_time) = $ent_number == 1;
add2hash($o->{mouse} ||= {}, mouse::read($o->{prefix})) if $o->{isUpgrade} && $first_time;
- $o->selectMouse(!$first_time);
+ installStepsCall($o, $auto, 'selectMouse', !$first_time || $clicked);
+
addToBeDone { mouse::write($o->{prefix}, $o->{mouse}) } 'installPackages';
}
#------------------------------------------------------------------------------
sub setupSCSI {
- my ($clicked) = @_;
- $o->setupSCSI($clicked);
+ my ($clicked, $ent_number, $auto) = @_;
+ installStepsCall($o, $auto, 'setupSCSI', $clicked);
}
#------------------------------------------------------------------------------
sub selectKeyboard {
- my ($clicked, $first_time) = ($_[0], $_[1] == 1);
+ my ($clicked, $first_time, $auto) = ($_[0], $_[1] == 1, $_[2]);
if ($o->{isUpgrade} && $first_time && $o->{keyboard_unsafe}) {
my $keyboard = keyboard::read($o->{prefix});
@@ -165,18 +131,18 @@ sub selectKeyboard {
}
return if !$::expert && !$clicked;
- $o->selectKeyboard($clicked);
+ installStepsCall($o, $auto, 'selectKeyboard', $clicked);
}
#------------------------------------------------------------------------------
sub selectInstallClass {
- my ($clicked) = @_;
+ my ($clicked, $ent_number, $auto) = @_;
+
+ installStepsCall($o, $auto, 'selectInstallClass', $clicked);
- $o->selectInstallClass($clicked);
-
if ($o->{steps}{choosePackages}{entered} >= 1 && !$o->{steps}{installPackages}{done}) {
- $o->setPackages(\@install_classes);
- $o->selectPackagesToUpgrade if $o->{isUpgrade};
+ installStepsCall($o, $auto, 'setPackages');
+ installStepsCall($o, $auto, 'selectPackagesToUpgrade') if $o->{isUpgrade};
}
if ($o->{isUpgrade}) {
@{$o->{orderedSteps}} = map { /setupSCSI/ ? ($_, "doPartitionDisks") : $_ }
@@ -190,16 +156,19 @@ sub selectInstallClass {
#------------------------------------------------------------------------------
sub doPartitionDisks {
+ my ($clicked, $ent_number, $auto) = @_;
$o->{steps}{formatPartitions}{done} = 0;
- $o->doPartitionDisksBefore;
- $o->doPartitionDisks;
- $o->doPartitionDisksAfter;
+ installStepsCall($o, $auto, 'doPartitionDisksBefore');
+ installStepsCall($o, $auto, 'doPartitionDisks');
+ installStepsCall($o, $auto, 'doPartitionDisksAfter');
}
sub formatPartitions {
+ my ($clicked, $ent_number, $auto) = @_;
+
$o->{steps}{choosePackages}{done} = 0;
- $o->choosePartitionsToFormat($o->{fstab}) unless $o->{isUpgrade};
- $o->formatMountPartitions($o->{fstab}) unless $::testing;
+ installStepsCall($o, $auto, 'choosePartitionsToFormat', $o->{fstab}) unless $o->{isUpgrade};
+ installStepsCall($o, $auto, 'formatMountPartitions', $o->{fstab}) unless $::testing;
mkdir "$o->{prefix}/$_", 0755 foreach
qw(dev etc etc/profile.d etc/rpm etc/sysconfig etc/sysconfig/console
@@ -230,13 +199,14 @@ sub formatPartitions {
#------------------------------------------------------------------------------
sub choosePackages {
+ my ($clicked, $ent_number, $auto) = @_;
require pkgs;
#- always setPackages as it may have to copy hdlist files and depslist file.
- $o->setPackages;
- $o->selectPackagesToUpgrade if $o->{isUpgrade} && $_[1] == 1;
+ installStepsCall($o, $auto, 'setPackages');
+ installStepsCall($o, $auto, 'selectPackagesToUpgrade') if $o->{isUpgrade} && $ent_number == 1;
- $o->choosePackages($o->{packages}, $o->{compssUsers}, $_[1] == 1);
+ installStepsCall($o, $auto, 'choosePackages', $o->{packages}, $o->{compssUsers}, $ent_number == 1);
log::l("compssUsersChoice's: ", join(" ", grep { $o->{compssUsersChoice}{$_} } keys %{$o->{compssUsersChoice}}));
#- check pre-condition where base backage has to be selected.
@@ -248,16 +218,20 @@ sub choosePackages {
#------------------------------------------------------------------------------
sub installPackages {
- $o->readBootloaderConfigBeforeInstall if $_[1] == 1;
+ my ($clicked, $ent_number, $auto) = @_;
+
+ installStepsCall($o, $auto, 'readBootloaderConfigBeforeInstall') if $ent_number == 1;
- $o->beforeInstallPackages;
- $o->installPackages;
- $o->afterInstallPackages;
+ installStepsCall($o, $auto, 'beforeInstallPackages');
+ installStepsCall($o, $auto, 'installPackages');
+ installStepsCall($o, $auto, 'afterInstallPackages');
}
#------------------------------------------------------------------------------
sub miscellaneous {
- $o->miscellaneousBefore($_[0]);
- $o->miscellaneous($_[0]);
+ my ($clicked, $ent_number, $auto) = @_;
+
+ installStepsCall($o, $auto, 'miscellaneousBefore', $clicked);
+ installStepsCall($o, $auto, 'miscellaneous', $clicked);
addToBeDone {
setVarsInSh("$o->{prefix}/etc/sysconfig/system", {
@@ -272,64 +246,81 @@ sub miscellaneous {
}
#------------------------------------------------------------------------------
-sub summary { $o->summary($_[1] == 1) }
+sub summary {
+ my ($clicked, $ent_number, $auto) = @_;
+ installStepsCall($o, $auto, 'summary', $ent_number == 1);
+}
#------------------------------------------------------------------------------
sub configureNetwork {
+ my ($clicked, $ent_number, $auto) = @_;
#- get current configuration of network device.
require network;
eval { network::read_all_conf($o->{prefix}, $o->{netc} ||= {}, $o->{intf} ||= {}) };
- $o->configureNetwork($_[1] == 1);
+ installStepsCall($o, $auto, 'configureNetwork', $ent_number == 1);
}
#------------------------------------------------------------------------------
-sub installCrypto { $o->installCrypto }
+sub installCrypto {
+ my ($clicked, $ent_number, $auto) = @_;
+ installStepsCall($o, $auto, 'installCrypto');
+}
#------------------------------------------------------------------------------
-sub configureServices { $o->configureServices($_[0]) }
+sub configureServices {
+ my ($clicked, $ent_number, $auto) = @_;
+ installStepsCall($o, $auto, 'configureServices', $clicked);
+}
#------------------------------------------------------------------------------
sub setRootPassword {
+ my ($clicked, $ent_number, $auto) = @_;
return if $o->{isUpgrade};
- $o->setRootPassword($_[0]);
+ installStepsCall($o, $auto, 'setRootPassword', $clicked);
addToBeDone { install_any::setAuthentication($o) } 'installPackages';
}
#------------------------------------------------------------------------------
sub addUser {
- return if $o->{isUpgrade} && !$_[0];
+ my ($clicked, $ent_number, $auto) = @_;
+ return if $o->{isUpgrade} && !$clicked;
- $o->addUser($_[0]);
+ installStepsCall($o, $auto, 'addUser', $clicked);
}
#------------------------------------------------------------------------------
sub createBootdisk {
+ my ($clicked, $ent_number, $auto) = @_;
modules::write_conf($o->{prefix});
- $o->createBootdisk($_[1] == 1);
+ installStepsCall($o, $auto, 'createBootdisk', $ent_number == 1);
}
#------------------------------------------------------------------------------
sub setupBootloader {
+ my ($clicked, $ent_number, $auto) = @_;
return if $::g_auto_install;
modules::write_conf($o->{prefix});
- $o->setupBootloaderBefore if $_[1] == 1;
- $o->setupBootloader($_[1] - 1);
-
+ installStepsCall($o, $auto, 'setupBootloaderBefore') if $ent_number == 1;
+ installStepsCall($o, $auto, 'setupBootloader', $ent_number - 1);
+
local $ENV{DRAKX_PASSWORD} = $o->{bootloader}{password};
local $ENV{DURING_INSTALL} = 1;
run_program::rooted($o->{prefix}, "/usr/sbin/msec", $o->{security});
}
#------------------------------------------------------------------------------
sub configureX {
- my ($clicked) = @_;
+ my ($clicked, $ent_number, $auto) = @_;
#- done here and also at the end of install2.pm, just in case...
install_any::write_fstab($o);
modules::write_conf($o->{prefix});
require pkgs;
- $o->configureX($clicked) if pkgs::packageFlagInstalled(pkgs::packageByName($o->{packages}, 'XFree86')) && !$o->{X}{disabled} || $clicked || $::testing;
+ installStepsCall($o, $auto, 'configureX', $clicked) if pkgs::packageFlagInstalled(pkgs::packageByName($o->{packages}, 'XFree86')) && !$o->{X}{disabled} || $clicked || $::testing;
}
#------------------------------------------------------------------------------
-sub exitInstall { $o->exitInstall(getNextStep() eq "exitInstall") }
+sub exitInstall {
+ my ($clicked, $ent_number, $auto) = @_;
+ installStepsCall($o, $auto, 'exitInstall', getNextStep() eq 'exitInstall');
+}
#-######################################################################################
@@ -507,9 +498,8 @@ sub main {
}
foreach (@auto) {
- eval "undef *" . (!/::/ && "install_steps_interactive::") . $_;
my $s = $o->{steps}{/::(.*)/ ? $1 : $_} or next;
- $s->{hidden} = 1;
+ $s->{auto} = $s->{hidden} = 1;
}
my $o_;
@@ -554,7 +544,9 @@ sub main {
$o->enteringStep($o->{step});
$o->{steps}{$o->{step}}{icon} and $o->{icon} = $o->{steps}{$o->{step}}{icon};
eval {
- &{$install2::{$o->{step}}}($clicked, $o->{steps}{$o->{step}}{entered});
+ &{$install2::{$o->{step}}}($clicked || $o->{steps}{$o->{step}}{noauto},
+ $o->{steps}{$o->{step}}{entered},
+ $clicked ? 0 : $o->{steps}{$o->{step}}{auto});
};
my $err = $@;
$o->kill_action;
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index ed68a29f3..3e50d5b9c 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -625,7 +625,7 @@ sub g_auto_install {
my @fields = qw(mntpoint type size);
$o->{partitions} = [ map { my %l; @l{@fields} = @$_{@fields}; \%l } grep { $_->{mntpoint} } @{$::o->{fstab}} ];
- exists $::o->{$_} and $o->{$_} = $::o->{$_} foreach qw(lang authentication printer mouse wacom netc timezone superuser intf keyboard users partitioning isUpgrade manualFstab nomouseprobe crypto security netcnx useSupermount autoExitInstall); #- TODO modules bootloader
+ exists $::o->{$_} and $o->{$_} = $::o->{$_} foreach qw(lang authentication printer mouse wacom netc timezone superuser intf keyboard users partitioning isUpgrade manualFstab nomouseprobe crypto security netcnx useSupermount autoExitInstall mkbootdisk); #- TODO modules bootloader
if (my $card = $::o->{X}{card}) {
$o->{X}{$_} = $::o->{X}{$_} foreach qw(default_depth resolution_wanted);
@@ -655,12 +655,91 @@ sub g_auto_install {
Data::Dumper->Dump([$o], ['$o']), if_($replay,
qq(\npackage install_steps_auto_install;), q(
$graphical = 1;
-push @graphical_steps, 'doPartitionDisks', 'choosePartitionsToFormat', 'formatMountPartitions';
+push @graphical_steps, 'doPartitionDisks', 'formatPartitions';
)), "\0");
$str =~ s/ {8}/\t/g; #- replace all 8 space char by only one tabulation, this reduces file size so much :-)
$str;
}
+sub getAndSaveInstallFloppy {
+ my ($o, $where) = @_;
+ my $image = cat_("/proc/cmdline") =~ /pcmcia/ ? "pcmcia" :
+ ${{ hd => 'hd', cdrom => 'cdrom', ftp => 'network', nfs => 'network', http => 'network' }}{$o->{method}};
+ $image .= arch() =~ /sparc64/ && "64"; #- for sparc64 there are a specific set of image.
+ install_any::getAndSaveFile("images/$image.img", $where) or log::l("failed to write Install Floppy ($image.img) to $where"), return;
+ 1;
+}
+
+sub getAndSaveAutoInstallFloppy {
+ my ($o, $replay, $where) = @_;
+
+ eval { modules::load('loop') };
+
+ if (arch() =~ /sparc/) {
+ my $imagefile = "$o->{prefix}/tmp/autoinst.img";
+ my $mountdir = "$o->{prefix}/tmp/mount"; -d $mountdir or mkdir $mountdir, 0755;
+ my $workdir = "$o->{prefix}/tmp/work"; -d $workdir or rmdir $workdir;
+
+ install_any::getAndSaveInstallFloppy($o, $imagefile) or return;
+ devices::make($_) foreach qw(/dev/loop6 /dev/ram);
+
+ require commands;
+ run_program::run("losetup", "/dev/loop6", $imagefile);
+ fs::mount("/dev/loop6", $mountdir, "romfs", 'readonly');
+ commands::cp("-f", $mountdir, $workdir);
+ fs::umount($mountdir);
+ run_program::run("losetup", "-d", "/dev/loop6");
+
+ substInFile { s/timeout.*//; s/^(\s*append\s*=\s*\".*)\"/$1 kickstart=floppy\"/ } "$workdir/silo.conf"; #" for po
+#-TODO output "$workdir/ks.cfg", install_any::generate_ks_cfg($o);
+ output "$workdir/boot.msg", "\n7m",
+"!! If you press enter, an auto-install is going to start.
+ ALL data on this computer is going to be lost,
+ including any Windows partitions !!
+", "7m\n";
+
+ local $o->{partitioning}{clearall} = 1;
+ output("$workdir/auto_inst.cfg", install_any::g_auto_install());
+
+ run_program::run("genromfs", "-d", $workdir, "-f", "/dev/ram", "-A", "2048,/..", "-a", "512", "-V", "DrakX autoinst");
+ fs::mount("/dev/ram", $mountdir, 'romfs', 0);
+ run_program::run("silo", "-r", $mountdir, "-F", "-i", "/fd.b", "-b", "/second.b", "-C", "/silo.conf");
+ fs::umount($mountdir);
+ commands::dd("if=/dev/ram", "of=$where", "bs=1440", "count=1024");
+
+ commands::rm("-rf", $workdir, $mountdir, $imagefile);
+ } else {
+ my $imagefile = "$o->{prefix}/tmp/autoinst.img";
+ my $mountdir = "$o->{prefix}/tmp/mount"; -d $mountdir or mkdir $mountdir, 0755;
+
+ my $param = 'kickstart=floppy ' . install_any::generate_automatic_stage1_params($o);
+
+ install_any::getAndSaveInstallFloppy($o, $imagefile) or return;
+
+ my $dev = devices::set_loop($imagefile) or log::l("couldn't set loopback device"), return;
+ fs::mount($dev, $mountdir, 'vfat', 0);
+
+ substInFile {
+ s/timeout.*/$replay ? 'timeout 1' : ''/e;
+ s/^(\s*append)/$1 $param/
+ } "$mountdir/syslinux.cfg";
+
+ unlink "$mountdir/help.msg";
+ output "$mountdir/boot.msg", "\n0c",
+"!! If you press enter, an auto-install is going to start.
+ All data on this computer is going to be lost,
+ including any Windows partitions !!
+", "07\n" if !$replay;
+
+ local $o->{partitioning}{clearall} = !$replay;
+ output("$mountdir/auto_inst.cfg", install_any::g_auto_install($replay));
+
+ fs::umount($mountdir);
+ commands::dd("if=$imagefile", "of=$where", "bs=1440", "count=1024");
+ }
+ 1;
+}
+
sub g_default_packages {
my ($o, $quiet) = @_;
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index cef639702..12709e297 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -899,6 +899,7 @@ sub miscellaneous {
sub exitInstall {
my ($o) = @_;
eval { output "$o->{prefix}/root/report.bug", install_any::report_bug($o->{prefix}) };
+ install_any::getAndSaveAutoInstallFloppy($o, 1, "$o->{prefix}/root/replay_install.img");
install_any::unlockCdrom;
install_any::log_sizes($o);
}
diff --git a/perl-install/install_steps_auto_install.pm b/perl-install/install_steps_auto_install.pm
index 4e48dc8a5..a7870240d 100644
--- a/perl-install/install_steps_auto_install.pm
+++ b/perl-install/install_steps_auto_install.pm
@@ -23,31 +23,22 @@ sub new {
# Handle legacy options
$o->{interactive} ||= 'gtk' if $graphical || !is_empty_array_ref($o->{interactiveSteps});
$o->{interactiveSteps} ||= [ @graphical_steps ];
- push @{$o->{interactiveSteps}}, qw(enteringStep formatMountPartitions beforeInstallPackages installPackages);
+ push @{$o->{interactiveSteps}}, qw(formatPartitions installPackages);
if ($o->{interactive}) {
- push @ISA, "interactive_$o->{interactive}";
-
my $interactiveClass = "install_steps_$o->{interactive}";
require"$interactiveClass.pm"; #- no space to skip perl2fcalls
- #- remove the empty wait_message
- undef *wait_message;
-
- foreach my $f (@{$o->{interactiveSteps}}) {
- foreach my $pkg ($interactiveClass, 'install_steps_interactive') {
- if ($::{$pkg . "::"}{$f}) {
- log::l("install_steps_auto_install: adding function ", $pkg, "::", $f);
-
- no strict 'refs';
- *{"install_steps_auto_install::$f"} = sub {
- local @ISA = ($interactiveClass, @ISA);
- &{$::{$pkg . "::"}{$f}};
- };
- last;
- }
- }
- }
+ @ISA = ($interactiveClass, @ISA);
+
+ #- remove our non-interactive stuff
+ eval "undef *$_" foreach qw(configureNetwork enteringStep ask_warn wait_message errorInStep installPackages);
+
+ my $f = $o->{steps}{first};
+ do {
+ member($f, @{$o->{interactiveSteps}}) ? $o->{steps}{$f}{noauto} = 1 : $o->{steps}{$f}{auto} = 1;
+ } while ($f = $o->{steps}{$f}{next});
+
goto &{$::{$interactiveClass . "::"}{new}};
} else {
(bless {}, ref $type || $type)->SUPER::new($o);
@@ -69,6 +60,7 @@ sub enteringStep {
sub ask_warn {
log::l(ref $_[1] ? join " ", @{$_[1]} : $_[1]);
}
+
sub wait_message {}
sub errorInStep {
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 057f5e399..bc33ad6e8 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -1138,77 +1138,15 @@ sub generateAutoInstFloppy {
my ($o, $replay) = @_;
my $floppy = detect_devices::floppy();
-#+ $o->ask_yesorno('',
-#+_("Do you want to generate an auto install floppy for linux replication?"), $floppy) or return;
$o->ask_okcancel('', _("Insert a blank floppy in drive %s", $floppy), 1) or return;
my $dev = devices::make($floppy);
-
- my $image = cat_("/proc/cmdline") =~ /pcmcia/ ? "pcmcia" :
- ${{ hd => 'hd', cdrom => 'cdrom', ftp => 'network', nfs => 'network', http => 'network' }}{$o->{method}};
-
- if (arch() =~ /sparc/) {
- $image .= arch() =~ /sparc64/ && "64"; #- for sparc64 there are a specific set of image.
-
- my $imagefile = "$o->{prefix}/tmp/autoinst.img";
- my $mountdir = "$o->{prefix}/tmp/mount"; -d $mountdir or mkdir $mountdir, 0755;
- my $workdir = "$o->{prefix}/tmp/work"; -d $workdir or rmdir $workdir;
-
+ {
my $w = $o->wait_message('', _("Creating auto install floppy"));
- install_any::getAndSaveFile("images/$image.img", $imagefile) or log::l("failed to write $dev"), return;
- devices::make($_) foreach qw(/dev/loop6 /dev/ram);
-
- require commands;
- run_program::run("losetup", "/dev/loop6", $imagefile);
- fs::mount("/dev/loop6", $mountdir, "romfs", 'readonly');
- commands::cp("-f", $mountdir, $workdir);
- fs::umount($mountdir);
- run_program::run("losetup", "-d", "/dev/loop6");
-
- substInFile { s/timeout.*//; s/^(\s*append\s*=\s*\".*)\"/$1 kickstart=floppy\"/ } "$workdir/silo.conf"; #" for po
-#-TODO output "$workdir/ks.cfg", install_any::generate_ks_cfg($o);
- output "$workdir/boot.msg", "\n7m",
-"!! If you press enter, an auto-install is going to start.
- ALL data on this computer is going to be lost,
- including any Windows partitions !!
-", "7m\n";
-
- local $o->{partitioning}{clearall} = 1;
- output("$workdir/auto_inst.cfg", install_any::g_auto_install());
-
- run_program::run("genromfs", "-d", $workdir, "-f", "/dev/ram", "-A", "2048,/..", "-a", "512", "-V", "DrakX autoinst");
- fs::mount("/dev/ram", $mountdir, 'romfs', 0);
- run_program::run("silo", "-r", $mountdir, "-F", "-i", "/fd.b", "-b", "/second.b", "-C", "/silo.conf");
- fs::umount($mountdir);
- commands::dd("if=/dev/ram", "of=$dev", "bs=1440", "count=1024");
-
- commands::rm("-rf", $workdir, $mountdir, $imagefile);
- } else {
- my $param = 'kickstart=floppy ' . install_any::generate_automatic_stage1_params($o);
- {
- my $w = $o->wait_message('', _("Creating auto install floppy"));
- install_any::getAndSaveFile("images/$image.img", $dev) or log::l("failed to write $dev"), return;
- }
- fs::mount($dev, "/floppy", "vfat", 0);
- substInFile {
- s/timeout.*/$replay ? 'timeout 1' : ''/e;
- s/^(\s*append)/$1 $param/
- } "/floppy/syslinux.cfg";
-
- unlink "/floppy/help.msg";
- output "/floppy/boot.msg", "\n0c",
-"!! If you press enter, an auto-install is going to start.
- All data on this computer is going to be lost,
- including any Windows partitions !!
-", "07\n" if !$replay;
-
- local $o->{partitioning}{clearall} = !$replay;
- output("/floppy/auto_inst.cfg", install_any::g_auto_install($replay));
-
- fs::umount("/floppy");
- common::sync(); #- if you shall remove the floppy right after the LED switches off
+ install_any::getAndSaveAutoInstallFloppy($o, $replay, $dev) or return;
}
+ common::sync(); #- if you shall remove the floppy right after the LED switches off
}
#------------------------------------------------------------------------------
diff --git a/perl-install/standalone/drakautoinst b/perl-install/standalone/drakautoinst
new file mode 100755
index 000000000..070c1d8dc
--- /dev/null
+++ b/perl-install/standalone/drakautoinst
@@ -0,0 +1,137 @@
+#!/usr/bin/perl
+
+#
+# Guillaume Cottenceau (gc@mandrakesoft.com)
+#
+# Copyright 2001 MandrakeSoft
+#
+# This software may be freely redistributed under the terms of the GNU
+# public license.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+use lib qw(..);
+
+use common;
+use interactive;
+use standalone;
+use devices;
+use detect_devices;
+use steps;
+use commands;
+use fs;
+
+$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/;
+
+
+local $_ = join '', @ARGV;
+
+/-h/ and die "usage: drakautoinst [--version]\n";
+/-version/ and die 'version: $Id$ '."\n";
+$::direct = /-direct/;
+
+
+my $in = 'interactive'->vnew('su', 'default');
+
+begin:
+$::isEmbedded and kill USR2, $::CCPID;
+
+$::direct or $in->ask_okcancel(_("Auto Install Configurator"),
+_("You are about to configure an Auto Install floppy. This feature is somewhat dangerous and must be used circumspectly.
+
+With that feature, you will be able to replay the installation you've performed on this computer, being interactively prompted for some steps, in order to change their values.
+
+For maximum safety, the partitioning and formatting will never be performed automatically, whatever you chose during the install of this computer.
+
+Do you want to continue?"), 1) or quit_global($in, 0);
+
+
+my @manual_steps = qw(doPartitionDisks formatPartitions);
+my @all_steps;
+my @choices;
+
+my $st = \%steps::installSteps;
+
+for (my $f = $st->{first}; $f; $f = $st->{$f}{next}) {
+ next if member($f, @manual_steps);
+ my $def_choice = 'replay';
+ push @choices, { label => _($st->{$f}{text}), val => \$def_choice, list => [ 'replay', 'manual' ] };
+ push @all_steps, [ $f, \$def_choice ];
+}
+
+$in->ask_from_entries_refH(_("Automatic Steps Configuration"),
+ _("Please choose for each step whether it will replay like your install, or it will be manual"),
+ \@choices
+ ) or quit_global($in, 0);
+
+${$_->[1]} eq 'manual' and push @manual_steps, $_->[0] foreach @all_steps;
+
+
+my $imagefile = "/root/replay_install.img";
+-f $imagefile or $in->ask_okcancel(_("Error!"),
+ _("I can't find needed image file `%s'.", $imagefile), 1), quit_global($in, 0);
+my $mountdir = "/root/tmp/drakautoinst-mountdir"; -d $mountdir or mkdir $mountdir, 0755;
+my $floppy = detect_devices::floppy();
+my $dev = devices::make($floppy);
+$in->ask_okcancel('', _("Insert a blank floppy in drive %s", $floppy), 1) or quit_global($in, 0);
+{
+ my $w = $in->wait_message('', _("Creating auto install floppy"));
+ commands::dd("if=$imagefile", "of=$dev", "bs=1440", "count=1024");
+ common::sync();
+}
+fs::mount($dev, $mountdir, 'vfat', 0);
+
+my $cfgfile = "$mountdir/auto_inst.cfg";
+eval(cat_($cfgfile));
+
+require Data::Dumper;
+my $str = join('',
+"#!/usr/bin/perl -cw
+#
+# Special file generated by ``drakautoinst''.
+#
+# You should check the syntax of this file before using it in an auto-install.
+# You can do this with 'perl -cw auto_inst.cfg.pl' or by executing this file
+# (note the '#!/usr/bin/perl -cw' on the first line).
+",
+ Data::Dumper->Dump([$o], ['$o']), q(
+package install_steps_auto_install;
+$graphical = 1;
+), Data::Dumper->Dump([\@manual_steps], ['$msteps']),
+q(push @graphical_steps, @$msteps;
+), "\0");
+$str =~ s/ {8}/\t/g; #- replace all 8 space char by only one tabulation, this reduces file size so much :-)
+output($cfgfile, $str);
+
+fs::umount($mountdir);
+
+
+$in->ask_okcancel(_("Congratulations!"),
+_("The floppy has been successfully generated.
+You may now replay your installation."));
+
+quit_global($in, 0);
+
+
+sub quit_global {
+ my ($in, $exitcode) = @_;
+ $::isEmbedded ? kill USR1, $::CCPID : $in->exit(0);
+ goto begin;
+}
+
+
+#-------------------------------------------------
+#- $Log$
+#- Revision 1.1 2001/08/13 19:06:50 gc
+#- initial revision for drakautoinst
+#- - put %installSteps in a separate package (steps.pm) (for drakxtools)
+#- - use additional fields {auto} and {noauto}, by step, to ease interactive auto install and oem stuff
+#- - in install2.pm, perform each step either from the interactive class or from install_steps, according to the {auto} flag
+#- - id, tell each step to not try to be automatic if {noauto}
+#- - in the install, have auto install bootdisk created in install_any so we can always write a bootdisk (from install_steps) for further use from drakautoinst in standalone
+#- - interactive version of install_steps_auto_install is now inheriting from the interactive class, so we can click on a previous automatic step and have it interactively during an interactive auto install
+#-
+#-
diff --git a/perl-install/steps.pm b/perl-install/steps.pm
new file mode 100644
index 000000000..e5e522c1e
--- /dev/null
+++ b/perl-install/steps.pm
@@ -0,0 +1,51 @@
+package steps;
+
+use strict;
+use vars qw(%installSteps @orderedInstallSteps);
+use common;
+
+#-######################################################################################
+#- Steps table
+#-######################################################################################
+{
+ my @installStepsFields = qw(text redoable onError hidden needs icon);
+ #entered reachable toBeDone next done;
+ my @installSteps = (
+ selectLanguage => [ __("Choose your language"), 1, 1, '', '', 'default' ],
+ selectInstallClass => [ __("Select installation class"), 1, 1, '', '', 'default' ],
+ setupSCSI => [ __("Hard drive detection"), 1, 0, '', '', 'harddrive' ],
+ selectMouse => [ __("Configure mouse"), 1, 1, '', "selectInstallClass", 'mouse' ],
+ selectKeyboard => [ __("Choose your keyboard"), 1, 1, '', "selectInstallClass", 'keyboard' ],
+ miscellaneous => [ __("Security"), 1, 1, '!$::expert', '', 'security' ],
+ doPartitionDisks => [ __("Setup filesystems"), 1, 0, '', "selectInstallClass", 'default' ],
+ formatPartitions => [ __("Format partitions"), 1, -1, '$o->{isUpgrade}', "doPartitionDisks", 'default' ],
+ choosePackages => [ __("Choose packages to install"), 1, -2, '!$::expert', "formatPartitions", 'default' ],
+ installPackages => [ __("Install system"), 1, -1, '', ["formatPartitions", "selectInstallClass"], '' ],
+ setRootPassword => [ __("Set root password"), 1, 1, '', "installPackages", 'rootpasswd' ],
+ addUser => [ __("Add a user"), 1, 1, '', "installPackages", 'user' ],
+ configureNetwork => [ __("Configure networking"), 1, 1, '', "formatPartitions", 'network' ],
+#- installCrypto => [ __("Cryptographic"), 1, 1, '!$::expert', "configureNetwork" ],
+ summary => [ __("Summary"), 1, 0, '', "installPackages", 'default' ],
+ configureServices => [ __("Configure services"), 1, 1, '!$::expert', "installPackages", 'services' ],
+if_((arch() !~ /alpha/) && (arch() !~ /ppc/),
+ createBootdisk => [ __("Create a bootdisk"), 1, 0, '', "installPackages", 'bootdisk' ],
+),
+ setupBootloader => [ __("Install bootloader"), 1, 1, '', "installPackages", 'bootloader' ],
+ configureX => [ __("Configure X"), 1, 1, '', ["formatPartitions", "setupBootloader"], 'X' ],
+ exitInstall => [ __("Exit install"), 0, 0, '!$::expert && !$::live', '', 'default' ],
+);
+ for (my $i = 0; $i < @installSteps; $i += 2) {
+ my %h; @h{@installStepsFields} = @{ $installSteps[$i + 1] };
+ $h{next} = $installSteps[$i + 2];
+ $h{entered} = 0;
+ $h{onError} = $installSteps[$i + 2 * $h{onError}];
+ $h{reachable} = !$h{needs};
+ $installSteps{ $installSteps[$i] } = \%h;
+ push @orderedInstallSteps, $installSteps[$i];
+ }
+ $installSteps{first} = $installSteps[0];
+}
+
+
+#- Wonderful perl :(
+1;