diff options
author | pad <pad@mandriva.com> | 1999-09-05 13:59:16 +0000 |
---|---|---|
committer | pad <pad@mandriva.com> | 1999-09-05 13:59:16 +0000 |
commit | b2dcc1f05939631e7583740a36f3c41c87235639 (patch) | |
tree | bee0630d0f11935a8e812b8fed0798e1148d449f /perl-install | |
parent | a7c17125164aa7fd336fdab93e49032239f2b626 (diff) | |
download | drakx-backup-do-not-use-b2dcc1f05939631e7583740a36f3c41c87235639.tar drakx-backup-do-not-use-b2dcc1f05939631e7583740a36f3c41c87235639.tar.gz drakx-backup-do-not-use-b2dcc1f05939631e7583740a36f3c41c87235639.tar.bz2 drakx-backup-do-not-use-b2dcc1f05939631e7583740a36f3c41c87235639.tar.xz drakx-backup-do-not-use-b2dcc1f05939631e7583740a36f3c41c87235639.zip |
clean graphical to use ask_from_entries
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/install_steps.pm | 10 | ||||
-rw-r--r-- | perl-install/install_steps_interactive.pm | 122 | ||||
-rw-r--r-- | perl-install/interactive.pm | 9 | ||||
-rw-r--r-- | perl-install/interactive_gtk.pm | 34 |
4 files changed, 143 insertions, 32 deletions
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 5f0044f88..9c5473c49 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -24,9 +24,6 @@ use network; use fs; -my @etc_pass_fields = qw(name password uid gid realname home shell); - - my $o; 1; @@ -85,11 +82,9 @@ sub errorInStep($$) {} #-###################################################################################### #- Steps Functions #-###################################################################################### - #------------------------------------------------------------------------------ sub selectLanguage { $o->{keyboard} ||= keyboard::lang2keyboard($o->{lang}); - #PAD CHOICE ||= selectKeyboard($o); } #------------------------------------------------------------------------------ @@ -113,7 +108,6 @@ sub rebootNeeded($) { exit "true"; } -#------------------------------------------------------------------------------ sub choosePartitionsToFormat($$) { my ($o, $fstab) = @_; @@ -123,7 +117,6 @@ sub choosePartitionsToFormat($$) { } } -#------------------------------------------------------------------------------ sub formatPartitions { my $o = shift; foreach (@_) { @@ -136,7 +129,6 @@ sub choosePackages($$$) { my ($o, $packages, $compss) = @_; } -#------------------------------------------------------------------------------ sub beforeInstallPackages { my ($o) = @_; @@ -207,7 +199,9 @@ sub printerConfig { printer::configure_queue($o->{printer}); } } + #------------------------------------------------------------------------------ +my @etc_pass_fields = qw(name password uid gid realname home shell); sub setRootPassword($) { my ($o) = @_; my %u = %{$o->{superuser}}; diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index ce9fc0065..65206c569 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -26,7 +26,7 @@ use printer; 1; #-###################################################################################### -#- misc functions +#- In/Out Steps Functions #-###################################################################################### sub errorInStep($$) { my ($o, $err) = @_; @@ -88,7 +88,6 @@ sub rebootNeeded($) { install_steps::rebootNeeded($o); } -#------------------------------------------------------------------------------ sub choosePartitionsToFormat($$) { my ($o, $fstab) = @_; @@ -111,11 +110,15 @@ sub formatPartitions { } } } +#------------------------------------------------------------------------------ +#-choosePackage +#------------------------------------------------------------------------------ +#-mouse +#------------------------------------------------------------------------------ sub configureNetwork($) { my ($o, $first_time) = @_; my $r = ''; - if ($o->{intf}) { if ($first_time) { my @l = ( @@ -154,7 +157,45 @@ sub configureNetwork($) { } install_steps::configureNetwork($o); } - + +sub configureNetworkIntf { + my ($o, $intf) = @_; + delete $intf->{NETWORK}; + delete $intf->{BROADCAST}; + my @fields = qw(IPADDR NETMASK); + $o->ask_from_entries_ref(_("Configuring network device %s", $intf->{DEVICE}), +_("Please enter the IP configuration for this machine. +Each item should be entered as an IP address in dotted-decimal +notation (for example, 1.2.3.4)."), + [ _("IP address:"), _("Netmask:")], + [ \$intf->{IPADDR}, \$intf->{NETMASK}], + complete => sub { + for (my $i = 0; $i < @fields; $i++) { + unless (network::is_ip($intf->{$fields[$i]})) { + $o->ask_warn('', _("IP address should be in format 1.2.3.4")); + return (1,$i); + } + return 0; + } + } + ); +} + +sub configureNetworkNet { + my ($o, $netc, @devices) = @_; + + $o->ask_from_entries_ref(_("Configuring network"), +_("Please enter your host name. +Your host name should be a fully-qualified host name, +such as ``mybox.mylab.myco.com''. +Also give the gateway if you have one"), + [_("Host name:"), _("DNS server:"), _("Gateway:"), _("Gateway device:")], + [(map { \$netc->{$_}} qw(HOSTNAME dnsServer GATEWAY)), + {val => \$netc->{GATEWAYDEV}, list => \@devices}] + ); +} + +#------------------------------------------------------------------------------ sub timeConfig { my ($o, $f) = @_; @@ -164,6 +205,8 @@ sub timeConfig { } #------------------------------------------------------------------------------ +#-sub servicesConfig {} +#------------------------------------------------------------------------------ sub printerConfig($) { my ($o) = @_; $o->{printer}{want} = @@ -186,7 +229,7 @@ name and directory should be used for this queue?"), { $o->{printer}{SPOOLDIR} = "$printer::spooldir$o->{printer}{QUEUE}" unless $_[0]; - }, + }, ); } @@ -206,14 +249,14 @@ name and directory should be used for this queue?"), push @port, "/dev/$_" if open LP, ">/dev/$_" } eval { modules::unload("lp") }; - @port =("lp0", "lp1", "lp2"); +# @port =("lp0", "lp1", "lp2"); $o->{printer}{DEVICE} = $port[0] if $port[0]; return if !$o->ask_from_entries_ref(_("Local Printer Device"), _("What device is your printer connected to \n(note that /dev/lp0 is equivalent to LPT1:)?\n"), [_("Printer Device:")], - [{val => \$o->{printer}{DEVICE}, list => \@port, is_edit => 1}], + [{val => \$o->{printer}{DEVICE}, list => \@port }], ); #TAKE A GOODDEFAULT TODO @@ -341,6 +384,63 @@ wish to access and any applicable user name and password."), } +#------------------------------------------------------------------------------ +sub setRootPassword($) { + my ($o) = @_; + $o->{superuser} ||= {}; + $o->{superuser}{password2} ||= $o->{superuser}{password}; + my $sup = $o->{superuser}; + + $o->ask_from_entries_ref(_("Set root password"), + _("Set root password"), + [_("Password"), _("Password (again)")], + [\$sup->{password}, \$sup->{password2}], + complete => sub { + $sup->{password} eq $sup->{password2} or $o->ask_warn('', [ _("You must enter the same password"), _("Please try again") ]), return (1,1); + (length $sup->{password} < 6) and $o->ask_warn('', _("This password is too simple")), return (1,0); + return 0 + } + ); + install_steps::setRootPassword($o); +} + +#------------------------------------------------------------------------------ +#-addUser +#------------------------------------------------------------------------------ +sub addUser($) { + my ($o) = @_; + $o->{user} ||= {}; + $o->{user}{password2} ||= $o->{user}{password}; + my $sup = $o->{user}; + my @fields = qw(name password password2 realname); + + my @shells = install_any::shells($o); + @shells = qw( /bin/bash /nide); + + $o->ask_from_entries_ref(_("Add user"), + _("Enter a user"), + [_("User name"), _("Password"), _("Password (again)"), _("Real name"), _("Shell"),], + [(map { \$sup->{$_}} @fields), + {val => \$sup->{shell}, list => \@shells}, + ], + complete => sub { + $sup->{password} eq $sup->{password2} or $o->ask_warn('', [ _("You must enter the same password"), _("Please try again") ]), return (1,2); + (length $sup->{password} < 6) and $o->ask_warn('', _("This password is too simple")), return (1,1); + $sup->{name} or $o->ask_warn('', _("Please give a user name")), return (1,0); + $sup->{name} =~ /^[a-z0-9_-]+$/ or $o->ask_warn('', _("The user name must contain only lower cased letters, numbers, `-' and `_'")), return (1,0); + return 0; + } + + ); + install_steps::addUser($o); + $o->{user} = {}; + goto &addUser if $::expert; +} + + + + +#------------------------------------------------------------------------------ sub createBootdisk { my ($o, $first_time) = @_; my @l = detect_devices::floppies(); @@ -367,6 +467,7 @@ failures. Would you like to create a bootdisk for your system?"), !$o->{mkbootdi install_steps::createBootdisk($o); } +#------------------------------------------------------------------------------ sub setupBootloader($) { my ($o) = @_; my @l = (__("First sector of drive"), __("First sector of boot partition")); @@ -380,6 +481,7 @@ sub setupBootloader($) { install_steps::setupBootloader($o); } +#------------------------------------------------------------------------------ sub exitInstall { my ($o) = @_; $o->ask_warn('', @@ -391,6 +493,10 @@ Information on configuring your system is available in the post install chapter of the Official Linux Mandrake User's Guide.")); } + +#-###################################################################################### +#- Misc Steps Functions +#-###################################################################################### sub loadModule { my ($o, $type) = @_; my @options; @@ -426,6 +532,7 @@ Do you want to try again with other parameters?", $l)) or return; $l, $m; } +#------------------------------------------------------------------------------ sub load_thiskind { my ($o, $type) = @_; my $w; @@ -437,6 +544,7 @@ sub load_thiskind { }); } +#------------------------------------------------------------------------------ sub setup_thiskind { my ($o, $type, $auto, $at_least_one) = @_; my @l = $o->load_thiskind($type); diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index de9998145..dc846f42b 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -105,7 +105,14 @@ sub ask_from_entries_ref($$$$;$%) { my ($o, $title, $message, $l, $val, %callback) = @_; $message = ref $message ? $message : [ $message ]; - my $val_hash = [ map { (ref $_) eq "SCALAR" ? { val => $_ } : {(%{$_}, type => "list")}} @{$val} ]; + my $val_hash = [ map + { if ((ref $_) eq "SCALAR") { + { val => $_ } + } else { + @{$_->{list}} ? + { (%{$_}, type => "list")} : {(%{$_})} + } + } @{$val} ]; $o->ask_from_entries_refW($title, $message, $l, $val_hash, %callback) diff --git a/perl-install/interactive_gtk.pm b/perl-install/interactive_gtk.pm index 4e525e5c7..457406acc 100644 --- a/perl-install/interactive_gtk.pm +++ b/perl-install/interactive_gtk.pm @@ -82,15 +82,11 @@ sub ask_from_entries_refW { my $w = my_gtk->new($title, %$o); my @entries = map { if ($_->{type} eq "list") { - if (@{$_->{list}}) { - my $depth_combo = new Gtk::Combo; - $depth_combo->set_use_arrows_always(1); - $depth_combo->entry->set_editable($_->{is_edit}); - $depth_combo->set_popdown_strings(@{$_->{list}}); - $depth_combo; - } else { - new Gtk::Entry; - } + my $depth_combo = new Gtk::Combo; + $depth_combo->set_use_arrows_always(1); + $depth_combo->entry->set_editable(!$_->{not_edit}); + $depth_combo->set_popdown_strings(@{$_->{list}}); + $depth_combo; } else { new Gtk::Entry; } @@ -130,10 +126,10 @@ sub ask_from_entries_refW { comb_entry($entry,$val->[$i])->signal_connect(changed => $callback); comb_entry($entry,$val->[$i])->signal_connect(activate => sub { ($ind == ($num_champs -1)) ? - $w->{ok}->grab_focus() : $entries[$ind+1]->grab_focus(); + $w->{ok}->grab_focus() : comb_entry($entries[$ind+1],$val->[$ind+1])->grab_focus(); }); comb_entry($entry,$val->[$i])->set_text(${$val->[$i]{val}}) if ${$val->[$i]{val}}; - comb_entry($entry,$val->[$i])->set_visibility(0) if $_[0] =~ /password/i; + comb_entry($entry,$val->[$i])->set_visibility(0) if $l->[$i] =~ /password/i; # &{$updates[$i]}; } @@ -146,21 +142,27 @@ sub ask_from_entries_refW { $ok )); + comb_entry($entries[0],$val->[0])->grab_focus(); if ($hcallback{complete}) { my $callback = sub { - my ($error, $focus) = &{$hcallback{changed}}; + my ($error, $focus) = &{$hcallback{complete}}; #update all the value $ignore = 1; foreach (@updates_inv) { &{$_};} $ignore = 0; if ($error) { - $entries[$focus]->grab_focus(); + comb_entry($entries[$focus], $val->[$focus])->grab_focus(); + } else { + return 1; } }; - $w->{ok}->signal_connect(activate => $callback) + #$w->{ok}->signal_connect(clicked => $callback) + $w->main($callback); + } else { + $w->main(); } - $entries[0]->grab_focus(); - $w->main(); + + } |