From deddef1f4746139ed4ef994d8f053bf39d4d6384 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sat, 17 Jul 1999 16:45:33 +0000 Subject: *** empty log message *** --- perl-install/install2.pm | 43 +++++++++++++++++--------------- perl-install/install_any.pm | 12 ++++++++- perl-install/install_steps.pm | 3 --- perl-install/install_steps_stdio.pm | 11 +++++---- perl-install/lang.pm | 9 ++++++- perl-install/my_gtk.pm | 49 +++++++++++++++++++++++++++++++++---- perl-install/pkgs.pm | 43 -------------------------------- 7 files changed, 92 insertions(+), 78 deletions(-) diff --git a/perl-install/install2.pm b/perl-install/install2.pm index 859e46e30..ff8c55994 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -1,7 +1,5 @@ #!/usr/bin/perl -# $o->{hints}->{component} *was* 'Workstation' or 'Server' or NULL - use diagnostics; use strict; use vars qw($testing $INSTALL_VERSION $o); @@ -15,10 +13,10 @@ use keyboard; use fs; use fsedit; use install_steps_graphical; -use install_methods; use modules; use partition_table qw(:types); use detect_devices; +use pkgs; use smp; $testing = 1;#$ENV{PERL_INSTALL_TEST}; @@ -31,6 +29,7 @@ my @installSteps = ( selectInstallClass => [ "Select installation class", "aide", 0, 0 ], setupSCSI => [ "Setup SCSI", "aide", 0, 1 ], partitionDisks => [ "Setup filesystems", "aide", 0, 1 ], + formatPartitions => [ "Format partitions", "aide", 0, 1 ], findInstallFiles => [ "Find installation files", "aide", 1, 0 ], choosePackages => [ "Choose packages to install", "aide", 0, 0 ], doInstallStep => [ "Install system", "aide", 0, 0 ], @@ -99,7 +98,14 @@ my $default = { installClass => 'Server', bootloader => { onmbr => 1, linear => 0 }, mkbootdisk => 0, - comps => [ qw() ], + base => [ qw(basesystem mkbootdisk linuxconf anacron linux_logo rhs-hwdiag utempter ldconfig chkconfig ntsysv mktemp setup setuptool filesystem MAKEDEV SysVinit ash at authconfig bash bdflush binutils console-tools cpio crontabs dev diffutils e2fsprogs ed eject etcskel file fileutils findutils getty_ps gpm grep groff gzip hdparm info initscripts isapnptools kbdconfig kernel less ldconfig lilo logrotate losetup mailcap mailx man mkinitrd mingetty modutils mount mouseconfig net-tools passwd kernel-pcmcia-cs procmail procps psmisc pump mandrake-release rootfiles rpm sash sed setconsole setserial shadow-utils sh-utils slocate stat sysklogd tar termcap textutils time timeconfig tmpwatch util-linux vim-minimal vixie-cron which) ], + comps => [ + [ 1, 'X Window System' => qw(XFree86 XFree86-xfs XFree86-75dpi-fonts) ], + [ 1, 'KDE' => qw(kdeadmin kdebase kthememgr kdegames kjumpingcube kdegraphics kdelibs kdemultimedia kdenetwork kdesupport kdeutils kBeroFTPD kdesu kdetoys kpilot kcmlaptop kdpms kpppload kmpg) ], + [ 0, 'Console Multimedia' => qw(aumix audiofile esound sndconfig awesfx rhsound cdp mpg123 svgalib playmidi sox mikmod) ], + [ 0, 'CD-R burning and utilities' => qw(mkisofs cdrecord cdrecord-cdda2wav cdparanoia xcdroast) ], + [ 0, 'Games' => qw(xbill xboard xboing xfishtank xgammon xjewel xpat2 xpilot xpuzzles xtrojka xkobo freeciv) ], + ], packages => [ qw() ], partitionning => { clearall => 0, eraseBadPartitions => 1, autoformat => 1 }, partitions => [ @@ -121,13 +127,17 @@ sub selectPath { $o->{isUpgrade} = $o->selectInstallOrUpgrade; $o->{steps} = $o->{isUpgrade} ? \%upgradeSteps : \%installSteps; $o->{orderedSteps} = $o->{isUpgrade} ? \@orderedUpgradeSteps : \@orderedInstallSteps; + + $o->{comps} = [ @{$o->{default}->{comps}} ]; + foreach (@{$o->{comps}}) { + my ($selected, $name, @packages) = @$_; + $_ = { selected => $selected, name => $name, packages => \@packages }; + } } sub selectInstallClass { $o->{installClass} = $o->selectInstallClass; - $testing and $o->{default}->{partitionning}->{clearall} = 1; - if ($o->{installClass} eq 'Server') { #TODO } @@ -167,6 +177,9 @@ sub partitionDisks { my $root_fs; map { $_->{mntpoint} eq '/' and $root_fs = $_ } @{$o->{fstab}}; $root_fs or die "partitionning failed: no root filesystem"; +} + +sub formatPartitions { $o->choosePartitionsToFormat($o->{fstab}); $testing and return; @@ -178,25 +191,16 @@ sub partitionDisks { } sub findInstallFiles { - $o->{packages} = $o->{method}->getPackageSet; - $o->{comps} = $o->{method}->getComponentSet($o->{packages}); + $o->{packages} = pkgs::psFromHeaderListFile(install_any::imageGetFile("hdlist")); } sub choosePackages { - # remove Base from comps so that it's hidden - my $base = $o->{comps}->{Base}; - delete $o->{comps}->{Base}; - $o->choosePackages($o->{packages}, $o->{comps}); - #restore Base - $o->{comps}->{Base} = $base; - $o->{comps}->{Base}->{selected} = 1; + my @p = @{$o->{default}->{base}}, grep { $_->{selected} } @{$o->{comps}}; + push @p, "kernel-smp" if smp::detect(); - foreach (grep { $_->{selected} } values %{$o->{comps}}) { - foreach (@{$_->{packages}}) { $_->{selected} = 1 } - } - smp::detect() and $o->{packages}->{"kernel-smp"}->{selected} = 1; + foreach (@p) { $o->{packages}->{$_}->{selected} = 1 } } sub doInstallStep { @@ -257,7 +261,6 @@ sub main { $o->{prefix} = $testing ? "/tmp/test-perl-install" : "/mnt"; mkdir $o->{prefix}, 0755; - $o->{method} = install_methods->new('cdrom'); $o = install_steps_graphical->new($o); diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 34f4c9139..f7bac3580 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -10,11 +10,21 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK); ); @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; -use common qw(:system); +use common qw(:common :system); use log; 1; +sub fileInBase { member($_[0], qw(hdlist comps)); } + +sub imageGetFile { + fileInBase($_[0]) and return "/tmp/rhimage/Mandrake/base/$_[0]"; + my $f = "/tmp/rhimage/Mandrake/RPMS/$_[0]"; + -r $f and return $f; + $f =~ s/i386/i586/; + $f; +} + sub versionString { my $kernel = $::o->{packages}->{kernel} or die "I couldn't find the kernel package!"; diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index b64952370..ace94a692 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -74,9 +74,6 @@ sub choosePartitionsToFormat($$) { sub choosePackages($$$) { my ($o, $packages, $comps) = @_; - - foreach (@{$o->{default}->{comps}}) { $comps->{$_}->{selected} = 1; } - foreach (@{$o->{default}->{packages}}) { $packages->{$_}->{selected} = 1; } } sub beforeInstallPackages($) { diff --git a/perl-install/install_steps_stdio.pm b/perl-install/install_steps_stdio.pm index 44de0dd60..9db9b2f9f 100644 --- a/perl-install/install_steps_stdio.pm +++ b/perl-install/install_steps_stdio.pm @@ -28,7 +28,9 @@ sub leavingStep { } sub chooseLanguage($) { - my $lang = ask_from_list('Language', 'Which language do you want?', [ lang::list() ]); + my $lang = lang::text2lang(ask_from_list('Language', + 'Which language do you want?', + [ lang::list() ])); run_program::run('xmodmap', "/usr/bin/$lang.map"); $lang; } @@ -56,13 +58,12 @@ sub choosePartitionsToFormat($$) { sub choosePackages($$$) { my ($o, $packages, $comps) = @_; - my @comps = values %$comps; my @r = ask_many_from_list('', "Choose the packages you want to install", - [ map { $_->{name} } @comps ], - [ map { $_->{selected} } @comps ]); + [ map { $_->{name} } @$comps ], + [ map { $_->{selected} } @$comps ]); - for (my $i = 0; $i < @comps; $i++) { + for (my $i = 0; $i < @$comps; $i++) { $comps[$i]->{selected} = $r[$i]; } } diff --git a/perl-install/lang.pm b/perl-install/lang.pm index a14c7c3ca..c7d8ed25e 100644 --- a/perl-install/lang.pm +++ b/perl-install/lang.pm @@ -24,7 +24,14 @@ my %languages = ( 1; -sub list { keys %languages } +sub list { map { $_->[0] } values %languages } +sub text2lang { + my ($t) = @_; + while (my ($k, $v) = each %languages) { + $v->[0] eq $t and return $k; + } + die "unknown language $t"; +} sub set { my $lang = shift; diff --git a/perl-install/my_gtk.pm b/perl-install/my_gtk.pm index 778cf53cb..b7a3405f5 100644 --- a/perl-install/my_gtk.pm +++ b/perl-install/my_gtk.pm @@ -12,6 +12,9 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK); use Gtk; use c; +use common qw(:common); + +my $forgetTime = 1000; # in milli-seconds 1; @@ -202,7 +205,7 @@ sub _create_window($$) { my ($o, $title) = @_; $o->{window} = new Gtk::Window; $o->{window}->set_title($title); - $o->{window}->signal_connect("expose_event" => sub { c::XSetInputFocus($o->{window}->window->XWINDOW) }) if $my_gtk::force_focus; + $o->{window}->signal_connect("expose_event" => sub { c::XSetInputFocus($o->{window}->window->XWINDOW) }) if $my_gtk::force_focus; $o->{window}->signal_connect("delete_event" => sub { $o->{retval} = undef; Gtk->main_quit }); $o->{window}->set_uposition(@$my_gtk::force_position) if $my_gtk::force_position; $o->{window} @@ -242,14 +245,50 @@ sub _ask_from_entry($$@) { sub _ask_from_list($$$@) { my ($o, $l, @msgs) = @_; my $list = new Gtk::List; + my ($first_time, $starting_word) = (1, ''); + my (@widgets, $timeout); my @sorted = sort @$l; - $list->signal_connect(select_child => sub { + $list->signal_connect(select_child => sub { $o->{retval} = $sorted[$list->child_position($_[1])]; Gtk->main_quit; }); - gtkadd($list, map { new Gtk::ListItem($_) } @sorted); - - gtkadd($o->{window}, gtkpack($o->create_box_with_title(@msgs), $list)); + for (my $i = 0; $i < @sorted; $i++) { + my $focused = $i; + my $w = new Gtk::ListItem($sorted[$i]); + $w->signal_connect(key_press_event => sub { + my ($w, $e)= @_; + my $c = chr $e->{keyval}; + + Gtk->timeout_remove($timeout) if $timeout; $timeout = ''; + + if ($e->{keyval} >= 0x100) { + if ($c eq "\r" || $c eq "\x8d") { + $list->select_item($focused); + } + $starting_word = ''; + } else { + my $curr = $focused + bool($starting_word eq '' || $starting_word eq $c); + $starting_word .= $c unless $starting_word eq $c; + + my $j; for ($j = 0; $j < @sorted; $j++) { + $sorted[($j + $curr) % @sorted] =~ /^$starting_word/i and last; + } + $j == @sorted ? + $starting_word = '' : + $widgets[($j + $curr) % @sorted]->grab_focus; + + $timeout = Gtk->timeout_add($forgetTime, sub { $timeout = $starting_word = ''; 0 } ); + } + }); + push @widgets, $w; + } + gtkadd($list, @widgets); + gtkadd($o->{window}, + gtkpack($o->create_box_with_title(@msgs), + @widgets > 15 ? + gtkset_usize(createScrolledWindow($list), 0, 300) : + $list)); + $widgets[0]->grab_focus; } sub _ask_warn($@) { diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index d512c7c5a..060add8c5 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -45,43 +45,6 @@ sub psUsingDirectory { \%packages; } -sub psReadComponentsFile { - my ($compsfile, $packages) = @_; - my (%comps, %current); - - local *F; - open F, $compsfile or die "Cannot open components file: $!"; - - =~ /^0(\.1)?$/ or die "Comps file is not version 0.1 as expected"; - - my $inComp = 0; - my $n = 0; - foreach () { $n++; - chomp; - s/^ +//; - /^#/ and next; - /^$/ and next; - - if ($inComp) { if (/^end$/) { - $inComp = 0; - $comps{$current{name}} = { %current }; - } else { - $packages->{$_} ? - push @{$current{packages}}, $packages->{$_} : - log::w("package $_ does not exist (line $n of comps file)"); - } - } else { - my ($selected, $hidden, $name) = /^([01])\s*(--hide)?\s*(.*)/ or die "bad comps file at line $n"; - %current = (selected => $selected, inmenu => !$hidden, name => $name); - $inComp = 1; - } - } - log::l("read " . (scalar keys %comps) . " comps"); - \%comps; -} - - - sub psVerifyDependencies { # my ($packages, $fixup) = @_; # @@ -110,12 +73,6 @@ sub psVerifyDependencies { # 1; } -sub selectComponents { - my ($csp, $psp, $doIndividual) = @_; - - return 0; -} - sub psFromHeaderListDesc { my ($fd, $noSeek) = @_; my %packages; -- cgit v1.2.1