From c75193289b79d4c0687aa6a597b51436568f8360 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sun, 6 Aug 2000 00:38:57 +0000 Subject: no_comment --- docs/TODO | 10 +-- perl-install/ChangeLog | 13 +++ perl-install/any.pm | 17 ++-- perl-install/crypto.pm | 3 +- perl-install/devices.pm | 3 +- perl-install/fsedit.pm | 7 +- perl-install/help.pm | 8 +- perl-install/install2.pm | 66 +++++++------- perl-install/install_any.pm | 25 +++++- perl-install/install_steps.pm | 18 ++-- perl-install/install_steps_gtk.pm | 4 +- perl-install/install_steps_interactive.pm | 143 ++++++++++++++---------------- perl-install/interactive.pm | 32 ++++--- perl-install/keyboard.pm | 8 -- perl-install/lang.pm | 2 +- perl-install/modules.pm | 19 ++-- perl-install/mouse.pm | 18 ++-- perl-install/partition_table.pm | 3 +- perl-install/partition_table_raw.pm | 15 +++- perl-install/printerdrake.pm | 3 +- update_kernel | 2 +- 21 files changed, 227 insertions(+), 192 deletions(-) diff --git a/docs/TODO b/docs/TODO index 51f17c1a9..70eff4439 100644 --- a/docs/TODO +++ b/docs/TODO @@ -10,14 +10,9 @@ warning on diskdrake startup, made them as warning ?). -features------------------------------------------------------------------------------- add rpmdrake in menu -(NEED 7.1) auto-install for corporate, very important (need consolidation). - (7.1 or later) clean SCSI CDROM autoboot. stage1 & cdrom: add ability in expert to choose the scsi cdrom drive to use -(7.1)install in 800x600 -- need handling of both 640x480 (mostly for VGA16) and 800x600 - (7.1)better help for partitioning in newbie (7.1)Improved network configuration (PPP and/or Ethernet) @@ -513,3 +508,8 @@ already hda1 with /boot/vmlinuz - create a stage2 with many tools (fdisk, bash...) the rescue could be on another cd (if multi-cd) ! care must be taken about modules (if ide is in module...) + +(done,7.1)install in 800x600 +- need handling of both 640x480 (mostly for VGA16) and 800x600 + +(done,NEED 7.1) auto-install for corporate, very important (need consolidation). diff --git a/perl-install/ChangeLog b/perl-install/ChangeLog index dbdd74c2c..2125ec320 100644 --- a/perl-install/ChangeLog +++ b/perl-install/ChangeLog @@ -3,6 +3,19 @@ * install_steps_gtk.pm (create_steps_window): use drawing area instead of button. Implemented all steps events. +2000-08-05 Pixel + + * mouse.pm (detect): test a hack for usb mouse via hub + (sparhawk@enteract.com) + + * fsedit.pm (undo): force isDirty and needKernelReread only if hd + hasBeenDirty, otherwise believe the flag saved + * partition_table.pm (write): flag hd as hasBeenDirty + + * install2.pm: a few renaming of methods so that the step names + correspond to install2 function and install_steps* methods (eg: + configureX & setupXfree unified to configureX) + 2000-08-04 Dam's * any.pm (setAutoLogin): added this method to write xdm-config diff --git a/perl-install/any.pm b/perl-install/any.pm index 7f59db74a..7e50c1dbc 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -122,11 +122,17 @@ _("Restrict command line options") => { val => \$b->{restricted}, type => "bool" until ($::beginner && $more <= 1) { $in->set_help(arch() =~ /sparc/ ? 'setupSILOAddEntry' : 'setupBootloaderAddEntry') unless $::isStandalone; - my $c = $in->ask_from_list_([''], + my $c = $in->ask_from_listf([''], _("Here are the different entries. You can add some more or change the existing ones."), - [ (sort @{[map { "$_->{label} ($_->{kernel_or_dev})" . ($b->{default} eq $_->{label} && " *") } @{$b->{entries}}]}), __("Add"), __("Done") ], - ); + sub { + my ($e) = @_; + ref $e ? + "$e->{label} ($e->{kernel_or_dev})" . ($b->{default} eq $e->{label} && " *") : + translate($e); + }, + [ @{$b->{entries}}, __("Add"), __("Done") ]); + $c eq "Done" and last; my ($e); @@ -147,9 +153,8 @@ You can add some more or change the existing ones."), } $e->{label} = $prefix; for (my $nb = 0; member($e->{label}, @labels); $nb++) { $e->{label} = "$prefix-$nb" } - } else { - $c =~ /(.*) \(/; - ($e) = grep { $_->{label} eq $1 } @{$b->{entries}}; + } else { + $e = $c; } my %old_e = %$e; my $default = my $old_default = $e->{label} eq $b->{default}; diff --git a/perl-install/crypto.pm b/perl-install/crypto.pm index f15c8914f..ac0904ce1 100644 --- a/perl-install/crypto.pm +++ b/perl-install/crypto.pm @@ -28,8 +28,7 @@ my %deps = ( sub require2package { $deps{$_[0]} || $_[0] } sub mirror2text($) { $mirrors{$_[0]} && "$mirrors{$_[0]}[0] ($_[0])" } -sub mirrorstext() { map { mirror2text($_) } keys %mirrors } -sub text2mirror($) { first($_[0] =~ /\((.*)\)$/) } +sub mirrors() { keys %mirrors } sub dir { $mirrors{$_[0]}[1] . '/' . (arch() !~ /i.86/ && ((arch() =~ /sparc/ ? "sparc" : arch()). '/')) . $::VERSION } sub ftp($) { ftp::new($_[0], dir($_[0])) } diff --git a/perl-install/devices.pm b/perl-install/devices.pm index c1a9bdaee..ae04b561c 100644 --- a/perl-install/devices.pm +++ b/perl-install/devices.pm @@ -112,7 +112,8 @@ sub entry { "sjcd" => [ c::S_IFBLK(), 18, 0 ], "tty" => [ c::S_IFCHR(), 5, 0 ], # "usbmouse"=> [ c::S_IFCHR(), 10, 32], #- aka hidbp-mse-0 - "usbmouse"=> [ c::S_IFCHR(), 13, 32], #- aka /dev/usb/usbmouse0 + "usbmouse"=> [ c::S_IFCHR(), 13, 32], #- aka /dev/input/mouse0 + "usbmice" => [ c::S_IFCHR(), 13, 63], #- aka /dev/input/mice "zero" => [ c::S_IFCHR(), 1, 5 ], }}{$_} or die "unknown device $_ (caller is " . join(":", caller()) . ")" }; } diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index cee6f88ff..edaadab88 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -316,18 +316,13 @@ sub undo_prepare($) { push @{$_->{undo}}, Data::Dumper->Dump([\@h], ['$h']); } } -sub undo_forget($) { - my ($hds) = @_; - pop @{$_->{undo}} foreach @$hds; -} - sub undo($) { my ($hds) = @_; foreach (@$hds) { my $h; eval pop @{$_->{undo}} || next; @{$_}{@partition_table::fields2save} = @$h; - $_->{isDirty} = $_->{needKernelReread} = 1; + $_->{isDirty} = $_->{needKernelReread} = 1 if $_->{hasBeenDirty}; } } diff --git a/perl-install/help.pm b/perl-install/help.pm index 242adcc1c..f86f5af05 100644 --- a/perl-install/help.pm +++ b/perl-install/help.pm @@ -20,9 +20,7 @@ or 7.0 (Air). Select: - - Automated (recommended): If you have never installed GNU/Linux before, choose this. NOTE: - networking will not be configured during installation, use \"LinuxConf\" - to configure it after the install completes. + - Recommended: If you have never installed GNU/Linux before, choose this. - Customized: If you are familiar enough with GNU/Linux, you may then choose the primary usage for your machine. See below for details. @@ -88,7 +86,7 @@ information from Windows (if you have it on your system), from hardware documentation, or from the manufacturer's website (if you have Internet access)."), -partitionDisks => +doPartitionDisks => __("At this point, you may choose what partition(s) to use to install your Linux-Mandrake system if they have been already defined (from a previous install of GNU/Linux or from another partitioning tool). In other @@ -149,7 +147,7 @@ chooseCD => If you have none of those CDs, click Cancel. If only some CDs are missing, unselect them, then click Ok."), -doInstallStep => +installPackages => __("The packages selected are now being installed. This operation should take a few minutes unless you have chosen to upgrade an existing system, in that case it can take more time even before diff --git a/perl-install/install2.pm b/perl-install/install2.pm index 07301f810..30b3fedcc 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -28,14 +28,13 @@ use detect_devices; use run_program; use install_steps; -#use install_steps_interactive; -#-###################################################################################### -#- Steps table -#-###################################################################################### $::VERSION = "7.1"; #-$::corporate=1; +#-###################################################################################### +#- Steps table +#-###################################################################################### my (%installSteps, @orderedInstallSteps); { my @installStepsFields = qw(text redoable onError hidden needs); @@ -47,24 +46,24 @@ my (%installSteps, @orderedInstallSteps); selectMouse => [ __("Configure mouse"), 1, 1, '$::beginner', "selectInstallClass" ], selectKeyboard => [ __("Choose your keyboard"), 1, 1, '', "selectInstallClass" ], miscellaneous => [ __("Miscellaneous"), 1, 1, '$::beginner' ], - partitionDisks => [ __("Setup filesystems"), 1, 0, '$o->{lnx4win}', "selectInstallClass" ], - formatPartitions => [ __("Format partitions"), 1, -1, '', "partitionDisks" ], + doPartitionDisks => [ __("Setup filesystems"), 1, 0, '$o->{lnx4win}', "selectInstallClass" ], + formatPartitions => [ __("Format partitions"), 1, -1, '', "doPartitionDisks" ], choosePackages => [ __("Choose packages to install"), 1, -2, '$::beginner', "formatPartitions" ], - doInstallStep => [ __("Install system"), 1, -1, '', ["formatPartitions", "selectInstallClass"] ], + installPackages => [ __("Install system"), 1, -1, '', ["formatPartitions", "selectInstallClass"] ], configureNetwork => [ __("Configure networking"), 1, 1, '$::beginner && !$::corporate', "formatPartitions" ], installCrypto => [ __("Cryptographic"), 1, 1, '!$::expert', "configureNetwork" ], - configureTimezone => [ __("Configure timezone"), 1, 1, '', "doInstallStep" ], - configureServices => [ __("Configure services"), 1, 1, '!$::expert', "doInstallStep" ], - configurePrinter => [ __("Configure printer"), 1, 0, '', "doInstallStep" ], + configureTimezone => [ __("Configure timezone"), 1, 1, '', "installPackages" ], + configureServices => [ __("Configure services"), 1, 1, '!$::expert', "installPackages" ], + configurePrinter => [ __("Configure printer"), 1, 0, '', "installPackages" ], setRootPassword => [ __("Set root password"), 1, 1, '', "formatPartitions" ], addUser => [ __("Add a user"), 1, 1, '' ], arch() !~ /alpha/ ? ( - createBootdisk => [ __("Create a bootdisk"), 1, 0, '$::o->{lnx4win} && !$::expert', "doInstallStep" ], + createBootdisk => [ __("Create a bootdisk"), 1, 0, '$::o->{lnx4win} && !$::expert', "installPackages" ], ) : (), - setupBootloader => [ __("Install bootloader"), 1, 1, '$::o->{lnx4win} && !$::expert', "doInstallStep" ], + setupBootloader => [ __("Install bootloader"), 1, 1, '$::o->{lnx4win} && !$::expert', "installPackages" ], configureX => [ __("Configure X"), 1, 1, '', ["formatPartitions", "setupBootloader"] ], arch() !~ /alpha/ ? ( - generateAutoInstFloppy => [ __("Auto install floppy"), 1, 1, '!$::expert || $o->{lnx4win}', "doInstallStep" ], + generateAutoInstFloppy => [ __("Auto install floppy"), 1, 1, '!$::expert || $o->{lnx4win}', "installPackages" ], ) : (), exitInstall => [ __("Exit install"), 0, 0, '$::beginner' ], ); @@ -237,7 +236,7 @@ sub selectLanguage { addToBeDone { lang::write($o->{prefix}); keyboard::write($o->{prefix}, lang::lang2charset($o->{lang}), $o->{keyboard}); - } 'doInstallStep' unless $::g_auto_install; + } 'installPackages' unless $::g_auto_install; } #------------------------------------------------------------------------------ @@ -247,7 +246,7 @@ sub selectMouse { add2hash($o->{mouse} ||= {}, { mouse::read($o->{prefix}) }) if $o->{isUpgrade} && !$clicked; $o->selectMouse($clicked); - addToBeDone { mouse::write($o->{prefix}, $o->{mouse}) } 'doInstallStep'; + addToBeDone { mouse::write($o->{prefix}, $o->{mouse}) } 'installPackages'; } #------------------------------------------------------------------------------ @@ -271,7 +270,7 @@ sub selectKeyboard { addToBeDone { lang::write($o->{prefix}); keyboard::write($o->{prefix}, lang::lang2charset($o->{lang}), $o->{keyboard}); - } 'doInstallStep' unless $::g_auto_install; + } 'installPackages' unless $::g_auto_install; } #------------------------------------------------------------------------------ @@ -280,13 +279,13 @@ sub selectInstallClass { $o->{partitions} ||= $suggestedPartitions{$o->{installClass}}; - if ($o->{steps}{choosePackages}{entered} >= 1 && !$o->{steps}{doInstallStep}{done}) { + if ($o->{steps}{choosePackages}{entered} >= 1 && !$o->{steps}{installPackages}{done}) { $o->setPackages(\@install_classes); $o->selectPackagesToUpgrade() if $o->{isUpgrade}; } if ($o->{isUpgrade}) { - @{$o->{orderedSteps}} = map { /setupSCSI/ ? ($_, "partitionDisks") : $_ } - grep { !/partitionDisks/ } @{$o->{orderedSteps}}; + @{$o->{orderedSteps}} = map { /setupSCSI/ ? ($_, "doPartitionDisks") : $_ } + grep { !/doPartitionDisks/ } @{$o->{orderedSteps}}; my $s; foreach (@{$o->{orderedSteps}}) { $s->{next} = $_ if $s; $s = $o->{steps}{$_}; @@ -295,7 +294,7 @@ sub selectInstallClass { } #------------------------------------------------------------------------------ -sub partitionDisks { +sub doPartitionDisks { return install_any::searchAndMount4Upgrade($o) if $o->{isUpgrade}; my $stage1_hd; @@ -389,11 +388,11 @@ sub choosePackages { pkgs::packageFlagSelected(pkgs::packageByName($o->{packages}, 'basesystem')) or die "basesystem package not selected"; #- check if there are package that need installation. - $o->{steps}{doInstallStep}{done} = 0 if $o->{steps}{doInstallStep}{done} && pkgs::packagesToInstall($o->{packages}) > 0; + $o->{steps}{installPackages}{done} = 0 if $o->{steps}{installPackages}{done} && pkgs::packagesToInstall($o->{packages}) > 0; } #------------------------------------------------------------------------------ -sub doInstallStep { +sub installPackages { $o->readBootloaderConfigBeforeInstall if $_[1] == 1; $o->beforeInstallPackages; @@ -421,7 +420,7 @@ sub miscellaneous { setVarsInSh($f, \%usb); install_any::fsck_option(); - } 'doInstallStep'; + } 'installPackages'; } #------------------------------------------------------------------------------ @@ -458,18 +457,18 @@ sub configureTimezone { } $o->{timezone}{timezone} ||= timezone::bestTimezone(lang::lang2text($o->{lang})); $o->{timezone}{UTC} = !$::beginner && !grep { isFat($_) || isNT($_) } @{$o->{fstab}} unless exists $o->{timezone}{UTC}; - $o->timeConfig($f, $clicked); + $o->configureTimezone($f, $clicked); } #------------------------------------------------------------------------------ -sub configureServices { $::expert and $o->servicesConfig } +sub configureServices { $::expert and $o->configureServices } #------------------------------------------------------------------------------ -sub configurePrinter { $o->printerConfig($_[0]) } +sub configurePrinter { $o->configurePrinter($_[0]) } #------------------------------------------------------------------------------ sub setRootPassword { return if $o->{isUpgrade}; $o->setRootPassword($_[0]); - addToBeDone { install_any::setAuthentication($o) } 'doInstallStep'; + addToBeDone { install_any::setAuthentication($o) } 'installPackages'; } #------------------------------------------------------------------------------ sub addUser { @@ -507,7 +506,7 @@ sub configureX { fs::write($o->{prefix}, $o->{fstab}, $o->{manualFstab}, $o->{useSupermount}); modules::write_conf($o->{prefix}); - $o->setupXfree if pkgs::packageFlagInstalled(pkgs::packageByName($o->{packages}, 'XFree86')) || $clicked; + $o->configureX if pkgs::packageFlagInstalled(pkgs::packageByName($o->{packages}, 'XFree86')) || $clicked; } #------------------------------------------------------------------------------ sub generateAutoInstFloppy { @@ -536,7 +535,7 @@ sub main { #- c::unlimit_core() unless $::testing; - my ($cfg, $patch, @auto); + my ($cfg, $patch, $oem, @auto); my %cmdline; map { my ($n, $v) = split '='; $cmdline{$n} = $v || 1; @@ -557,7 +556,7 @@ sub main { map_each { my ($n, $v) = @_; my $f = ${{ - oem => sub { $o->{oem} = $v }, + oem => sub { $oem = $v }, lang => sub { $o->{lang} = $v }, flang => sub { $o->{lang} = $v ; push @auto, 'selectLanguage' }, method => sub { $o->{method} = $v }, @@ -595,10 +594,6 @@ sub main { $o->{method} ||= "cdrom"; $o->{mkbootdisk} = 0; } - if ($o->{oem}) { - push @auto, 'exitInstall', 'selectMouse', 'timeConfig'; - } - unless ($::testing) { unlink $_ foreach ( $o->{pcmcia} ? () : ("/sbin/install"), #- #- install include cardmgr! "/modules/modules.cgz", @@ -675,6 +670,9 @@ sub main { $o->{interactive} = "newt"; require install_steps_newt; } + if ($oem) { + push @auto, 'selectInstallClass', 'selectMouse', 'configureTimezone', 'exitInstall'; + } foreach (@auto) { eval "undef *" . (!/::/ && "install_steps_interactive::") . $_; my $s = $o->{steps}{/::(.*)/ ? $1 : $_} or next; diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index f7743aa04..80b6f4f26 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -383,7 +383,7 @@ sub searchAndMount4Upgrade { my ($o) = @_; my ($root, $found); - my $w = $::beginner && $o->wait_message('', _("Searching root partition.")); + my $w = !$::expert && $o->wait_message('', _("Searching root partition.")); #- try to find the partition where the system is installed if beginner #- else ask the user the right partition, and test it after. @@ -871,4 +871,27 @@ sub generate_ks_cfg { $ks; } +sub partitionWizard { + my ($o, $hds, $fstab, $readonly) = @_; + my @solutions; + + # each solutions is a [ text, function ], where the function retunrs true if succeeded + if (fsedit::free_space(@$hds) > 500 << 11 && !$readonly) { + push @solutions, [ _("Use free space"), sub { fsedit::auto_allocate($hds, $o->{partitions}); 1 } ]; + } elsif (my @l = grep { isTrueFS($_) } @$fstab) { + push @solutions, [ _("Use existing partition"), sub { $o->ask_mntpoint_s($o->{fstab}) } ]; + } elsif (@l = grep { isFat($_) } @$fstab) { + } + push @solutions, + [ _("Take over the hard drive (beware!)"), + sub { + my $hd = $o->ask_from_listf('', _("You have more than one hard drive, which one do you install linux on?"), + \&partition_table_raw::description, @$hds) or return; + $o->ask_okcancel('', _("All existing partitions and their data will be lost on drive %s", $hd->{device})) or return; + partition_table_raw::zero_MBR($hd); + fsedit::auto_allocate($hds, $o->{partitions}); + 1; + } ]; +} + 1; diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 8df7f94b5..9b3b9b8db 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -129,7 +129,7 @@ sub doPartitionDisks { if ($o->{lnx4win}) { my @l = sort { $a->{device_windobe} cmp $b->{device_windobe} } grep { isFat($_) } fsedit::get_fstab(@{$o->{hds}}) or die "wow, lnx4win with no fat partitions! hard times :("; - my $real_part = @l > 1 && $o->doPartitionDisksLnx4winDev(\@l) || $l[0]; + my $real_part = $o->doPartitionDisksLnx4winDev(\@l) || $l[0]; my $handle = loopback::inspect($real_part, '', 'rw') or die _("This partition can't be used for loopback"); my $size = loopback::getFree($handle->{dir}, $real_part); @@ -631,20 +631,20 @@ sub pcmciaConfig($) { } #------------------------------------------------------------------------------ -sub timeConfig { +sub configureTimezone { my ($o, $f) = @_; require timezone; timezone::write($o->{prefix}, $o->{timezone}, $f); } #------------------------------------------------------------------------------ -sub servicesConfig { +sub configureServices { my ($o) = @_; require services; services::doit($o, $o->{services}, $o->{prefix}) if $o->{services}; } #------------------------------------------------------------------------------ -sub printerConfig { +sub configurePrinter { my($o) = @_; if ($o->{printer}{configured}) { require pkgs; @@ -834,7 +834,7 @@ sub setupBootloader($) { } #------------------------------------------------------------------------------ -sub setupXfreeBefore { +sub configureXBefore { my ($o) = @_; my $xkb = $o->{X}{keyboard}{xkb_keymap} || keyboard::keyboard2xkb($o->{keyboard}); if (!-e "$o->{prefix}/usr/X11R6/lib/X11/xkb/symbols/$xkb" && (my $f = keyboard::xmodmap_file($o->{keyboard}))) { @@ -851,9 +851,9 @@ sub setupXfreeBefore { #- keep this here if the package has to be updated. $o->pkg_install("XFree86"); } -sub setupXfree { +sub configureX { my ($o) = @_; - $o->setupXfreeBefore; + $o->configureXBefore; require Xconfigurator; require class_discard; @@ -864,9 +864,9 @@ sub setupXfree { $o->pkg_install("XFree86-$_[0]"); }); } - $o->setupXfreeAfter; + $o->configureXAfter; } -sub setupXfreeAfter { +sub configureXAfter { my ($o) = @_; if ($o->{X}{card}{server} eq 'FBDev') { unless (install_any::setupFB($o, Xconfigurator::getVGAMode($o->{X}))) { diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm index c8e836c90..62993d55e 100644 --- a/perl-install/install_steps_gtk.pm +++ b/perl-install/install_steps_gtk.pm @@ -19,6 +19,8 @@ use fsedit; use commands; use modules; use pkgs; +use partition_table qw(:types); +use partition_table_raw; use install_steps; use install_steps_interactive; use interactive_gtk; @@ -769,7 +771,7 @@ sub create_steps_window { my $darea = new Gtk::DrawingArea; my $draw_pix = sub { my $pixmap = Gtk::Gdk::Pixmap->create_from_xpm($darea->window, - $darea->style->bg('normal') + $darea->style->bg('normal'), $_[1]) or die; $darea->window->draw_pixmap ($darea->style->bg_gc('normal'), $pixmap, 0, 0, diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 523ccd59a..17ef94fb2 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -12,6 +12,7 @@ use vars qw(@ISA); #-###################################################################################### use common qw(:common :file :functional :system); use partition_table qw(:types); +use partition_table_raw; use install_steps; use install_any; use detect_devices; @@ -51,12 +52,11 @@ sub kill_action { sub selectLanguage($) { my ($o) = @_; - $o->{lang} = - lang::text2lang($o->ask_from_list("Language", - _("Please, choose a language to use."), - # the translation may be used for the help - [ lang::list() ], - lang::lang2text($o->{lang}))); + $o->{lang} = $o->ask_from_listf("Language", + _("Please, choose a language to use."), + \&lang::lang2text, + [ lang::list() ], + $o->{lang}); install_steps::selectLanguage($o); #- $o->{useless_thing_accepted} = $o->ask_from_list_('', @@ -67,18 +67,18 @@ sub selectLanguage($) { sub selectKeyboard($) { my ($o, $clicked) = @_; if (!$::beginner || $clicked) { - $o->{keyboard} = - keyboard::text2keyboard($o->ask_from_list_(_("Keyboard"), - _("Please, choose your keyboard layout."), - [ keyboard::list() ], - keyboard::keyboard2text($o->{keyboard}))); + $o->{keyboard} = $o->ask_from_listf_(_("Keyboard"), + _("Please, choose your keyboard layout."), + \&keyboard::keyboard2text, + [ keyboard::xmodmaps() ], + $o->{keyboard}); delete $o->{keyboard_unsafe}; } if ($::expert) { my %langs; $langs{$_} = 1 foreach @{$o->{langs}}; $o->ask_many_from_list_ref('', _("You can choose other languages that will be available after install"), - [ lang::list(), 'All' ], [ map { \$langs{$_} } (map { lang::text2lang($_) } lang::list()), 'all' ] ) or goto &selectKeyboard; + [ (map { lang::lang2text($_) } lang::list()), 'All' ], [ map { \$langs{$_} } lang::list(), 'all' ] ) or goto &selectKeyboard; $o->{langs} = $langs{all} ? [ 'all' ] : [ grep { $langs{$_} } keys %langs ]; } install_steps::selectKeyboard($o); @@ -107,7 +107,7 @@ sub selectInstallClass($@) { my %c = my @c = ( $::corporate ? () : ( - _("Automated") => "beginner", + _("Recommended") => "beginner", ), _("Customized") => "specific", _("Expert") => "expert", @@ -137,9 +137,11 @@ You will be allowed to make powerful but dangerous things here."), server => _("Server"), ); $o->set_help('selectInstallClass2'); - $o->{installClass} = ${{reverse %c}}{$o->ask_from_list(_("Install Class"), - _("Which usage is your system used for ?"), - [ values %c ], $c{$o->{installClass}})}; + $o->{installClass} = $o->ask_from_listf(_("Install Class"), + _("Which usage is your system used for ?"), + sub { $c{$_[0]} }, + [ keys %c ], + $o->{installClass}); } install_steps::selectInstallClass($o); } @@ -149,18 +151,18 @@ sub selectMouse { my ($o, $force) = @_; $force ||= $o->{mouse}{unsafe} || $::expert; - if ($force) { - my $name = $o->ask_from_list_('', _("Please, choose the type of your mouse."), [ mouse::names() ], $o->{mouse}{FULLNAME}); - $o->{mouse} = mouse::name2mouse($name); - } + + $o->{mouse} = $o->ask_from_listf_('', _("Please, choose the type of your mouse."), + sub { $_[0]{FULLNAME} }, [ mouse::list ], $o->{mouse}) if $force; $o->{mouse}{XEMU3} = 'yes' if $o->{mouse}{nbuttons} < 3; if ($force && $o->{mouse}{device} eq "ttyS") { $o->set_help('selectSerialPort'); - $o->{mouse}{device} = mouse::serial_ports_names2dev( - $o->ask_from_list(_("Mouse Port"), + $o->{mouse}{device} = + $o->ask_from_listf(_("Mouse Port"), _("Please choose on which serial port your mouse is connected to."), - [ mouse::serial_ports_names() ])); + \&mouse::serial_port2text, + [ mouse::serial_ports ]); } $o->setup_thiskind('SERIAL_USB', !$::expert, 0) if $o->{mouse}{device} eq "usbmouse"; @@ -184,28 +186,24 @@ sub ask_mntpoint_s { my ($o, $fstab) = @_; my @fstab = grep { isTrueFS($_) } @$fstab; @fstab = grep { isSwap($_) } @$fstab if @fstab == 0; -# @fstab = @$fstab if @fstab == 0; + @fstab = @$fstab if @fstab == 0; die _("no available partitions") if @fstab == 0; - my $msg = sub { "$_->{device} " . _("(%dMB)", $_->{size} / 1024 / 2) }; - if (@fstab == 1) { - $fstab[0]->{mntpoint} = '/'; + $fstab[0]{mntpoint} = '/'; } elsif ($::beginner) { - my %l; $l{&$msg} = $_ foreach @fstab; - my $e = $o->ask_from_list('', - _("Please choose a partition to use as your root partition."), - [ sort keys %l ]); + my $e = $o->ask_from_listf('', + _("Please choose a partition to use as your root partition."), + \&partition_table_raw::description, + \@fstab) or return; (fsedit::get_root($fstab) || {})->{mntpoint} = ''; - $l{$e}{mntpoint} = '/'; + $e->{mntpoint} = '/'; } else { - $o->ask_from_entries_ref - ('', - _("Choose the mount points"), - [ map { &$msg } @fstab ], - [ map { +{ val => \$_->{mntpoint}, - list => [ '', fsedit::suggestions_mntpoint([]) ] - } } @fstab ]); + $o->ask_from_entries_refH('', + _("Choose the mount points"), + { map { partition_table_raw::description($_) => + { val => \$_->{mntpoint}, list => [ '', fsedit::suggestions_mntpoint([]) ] } + } @fstab }) or return; } $o->SUPER::ask_mntpoint_s($fstab); } @@ -299,14 +297,11 @@ sub choosePackages { my $size2install = do { if ($::beginner) { - #- TODO: check the max_size > 700, otherwise remove Full entry, and even maybe Medium - #- in any case, ensure the result < $max_size - my @sizes = (300, 700, round_up(min($max_size, $availableC) / 1024 / 1024, 100)); - my @l = mapn { _ ($_[0], $_[1]) } [ __("Small(%dMB)"), __("Normal (%dMB)"), __("Full (%dMB)") ], \@sizes; - $sizes[2] > $sizes[1] + 200 or splice(@l, 1, 1), splice(@sizes, 1, 1); #- not worth proposing too alike stuff - $sizes[1] > $sizes[0] + 100 or splice(@l, 1, 1), splice(@sizes, 1, 1); - my $choice = $o->ask_from_list('', 'TODOMESSAGE', \@l); - $sizes[find_index { $_ eq $choice } @l] * 1024 * 1024; + my @l = (300, 700, round_up(min($max_size, $availableC) / sqr(1024), 100)); + $l[2] > $l[1] + 200 or splice(@l, 1, 1); #- not worth proposing too alike stuff + $l[1] > $l[0] + 100 or splice(@l, 0, 1); + my @text = (__("Small(%dMB)"), __("Normal (%dMB)"), __("Full (%dMB)")); + $o->ask_from_listf('', 'TODOMESSAGE', sub { _ ($text[$_[1]], $_[0]) }, \@l) * sqr(1024); } else { $o->chooseSizeToInstall($packages, $min_size, $max_size, $availableC, $individual) || goto &choosePackages; } @@ -545,10 +540,9 @@ sub pppConfig { } $m->{device} ||= $o->set_help('selectSerialPort') && - mouse::serial_ports_names2dev( - $o->ask_from_list('', _("Please choose which serial port your modem is connected to."), - [ grep { my $avoidDevice = mouse::serial_ports_names2dev($_); - $o->{mouse}{device} !~ /$avoidDevice/ } mouse::serial_ports_names ])); + $o->ask_from_listf('', _("Please choose which serial port your modem is connected to."), + \&mouse::serial_port2text, + [ grep { $_ ne $o->{mouse}{device} } mouse::serial_ports ]); $o->set_help('configureNetworkISP'); install_steps::pppConfig($o) if $o->ask_from_entries_refH('', @@ -605,7 +599,7 @@ USA")) || return; require crypto; eval { - $u->{mirror} = crypto::text2mirror($o->ask_from_list('', _("Choose a mirror from which to get the packages"), [ crypto::mirrorstext() ], crypto::mirror2text($u->{mirror}))); + $u->{mirror} = $o->ask_from_listf('', _("Choose a mirror from which to get the packages"), \&crypto::mirror2text, [ crypto::mirrors() ], $u->{mirror}); }; return if $@; @@ -627,25 +621,25 @@ USA")) || return; } #------------------------------------------------------------------------------ -sub timeConfig { +sub configureTimezone { my ($o, $f, $clicked) = @_; require timezone; - $o->{timezone}{timezone} = $o->ask_from_treelist('', _("Which is your timezone?"), '/', [ timezone::getTimeZones($::g_auto_install ? '' : $o->{prefix}) ], $o->{timezone}{timezone}) if $clicked; + $o->{timezone}{timezone} = $o->ask_from_treelist('', _("Which is your timezone?"), '/', [ timezone::getTimeZones($::g_auto_install ? '' : $o->{prefix}) ], $o->{timezone}{timezone}); $o->{timezone}{UTC} = $o->ask_yesorno('', _("Is your hardware clock set to GMT?"), $o->{timezone}{UTC}) if $::expert || $clicked; - install_steps::timeConfig($o, $f); + install_steps::configureTimezone($o, $f); } #------------------------------------------------------------------------------ -sub servicesConfig { +sub configureServices { my ($o) = @_; require services; $o->{services} = services::ask($o, $o->{prefix}); - install_steps::servicesConfig($o); + install_steps::configureServices($o); } #------------------------------------------------------------------------------ -sub printerConfig { +sub configurePrinter { my ($o, $clicked) = @_; return if $::corporate; @@ -791,11 +785,10 @@ drive and press \"Ok\"."), } else { my @l = detect_devices::floppies(); my %l = ( - 'fd0' => __("First floppy drive"), - 'fd1' => __("Second floppy drive"), - 'Skip' => __("Skip"), + 'fd0' => _("First floppy drive"), + 'fd1' => _("Second floppy drive"), + 'Skip' => _("Skip"), ); - $l{$_} ||= $_ foreach @l; if ($first_time || @l == 1) { $o->ask_yesorno('', @@ -810,12 +803,14 @@ failures. Would you like to create a bootdisk for your system?"), } else { @l or die _("Sorry, no floppy drive available"); - $o->{mkbootdisk} = ${{reverse %l}}{$o->ask_from_list_('', - _("Choose the floppy drive you want to use to make the bootdisk"), - [ @l{@l, "Skip"} ], $o->{mkbootdisk})}; + $o->{mkbootdisk} = $o->ask_from_listf('', + _("Choose the floppy drive you want to use to make the bootdisk"), + sub { $l{$_[0]} || $_[0] }, + [ @l, "Skip" ], + $o->{mkbootdisk}); return $o->{mkbootdisk} = '' if $o->{mkbootdisk} eq 'Skip'; } - $o->ask_warn('', _("Insert a floppy in drive %s", $l{$o->{mkbootdisk}})); + $o->ask_warn('', _("Insert a floppy in drive %s", $l{$o->{mkbootdisk}} || $o->{mkbootdisk})); } my $w = $o->wait_message('', _("Creating bootdisk")); @@ -928,9 +923,9 @@ give digits instead of normal letters (eg: pressing `p' gives `6')")) || return; } #------------------------------------------------------------------------------ -sub setupXfree { +sub configureX { my ($o) = @_; - $o->setupXfreeBefore; + $o->configureXBefore; require Xconfig; require Xconfigurator; @@ -962,7 +957,7 @@ Do you want to keep XFree 3.3?"), 0) if $::expert; $o->pkg_install("XFree86-$server", @l); }); } - $o->setupXfreeAfter; + $o->configureXAfter; } #------------------------------------------------------------------------------ @@ -1081,11 +1076,11 @@ sub load_module { my ($o, $type) = @_; my @options; - my $l = $o->ask_from_list('', + my $m = $o->ask_from_list('', _("Which %s driver should I try?", $type), - [ modules::text_of_type($type) ]) or return; - my $m = modules::text2driver($l); - + \&modules::module2text, + [ modules::module_of_type($type) ]) or return; + my $l = modules::module2text($m); require modparm; my @names = modparm::get_options_name($m); @@ -1162,7 +1157,7 @@ sub setup_thiskind { my $r = "Yes"; $r = $o->ask_from_list_('', $msg, $opt, "No") unless $at_least_one && @l == 0; if ($r eq "No") { return } - elsif ($r eq "Yes") { + if ($r eq "Yes") { push @l, $o->load_module($type) || next; } else { #-eval { commands::modprobe("isapnp") }; diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index 46abd8628..0ef20cc19 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -76,19 +76,30 @@ sub ask_warn($$$) { sub ask_yesorno($$$;$) { my ($o, $title, $message, $def) = @_; - ask_from_list2_($o, $title, $message, [ __("Yes"), __("No") ], $def ? "Yes" : "No") eq "Yes"; + ask_from_list_($o, $title, $message, [ __("Yes"), __("No") ], $def ? "Yes" : "No") eq "Yes"; } sub ask_okcancel($$$;$) { my ($o, $title, $message, $def) = @_; - ask_from_list2_($o, $title, $message, [ __("Ok"), __("Cancel") ], $def ? "Ok" : "Cancel") eq "Ok"; + ask_from_list_($o, $title, $message, [ __("Ok"), __("Cancel") ], $def ? "Ok" : "Cancel") eq "Ok"; } sub ask_from_list_ { my ($o, $title, $message, $l, $def) = @_; - @$l == 0 and die ''; - @$l == 1 and return $l->[0]; - goto &ask_from_list2_; + ask_from_listf($o, $title, $message, sub { translate($_[0]) }, @$l, $def); +} + +sub ask_from_listf_ { + my ($o, $title, $message, $f, $l, $def) = @_; + ask_from_listf($o, $title, $message, sub { translate($f->(@_)) }, $l, $def); +} +sub ask_from_listf { + my ($o, $title, $message, $f, $l, $def) = @_; + my %l; my $i = 0; foreach (@$l) { + $l{$f->($_, $i++)} = $_; + } + my $r = ask_from_list($o, $title, $message, [ keys %l ], $f->($def)) or return; + $l{$r}; } sub ask_from_list { @@ -98,13 +109,6 @@ sub ask_from_list { goto &ask_from_list2; } -sub ask_from_list2_($$$$;$) { - my ($o, $title, $message, $l, $def) = @_; - untranslate( - ask_from_list($o, $title, $message, [ map { translate($_) } @$l ], translate($def)), - @$l); -} - sub ask_from_list2($$$$;$) { my ($o, $title, $message, $l, $def) = @_; @@ -160,6 +164,10 @@ sub ask_from_treelistW($$$$;$) { +sub ask_many_from_list_refH { + my ($o, $title, $message, @l) = @_; + $o->ask_many_from_list_ref($title, $message, map { [ keys %$_ ], [ values %$_ ] } @l); +} sub ask_many_from_list_ref { my ($o, $title, $message, @l) = @_; $o->ask_many_from_list_with_help_ref($title, [ deref($message) ], map { ($_->[0], [], $_->[1]) } combine(2, @l)); diff --git a/perl-install/keyboard.pm b/perl-install/keyboard.pm index b479c94b1..dcde8407c 100644 --- a/perl-install/keyboard.pm +++ b/perl-install/keyboard.pm @@ -182,18 +182,10 @@ arch() eq "ppc" ? ( #-###################################################################################### #- Functions #-###################################################################################### -sub list { map { $_->[0] } values %keyboards } sub xmodmaps { keys %keyboards } sub keyboard2text { $keyboards{$_[0]} && $keyboards{$_[0]}[0] } sub keyboard2kmap { $keyboards{$_[0]} && $keyboards{$_[0]}[1] } sub keyboard2xkb { $keyboards{$_[0]} && $keyboards{$_[0]}[2] } -sub text2keyboard { - my ($t) = @_; - foreach (keys %keyboards) { - lc($keyboards{$_}[0]) eq lc($t) and return $_; - } - die "unknown keyboard $t"; -} sub loadkeys_files { my $archkbd = arch() =~ /^sparc/ ? "sun" : arch() =~ /^i\d/ ? "i386" : arch(); diff --git a/perl-install/lang.pm b/perl-install/lang.pm index 8bd641de9..e12fc789a 100644 --- a/perl-install/lang.pm +++ b/perl-install/lang.pm @@ -209,7 +209,7 @@ my %charsets = ( #- Functions #-###################################################################################### -sub list { sort { $a cmp $b } map { $_->[0] } values %languages } +sub list { sort { $a cmp $b } keys %languages } sub lang2text { $languages{$_[0]} && $languages{$_[0]}[0] } sub text2lang { my ($t) = @_; diff --git a/perl-install/modules.pm b/perl-install/modules.pm index 88852a039..cf17285e3 100644 --- a/perl-install/modules.pm +++ b/perl-install/modules.pm @@ -322,26 +322,17 @@ while (my ($k, $v) = each %drivers) { 1; -sub module_of_type($) { +sub module_of_type__4update_kernel { my ($type) = @_; my %skip; @skip{@skip_modules_on_stage1} = (); - grep { !exists $skip{$_} } grep { $drivers{$_}{type} =~ /^($type)$/ } keys %drivers; + grep { !exists $skip{$_} } grep { $drivers{$_}{type} =~ /^$type$/ } keys %drivers; } - -sub text_of_type($) { +sub module_of_type { my ($type) = @_; my $alias = $type_aliases{$type}; - - map { $_->{text} } grep { $_->{type} eq $type || $_->{type} eq $alias } values %drivers; -} - -sub text2driver($) { - my ($text) = @_; - foreach (keys %drivers) { - $drivers{$_}{text} eq $text and return $_; - } - die "$text is not a valid module description"; + grep { $drivers{$_}{type} =~ /^$type|$alias$/ } keys %drivers; } +sub module2text { $drivers{$_[0]}{text} } sub get_alias { my ($alias) = @_; diff --git a/perl-install/mouse.pm b/perl-install/mouse.pm index 239a3de17..578765f7b 100644 --- a/perl-install/mouse.pm +++ b/perl-install/mouse.pm @@ -96,6 +96,7 @@ my @xmousetypes = ( sub xmouse2xId { my ($id) = @_; my $i; map_index { $_ eq $id and $i = $::i } @xmousetypes; $i } sub names { map { $_->{FULLNAME} } @mouses } +sub list { @mouses } sub name2mouse { my ($name) = @_; @@ -109,12 +110,10 @@ sub X2nbuttons { first(map { $_->{nbuttons} } grep { $_->{XMOUSETYPE} eq $_[0] } @mouses); } -sub serial_ports_names() { - map { "ttyS" . ($_ - 1) . " / COM$_" } 1..4; -} -sub serial_ports_names2dev { - local ($_) = @_; - first(/(\w+)/); +sub serial_ports() { map { "ttyS$_" } 0..3 } +sub serial_port2text { + $_[0] =~ /ttyS (\d+)/x; + "$_[0] / COM" . ($1 + 1); } sub read($) { @@ -179,9 +178,12 @@ sub detect() { modules::load("mousedev"); }; sleep(2); - if (!$@ && detect_devices::tryOpen("usbmouse")) { + if (!$@) { + my $dev; + $dev ||= "usbmouse" if detect_devices::tryOpen("usbmouse"); + $dev ||= "usbmice" if detect_devices::tryOpen("usbmice"); $wacom or modules::unload("serial"); - return name2mouse("USB Mouse"), $wacom; + return add2hash({ device => $dev }, name2mouse("USB Mouse")), $wacom; } modules::unload("mousedev"); modules::unload("usbmouse"); diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index fc43e53ab..c0d45d437 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -25,7 +25,7 @@ use log; @important_types = ('Linux native', 'Linux swap', 'Win98 FAT32'); @important_types2 = (arch() =~ /i.86/ ? 'ReiserFS' : (), 'Linux RAID'); -@fields2save = qw(primary extended totalsectors); +@fields2save = qw(primary extended totalsectors isDirty needKernelReread); my %types = ( @@ -473,6 +473,7 @@ sub write($) { } } $hd->{isDirty} = 0; + $hd->{hasBeenDirty} = 1; #- used in undo (to know if undo should believe isDirty or not) #- now sync disk and re-read the partition table if ($hd->{needKernelReread}) { diff --git a/perl-install/partition_table_raw.pm b/perl-install/partition_table_raw.pm index 4fe3fe73b..70bb99fd4 100644 --- a/perl-install/partition_table_raw.pm +++ b/perl-install/partition_table_raw.pm @@ -9,9 +9,10 @@ use c; my @MBR_signatures = ( [ 'empty', 0, "\0\0\0\0" ], + [ 'grub', 0, "\xEBG", 0x17d, "stage1 \0" ], + [ 'grub', 0, "\xEBH", 0x18a, "stage1 \0" ], [ 'lilo', 0x2, "LILO" ], [ 'lilo', 0x6, "LILO" ], - [ 'grub', 0x17d, "stage1 \0" ], [ 'osbs', 0x2, "OSBS" ], #- http://www.prz.tu-berlin.de/~wolf/os-bs.html [ 'pqmagic', 0xef, "PQV" ], [ 'BootStar', 0x130, "BootStar:" ], @@ -88,6 +89,18 @@ sub get_geometry($) { { geom => \%geom, totalsectors => $geom{heads} * $geom{sectors} * $geom{cylinders} }; } +#- works for both hard drives and partitions ;p +sub description { + my ($hd) = @_; + my $win = $hd->{device_windobe}; + + sprintf "%s%s (%d%s%s)", + $hd->{device}, + $win && " [$win:]", + ($hd->{totalsectors} || $hd->{size}) >> 11, _("MB"), + $hd->{info} && ", $hd->{info}"; +} + sub openit($$;$) { sysopen $_[1], $_[0]{file}, $_[2] || 0; } # cause kernel to re-read partition table diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm index 827ef9a33..9d7349740 100644 --- a/perl-install/printerdrake.pm +++ b/perl-install/printerdrake.pm @@ -195,8 +195,7 @@ _("Extra Text options") => \$printer->{TEXTONLYOPTIONS}, printer::configure_queue($printer); $printer->{complete} = 0; - $action = ${{reverse %action}}{$in->ask_from_list('', _("Do you want to test printing?"), - [ map { $action{$_} } @action ], $action{'done'})}; + $action = $in->ask_from_list('', _("Do you want to test printing?"), sub { $action{$_[0]} }, \@action, 'done'); my @testpages; push @testpages, "/usr/lib/rhs/rhs-printfilters/testpage.asc" diff --git a/update_kernel b/update_kernel index 28f959cf8..a644e99a1 100755 --- a/update_kernel +++ b/update_kernel @@ -3,7 +3,7 @@ KERNEL_BOOT_PATH="kernel" function f() { - v=`perl -Iperl-install -Mmodules -e "print qq(\\$_.o\n) foreach modules::module_of_type(\"$1\")"` + v=`perl -Iperl-install -Mmodules -e "print qq(\\$_.o\n) foreach modules::module_of_type__4update_kernel(\"$1\")"` } ARCH=`uname -m | sed -e 's/i.86/i386/' -e 's/sparc.*/sparc/'` -- cgit v1.2.1