summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/logdrake
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2002-11-20 12:43:55 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2002-11-20 12:43:55 +0000
commit717ec5842fa3908605dee6a881299b834f141319 (patch)
treeb2dd38dfc37226980c5c3085a94c7bac94d643c9 /perl-install/standalone/logdrake
parent9cad98dbf947e0dc929cd81bab53e4b23f1e8538 (diff)
downloaddrakx-717ec5842fa3908605dee6a881299b834f141319.tar
drakx-717ec5842fa3908605dee6a881299b834f141319.tar.gz
drakx-717ec5842fa3908605dee6a881299b834f141319.tar.bz2
drakx-717ec5842fa3908605dee6a881299b834f141319.tar.xz
drakx-717ec5842fa3908605dee6a881299b834f141319.zip
- logdrake does not need any
- use ugtk for gtkcolor & co - perl_checker fixes
Diffstat (limited to 'perl-install/standalone/logdrake')
-rwxr-xr-xperl-install/standalone/logdrake101
1 files changed, 52 insertions, 49 deletions
diff --git a/perl-install/standalone/logdrake b/perl-install/standalone/logdrake
index 442e5595b..c9ffc68f1 100755
--- a/perl-install/standalone/logdrake
+++ b/perl-install/standalone/logdrake
@@ -24,7 +24,7 @@ use lib qw(/usr/lib/libDrakX);
use standalone; #- warning, standalone must be loaded very first, for 'explanations'
use common;
use interactive;
-use any;
+use ugtk qw(:helpers :wrappers);
use my_gtk qw(:helpers :wrappers);
$::isInstall and die "Not supported during install.\n";
@@ -39,41 +39,41 @@ if ($::isEmbedded) {
}
#- parse arguments list.
-for (@ARGV) {
+foreach (@ARGV) {
/^--explain=(.*)$/ and do { $::isExplain = ($::Explain) = $1; $::isFile = 1; $::File = "/var/log/explanations"; next };
/^--file=(.*)$/ and do { $::isFile = ($::File) = $1; next };
/^--word=(.*)$/ and do { $::isWord = ($::Word) = $1; next };
/^--alert$/ and do { alert_config(); quit() };
}
-$::isTail = 1 if ($::isFile);
-$| = 1 if ($::isTail);
+$::isTail = 1 if $::isFile;
+n$| = 1 if $::isTail;
my $h = chomp_(`hostname -s`);
my $my_win = my_gtk->new('logdrake');
unless ($::isEmbedded) {
$my_win->{rwindow}->set_title(N("logdrake"));
- $my_win->{window}->border_width (5);
+ $my_win->{window}->border_width(5);
$my_win->{rwindow}->set_policy(1, 1, 1);
}
$my_win->{window}->signal_connect(delete_event => \&quit);
#$my_win->{window}->set_default_size(540,460);
my $cal = gtkset_sensitive(new Gtk::Calendar(),0);
-my (undef,undef,undef,$mday) = localtime(time);
+my (undef,undef,undef,$mday) = localtime(time());
$cal->select_day($mday);
my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my $cal_mode = 0;
-my $cal_butt = gtksignal_connect(new Gtk::CheckButton(N("Show only for the selected day")), clicked =>sub{ $cal_mode =!$cal_mode; gtkset_sensitive($cal,$cal_mode) });
+my $cal_butt = gtksignal_connect(new Gtk::CheckButton(N("Show only for the selected day")), clicked => sub { $cal_mode = !$cal_mode; gtkset_sensitive($cal,$cal_mode) });
### menus definition
# the menus are not shown
# but they provides shiny shortcut like C-q
my @menu_items = (
{ path => N("/_File"), type => '<Branch>' },
- { path => N("/File/_New"), accelerator => N("<control>N"), callback => \&print_hello },
- { path => N("/File/_Open"), accelerator => N("<control>O"),callback => \&print_hello },
- { path => N("/File/_Save"), accelerator => N("<control>S"),callback => \&save },
+ { path => N("/File/_New"), accelerator => N("<control>N"), ncallback => \&print_hello },
+ { path => N("/File/_Open"), accelerator => N("<control>O"), callback => \&print_hello },
+ { path => N("/File/_Save"), accelerator => N("<control>S"), callback => \&save },
{ path => N("/File/Save _As") },
{ path => N("/File/-"),type => '<Separator>' },
{ path => N("/File/_Quit"), accelerator => N("<control>Q"), callback => \&quit },
@@ -168,7 +168,7 @@ gtkadd($my_win->{window},
gtkpack_(new Gtk::HBox(0,0),
1, gtkadd(gtkset_border_width(new Gtk::Frame(N("Choose file")),2),
gtkpack (gtkset_border_width(new Gtk::VBox(0,0),0),
- map { ${ "b_". $_ } = gtksignal_connect(new Gtk::CheckButton($files{ $_ }{desc}), clicked => sub{ $refcount_search++; gtkset_sensitive($yy,$refcount_search) }) } keys %files,
+ map { ${ "b_". $_ } = gtksignal_connect(new Gtk::CheckButton($files{$_}{desc}), clicked => sub{ $refcount_search++; gtkset_sensitive($yy,$refcount_search) }) } keys %files,
)
),
0, gtkadd(gtkset_border_width(new Gtk::Frame(N("Calendar")),2),
@@ -205,7 +205,7 @@ use strict;
$::isFile and gtkset_usize($log_text,400,500);
$my_win->{window}->realize;
$my_win->{window}->show_all();
-search() if ($::isFile);
+search() if $::isFile;
$my_win->main;
sub quit { my_gtk->exit(0) }
@@ -220,7 +220,7 @@ sub search {
parse_file($::File);
} else {
foreach (keys %files) {
- parse_file($files{ $_ }{file}) if ${ $::{ "b_". $_ }}->active
+ parse_file($files{$_}{fnile}) if ${ $::{"b_" . $_} n}->active
};
}
$log_text->thaw();
@@ -234,7 +234,7 @@ sub parse_file {
my $i = 0;
gtkadd(my $win_pb = (gtkset_modal new Gtk::Window(), 1),
gtkpack(new Gtk::VBox(5,0),
- " " . N("please wait, parsing file: %s", $files{ $_ }{desc}) . " ",
+ " " . N("please wait, parsing file: %s", $files{$_}{desc}) . " ",
my $pbar = new Gtk::ProgressBar()
)
);
@@ -246,21 +246,21 @@ sub parse_file {
$ey =~ s/ OR /\|/;
$ey =~ s/^\*$//;
$en =~ s/^\*$/.*/;
- $ey = $ey .($::Word) if ($::isWord);
+ $ey = $ey . $::Word if $::isWord;
if ($cal_mode) {
my ($year, $month, $day) = $cal->get_date();
$ey = $months[$month]."\\s{1,2}$day\\s.*$ey.*\n";
}
- my @all = catMaybeCompressed ($file);
+ my @all = catMaybeCompressed($file);
if ($::isExplain) {
my (@t, $t);
while (@all) {
$t = pop @all;
- next if ($t =~ /logdrake/);
- last if !($t =~ /$::Explain/);
+ next if $t =~ /logdrake/;
+ last if $t !~ /$::Explain/;
push @t, $t;
}
@all = reverse @t;
@@ -274,14 +274,16 @@ sub parse_file {
Gtk->main_iteration while Gtk->events_pending;
}
- if (($en eq "") and /$ey/i) { logcolorize($_); next }
- if ((! /$en/i) and /$ey/i) { logcolorize($_); next }
- if ((! /$en/i) and ($ey eq "")) { logcolorize($_); next }
+ if ($en eq "" and /$ey/i) { logcolorize($_); next }
+ if (! /$en/i and /$ey/i) { logcolorize($_); next }
+ if (! /$en/i and $ey eq "") { logcolorize($_); next }
}
$win_pb->destroy();
if ($::isTail) {
+ local *F;
open F, $file or die "E: $!";
+ local $_;
while (<F>) {}; #to prevent to output the file twice..
$log_text->set_point($log_text->get_length());
my $timer = Gtk->timeout_add(1000, \&input_callback);
@@ -304,48 +306,48 @@ sub logcolorize {
my @rec = split;
log_output($cyan,$timestamp,$b); # date & time if any...
- $::isExplain or log_output(($rec[0] eq $h) ? $blue : $col,"$rec[0] ",$b); # hostname
+ $::isExplain or log_output($rec[0] eq $h ? $blue : $col, "$rec[0] ",$b); # hostname
if ($rec[1] eq "last") {
- log_output($green," last message repeated ",$n);
+ log_output($green, " last message repeated ",$n);
log_output($green, $rec[4], $b);
- log_output($green," times\n",$n);
+ log_output($green, " times\n",$n);
return;
}
# Extract PID if present
if ($rec[1] =~ /\[(\d+)\]\:/) {
my($pid) = $1;
- $rec[1] =~s/\[$1\]\:// ;
- log_output ($green, $rec[1] ."[",$n);
+ $rec[1] =~ s/\[$1\]\://;
+ log_output ($green, $rec[1] . "[", $n);
log_output ($black, $pid,$b);
log_output ($green, "]: ",$n);
}
else {
- log_output($green, $rec[1] ." ",$n);
+ log_output($green, $rec[1] . " ", $n);
}
- for my $therest (2 .. $#rec) {
+ foreach my $therest (2 .. $#rec) {
$col = $cyan;
# Check for keywords to highlight
- foreach (@word_good) { $col = $col_good if ($_ eq $rec[$therest]) }
- foreach (@word_warn) { $col = $col_warn if ($_ eq $rec[$therest]) }
- foreach (@word_bad) { $col = $col_bad if ($_ eq $rec[$therest]) }
- foreach (@word_note) { $col = $col_note if ($_ eq $rec[$therest]) }
+ foreach (@word_good) { $col = $col_good if $_ eq $rec[$therest] }
+ foreach (@word_warn) { $col = $col_warn if $_ eq $rec[$therest] }
+ foreach (@word_bad) { $col = $col_bad if $_ eq $rec[$therest] }
+ foreach (@word_note) { $col = $col_note if $_ eq $rec[$therest] }
# Watch for words that indicate entire lines should be highlighted
- #foreach (@line_good) { $col = $col_good if ($_ eq $rec[$therest]) }
- #foreach (@line_warn) { $col = $col_warn if ($_ eq $rec[$therest]) }
- #foreach (@line_bad) { $col = $col_bad if ($_ eq $rec[$therest]) }
+ #foreach (@line_good) { $col = $col_good if $_ eq $rec[$therest] }
+ #foreach (@line_warn) { $col = $col_warn if $_ eq $rec[$therest] }
+ #foreach (@line_bad) { $col = $col_bad if $_ eq $rec[$therest] }
- log_output($col,"$rec[$therest] ",$n);
+ log_output($col, "$rec[$therest] ", $n);
}
- log_output($black,"\n",$n);
+ log_output($black, "\n",$n);
}
sub log_output {
- $log_text->insert($_[2],$_[0], undef,$_[1]);
+ $log_text->insert($_[2], $_[0], undef, $_[1]);
}
@@ -391,20 +393,20 @@ my $initdir = "/etc/init.d";
webmin => N("Webmin Service"),
xinetd => N("Xinetd Service")
};
- my @installed_d = ();
+ my @installed_d;
foreach my $serv (keys %$service) {
-e "$initdir/$serv" && push (@installed_d,$serv);
}
$in->ask_from(N("service setting"),
N("You will receive an alert if one of the selected services is no more running"),
- [ map { { label => "$_", val => \${ $_ }, type => "bool", text => "$service->{ $_ }" } } @installed_d
+ [ map { { label => $_, val => \${ $_ }, type => "bool", text => "$service->{ $_ }" } } @installed_d
]) or goto begin;
$cron .= "#- check services\n";
my $r;
foreach (@installed_d) {
- if(!-e "/var/lock/subsys/$_") { $r .= "Service $_ ($service->{$_} is not running\n" };
+ $r .= "Service $_ ($service->{$_} is not running\n" unless -e "/var/lock/subsys/$_";
# $cron .= "$r" if ${ $_ }; # take a look at this, don't know what is done here
}
@@ -419,7 +421,7 @@ my $initdir = "/etc/init.d";
$cron .= sprintf(<<'EOF', $load);
#- load
my ($load) = split ' ', first(cat_("/proc/loadavg"));
-$r .= "Load is huge: $load\n" if ($load > %s);
+$r .= "Load is huge: $load\n" if $load > %s;
EOF
@@ -430,14 +432,15 @@ EOF
N("Please enter your email address below "),
[
{ label => "" },
- { label => "Email", val => \$email},
+ { label => "Email", val => \$email },
]) or goto step_load;
$cron .= q(#- report it);
$cron .= q(
-$email = ) . "'" . "$email" . "'" . ";\n\n";
+$email = ) . "'$email';\n\n";
$cron .= q(
+local *F;
open F, '|/usr/sbin/sendmail -oi -t';
print F
@@ -447,10 +450,10 @@ To: ), "$email\n";
print F $r;
# EOF);
- output "$cron_hourly", $cron;
+ output $cron_hourly, $cron;
chmod 0755, $cron_hourly;
- print ("whole cron is ****** $cron *******\n");
+ print "whole cron is ****** $cron *******\n";
undef $::isWizard;
if (defined $::WizardWindow) {
@@ -466,7 +469,7 @@ print F $r;
sub save {
- $::isWizard=0;
- $yy = $in->ask_file(N("Save as.."),"/root") or return;
- output($yy,$log_text->get_chars(0,$log_text->get_length()));
+ $::isWizard = 0;
+ $yy = $in->ask_file(N("Save as.."), "/root") or return;
+ output($yy, $log_text->get_chars(0, $log_text->get_length()));
}
n663' href='#n663'>663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308
package install_steps_interactive; # $Id$


use diagnostics;
use strict;
use vars qw(@ISA $new_bootstrap);

@ISA = qw(install_steps);


#-######################################################################################
#- misc imports
#-######################################################################################
use common;
use partition_table qw(:types);
use partition_table::raw;
use install_steps;
use install_interactive;
use install_any;
use install_messages;
use detect_devices;
use run_program;
use devices;
use fsedit;
use loopback;
use mouse;
use modules;
use modules::interactive;
use lang;
use keyboard;
use any;
use fs;
use log;

#-######################################################################################
#- In/Out Steps Functions
#-######################################################################################
sub errorInStep {
    my ($o, $err) = @_;
    $o->ask_warn(N("Error"), [ N("An error occurred"), formatError($err) ]);
}

sub kill_action {
    my ($o) = @_;
    $o->kill;
}

sub charsetChanged {
    my ($_o) = @_;
}

#-######################################################################################
#- Steps Functions
#-######################################################################################
#------------------------------------------------------------------------------
sub selectLanguage {
    my ($o) = @_;

    $o->{locale}{lang} = any::selectLanguage($o, $o->{locale}{lang}, $o->{locale}{langs} ||= {});
    install_steps::selectLanguage($o);

    $o->charsetChanged;

    if ($o->isa('interactive::gtk')) {
	$o->ask_warn('', formatAlaTeX(
"If you see this message it is because you chose a language for
which DrakX does not include a translation yet; however the fact
that it is listed means there is some support for it anyway.

That is, once GNU/Linux will be installed, you will be able to at
least read and write in that language; and possibly more (various
fonts, spell checkers, various programs translated etc. that
varies from language to language).")) if $o->{locale}{lang} !~ /^en/ && !lang::load_mo();
    } else {
	#- no need to have this in po since it is never translated
	$o->ask_warn('', "The characters of your language can't be displayed in console,
so the messages will be displayed in english during installation") if $ENV{LANGUAGE} eq 'C';
    }
}
    
sub acceptLicense {
    my ($o) = @_;

    my $r = 'Refuse';

    $o->ask_from_({ title => N("License agreement"), 
		    cancel => N("Quit"),
		    messages => formatAlaTeX(install_messages::main_license() . "\n\n\n" . install_messages::warning_about_patents()),
		    interactive_help_id => 'acceptLicense',
		    callbacks => { ok_disabled => sub { $r eq 'Refuse' } },
		  },
		  [ { list => [ N_("Accept"), N_("Refuse") ], val => \$r, type => 'list', format => sub { translate($_[0]) } } ]) 
      or do {
	  install_any::ejectCdrom();
	  $o->exit;
      };
}

#------------------------------------------------------------------------------
sub selectKeyboard {
    my ($o, $clicked) = @_;

    my $from_usb = keyboard::from_usb();
    my $l = keyboard::lang2keyboards(lang::langs($o->{locale}{langs}));

    if ($::expert || $clicked || !($from_usb || @$l && $l->[0][1] >= 90) || listlength(lang::langs($o->{locale}{langs})) > 1) {
	add2hash($o->{keyboard}, $from_usb);
	my @best = uniq($from_usb ? $from_usb->{KEYBOARD} : (), (map { $_->[0] } @$l), 'us_intl');

	my $format = sub { translate(keyboard::KEYBOARD2text($_[0])) };
	my $other;
	my $ext_keyboard = my $KEYBOARD = $o->{keyboard}{KEYBOARD};
	$o->ask_from_(
		      { title => N("Keyboard"), 
			messages => N("Please choose your keyboard layout."),
			interactive_help_id => 'selectKeyboard',
			advanced_messages => N("Here is the full list of keyboards available"),
			advanced_label => N("More"),
			callbacks => { changed => sub { $other = $_[0] == 1 } },
		      },
		      [ if_(@best > 1, { val => \$KEYBOARD, type => 'list', format => $format, sort => 1,
					 list => [ @best ] }),
			{ val => \$ext_keyboard, type => 'list', format => $format,
			  list => [ difference2([ keyboard::KEYBOARDs() ], \@best) ], advanced => @best > 1 }
		      ]);
	$o->{keyboard}{KEYBOARD} = $other ? $ext_keyboard : $KEYBOARD;
	delete $o->{keyboard}{unsafe};
    }
    keyboard::group_toggle_choose($o, $o->{keyboard}) or goto &selectKeyboard;
    install_steps::selectKeyboard($o);
}

#------------------------------------------------------------------------------
sub selectInstallClass {
    my ($o) = @_;

    if (my @l = install_any::find_root_parts($o->{fstab}, $o->{prefix})) {
	log::l("proposing to upgrade partitions " . join(" ", map { $_->{part}{device} } @l));

	my @releases = uniq(map { $_->{release} } @l);
	if (@releases != @l) {
	    #- same release name so adding the device to differentiate them:
	    $_->{release} .= " ($_->{part}{device})" foreach @l;
	}

	my $p;
	$o->ask_from_({ title => N("Install/Upgrade"),
			messages => N("Is this an install or an upgrade?"),
			interactive_help_id => 'selectInstallClass',
		      },
		      [ { val => \$p,
			  list => [ @l, N_("Install") ], 
			  type => 'list',
			  format => sub { ref($_[0]) ? N("Upgrade %s", $_[0]{release}) : translate($_[0]) }
			} ]);
	if (ref $p) {
	    my $part = $p->{part};
	    log::l("choosing to upgrade partition $part->{device}");
	    install_any::use_root_part($o->{all_hds}, $part, $o->{prefix});
	    foreach (grep { $_->{mntpoint} } @{$o->{fstab}}) {
		my ($options, $_unknown) = fs::mount_options_unpack($_);
		$options->{encrypted} or next;
		$o->ask_from_({ focus_first => 1 },
			      [ { label => N("Encryption key for %s", $_->{mntpoint}),
				  hidden => 1, val => \$_->{encrypt_key} } ]);
	    }
	    $o->{isUpgrade} = 1;
	}
    }
}

#------------------------------------------------------------------------------
sub selectMouse {
    my ($o, $force) = @_;

    $force ||= $o->{mouse}{unsafe} || 1;

    if ($force) {
	my $prev = $o->{mouse}{type} . '|' . $o->{mouse}{name};

	$o->ask_from_({ messages => N("Please choose your type of mouse."),
			interactive_help_id => 'selectMouse',
		      },
		     [ { list => [ mouse::fullnames() ], separator => '|', val => \$prev, format => sub { join('|', map { translate($_) } split('\|', $_[0])) } } ]);
	$o->{mouse} = mouse::fullname2mouse($prev);
    }

    if ($force && $o->{mouse}{type} eq 'serial') {
	$o->{mouse}{device} = 
	  $o->ask_from_listf_raw({ title => N("Mouse Port"),
				   messages => N("Please choose which serial port your mouse is connected to."),
				   interactive_help_id => 'selectSerialPort',
				 },
			    \&mouse::serial_port2text,
			    [ mouse::serial_ports() ]) or return &selectMouse;
    }
    if (arch() =~ /ppc/ && $o->{mouse}{nbuttons} == 1) {
	#- set a sane default F11/F12
	$o->{mouse}{button2_key} = 87;
	$o->{mouse}{button3_key} = 88;
	$o->ask_from('', N("Buttons emulation"),
		[
		{ label => N("Button 2 Emulation"), val => \$o->{mouse}{button2_key}, list => [ mouse::ppc_one_button_keys() ], format => \&mouse::ppc_one_button_key2text },
		{ label => N("Button 3 Emulation"), val => \$o->{mouse}{button3_key}, list => [ mouse::ppc_one_button_keys() ], format => \&mouse::ppc_one_button_key2text },
		]) or return;
    }
    
    if ($o->{mouse}{device} eq "usbmouse") {
	modules::interactive::load_category($o, 'bus/usb', 1, 1);
	eval { 
	    devices::make("usbmouse");
	    modules::load(qw(hid mousedev usbmouse));
	};
    }

    $o->SUPER::selectMouse;
    1;
}
#------------------------------------------------------------------------------
sub setupSCSI {
    my ($o) = @_;

    if (!$::noauto && arch() =~ /i.86/) {
	if ($o->{pcmcia} ||= !$::testing && c::pcmcia_probe()) {
	    my $w = $o->wait_message(N("PCMCIA"), N("Configuring PCMCIA cards..."));
	    my $results = modules::configure_pcmcia($o->{pcmcia});
	    $w = undef;
	    $results and $o->ask_warn('', $results);
	}
    }
    { 
	my $_w = $o->wait_message(N("IDE"), N("Configuring IDE"));
	modules::load(modules::category2modules('disk/cdrom'));
    }
    modules::interactive::load_category($o, 'bus/firewire', 1);

    my $have_non_scsi = detect_devices::hds(); #- at_least_one scsi device if we have no disks
    modules::interactive::load_category($o, 'disk/scsi|hardware_raid', 1, !$have_non_scsi);
    modules::interactive::load_category($o, 'disk/scsi|hardware_raid') if !detect_devices::hds(); #- we really want a disk!

    install_interactive::tellAboutProprietaryModules($o);

    install_any::getHds($o, $o);
}

sub ask_mntpoint_s { #- }{}
    my ($o, $fstab) = @_;

    my @fstab = grep { isTrueFS($_) } @$fstab;
    @fstab = grep { isSwap($_) } @$fstab if @fstab == 0;
    @fstab = @$fstab if @fstab == 0;
    die \N("No partition available") if @fstab == 0;

    {
	my $_w = $o->wait_message('', N("Scanning partitions to find mount points"));
	install_any::suggest_mount_points($fstab, $o->{prefix}, 'uniq');
	log::l("default mntpoint $_->{mntpoint} $_->{device}") foreach @fstab;
    }
    if (@fstab == 1) {
	$fstab[0]{mntpoint} = '/';
    } else {
	$o->ask_from_({ messages => N("Choose the mount points"),
			interactive_help_id => 'ask_mntpoint_s',
		      },
		      [ map { { label => partition_table::description($_), 
				  val => \$_->{mntpoint},
				    not_edit => 0,
				      list => [ '', fsedit::suggestions_mntpoint(fsedit::empty_all_hds()) ] }
			  } grep { !$_->{real_mntpoint} || common::usingRamdisk() } @fstab ]) or return;
    }
    $o->SUPER::ask_mntpoint_s($fstab);
}

#------------------------------------------------------------------------------
sub doPartitionDisks {
    my ($o) = @_;

    if (arch() =~ /ppc/ && detect_devices::get_mac_generation() =~ /NewWorld/) { #- need to make bootstrap part if NewWorld machine - thx Pixel ;^)
	if (defined $partition_table::mac::bootstrap_part) {
	    #- don't do anything if we've got the bootstrap setup
	    #- otherwise, go ahead and create one somewhere in the drive free space
	} else {
            undef = $partition_table::mac::freepart; #- please "perl -w"
            my $freepart = $partition_table::mac::freepart;
	    if ($freepart && $freepart->{size} >= 1) {	        
		log::l("creating bootstrap partition on drive /dev/$freepart->{hd}{device}, block $freepart->{start}");
		$partition_table::mac::bootstrap_part = $freepart->{part};	
		log::l("bootstrap now at $partition_table::mac::bootstrap_part");
		fsedit::add($freepart->{hd}, { start => $freepart->{start}, size => 1 << 11, type => 0x401, mntpoint => '' }, $o->{all_hds}, { force => 1, primaryOrExtended => 'Primary' });
		$new_bootstrap = 1;    
	    } else {
		$o->ask_warn('', N("No free space for 1MB bootstrap! Install will continue, but to boot your system, you'll need to create the bootstrap partition in DiskDrake"));
	    }
	}
    }

    if (!$o->{isUpgrade}) {
        install_interactive::partitionWizard($o);
    }
}

#------------------------------------------------------------------------------
sub rebootNeeded {
    my ($o) = @_;
    $o->ask_warn('', N("You need to reboot for the partition table modifications to take place"));

    install_steps::rebootNeeded($o);
}

#------------------------------------------------------------------------------
sub choosePartitionsToFormat {
    my ($o, $fstab) = @_;

    $o->SUPER::choosePartitionsToFormat($fstab);

    my @l = grep { !$_->{isMounted} && $_->{mntpoint} && 
		   (!isSwap($_) || $::expert) &&
		   (!isFat_or_NTFS($_) || $_->{notFormatted} || $::expert) &&
		   (!isOtherAvailableFS($_) || $::expert || $_->{toFormat})
	       } @$fstab;
    $_->{toFormat} = 1 foreach grep { isSwap($_) && !$::expert } @$fstab;

    return if @l == 0 || !$::expert && every { $_->{toFormat} } @l;

    #- keep it temporary until the guy has accepted
    $_->{toFormatTmp} = $_->{toFormat} || $_->{toFormatUnsure} foreach @l;

    $o->ask_from_(
        { messages => N("Choose the partitions you want to format"),
	  interactive_help_id => 'formatPartitions',
          advanced_messages => N("Check bad blocks?"),
        },
        [ map { 
	    my $e = $_;
	    ({
	      text => partition_table::description($e), type => 'bool',
	      val => \$e->{toFormatTmp}
	     }, if_(!isLoopback($_) && !isThisFs("reiserfs", $_) && !isThisFs("xfs", $_) && !isThisFs("jfs", $_), {
	      text => partition_table::description($e), type => 'bool', advanced => 1, 
	      disabled => sub { !$e->{toFormatTmp} },
	      val => \$e->{toFormatCheck}
        })) } @l ]
    ) or die 'already displayed';
    #- ok now we can really set toFormat
    foreach (@l) {
	$_->{toFormat} = delete $_->{toFormatTmp};
	$_->{isFormatted} = 0;
    }
}


sub formatMountPartitions {
    my ($o, $_fstab) = @_;
    my $w;
    catch_cdie {
        fs::formatMount_all($o->{all_hds}{raids}, $o->{fstab}, $o->{prefix}, sub {
        	my ($msg) = @_;
        	$w ||= $o->wait_message('', $msg);
        	$w->set($msg);
        });
    } sub { 
	$@ =~ /fsck failed on (\S+)/ or return;
	$o->ask_yesorno('', N("Failed to check filesystem %s. Do you want to repair the errors? (beware, you can loose data)", $1), 1);
    };
    undef $w; #- help perl (otherwise wait_message stays forever in newt)
    die \N("Not enough swap space to fulfill installation, please add some") if availableMemory() < 40 * 1024;
}

#------------------------------------------------------------------------------
sub setPackages {
    my ($o, $rebuild_needed) = @_;

    my $w = $o->wait_message('', $rebuild_needed ? N("Looking for available packages and rebuilding rpm database...") :
			     N("Looking for available packages..."));
    install_any::setPackages($o, $rebuild_needed);

    $w->set(N("Looking at packages already installed..."));
    pkgs::selectPackagesAlreadyInstalled($o->{packages}, $o->{prefix});

    if ($rebuild_needed) {
	$w->set(N("Finding packages to upgrade..."));
	pkgs::selectPackagesToUpgrade($o->{packages}, $o->{prefix});
    }
}
#------------------------------------------------------------------------------
sub choosePackages {
    my ($o, $packages, $compssUsers, $_first_time) = @_;

    #- this is done at the very beginning to take into account
    #- selection of CD by user if using a cdrom.
    $o->chooseCD($packages) if $o->{method} eq 'cdrom' && !$::oem;

    my $w = $o->wait_message('', N("Looking for available packages..."));
    my $availableC = &install_steps::choosePackages;
    my $individual;

    require pkgs;

    my $min_size = pkgs::selectedSize($packages);
    unless ($min_size < $availableC) {
	$w = undef;
	$o->ask_warn('', N("Your system does not have enough space left for installation or upgrade (%d > %d)",
			   $min_size, $availableC));
	install_steps::rebootNeeded($o);
    }

    my $min_mark = 4;

    my $b = pkgs::saveSelected($packages);
    my $_level = pkgs::setSelectedFromCompssList($packages, { map { $_ => 1 } map { @{$compssUsers->{$_}{flags}} } @{$o->{compssUsersSorted}} }, $min_mark, 0);
    my $max_size = pkgs::selectedSize($packages) + 1; #- avoid division by zero.
    log::l("max size (level $min_mark) is : " . formatXiB($max_size));
    pkgs::restoreSelected($b);
    $w = undef;

  chooseGroups:
    $o->chooseGroups($packages, $compssUsers, $min_mark, \$individual, $max_size) if !$o->{isUpgrade} && !$::corporate;

    ($o->{packages_}{ind}) =
      pkgs::setSelectedFromCompssList($packages, $o->{compssUsersChoice}, $min_mark, $availableC);

    $o->choosePackagesTree($packages) or goto chooseGroups if $individual;

    install_any::warnAboutRemovedPackages($o, $o->{packages});
    install_any::warnAboutNaughtyServers($o) or goto chooseGroups;
}

sub choosePackagesTree {
    my ($o, $packages, $limit_to_medium) = @_;

    $o->ask_many_from_list('', N("Choose the packages you want to install"),
			   {
			    list => [ grep { !$limit_to_medium || pkgs::packageMedium($packages, $_) == $limit_to_medium }
				      @{$packages->{depslist}} ],
			    value => \&URPM::Package::flag_selected,
			    label => \&URPM::Package::name,
			    sort => 1,
			   });
}
sub loadSavePackagesOnFloppy {
    my ($o, $packages) = @_;
    $o->ask_from('', 
N("Please choose load or save package selection on floppy.
The format is the same as auto_install generated floppies."),
		 [ { val => \ (my $choice), list => [ N_("Load from floppy"), N_("Save on floppy") ], format => \&translate, type => 'list' } ]) or return;

    if ($choice eq 'Load from floppy') {
	while (1) {
	    my $w = $o->wait_message(N("Package selection"), N("Loading from floppy"));
	    log::l("load package selection from floppy");
	    my $O = eval { install_any::loadO(undef, 'floppy') };
	    if ($@) {
		$w = undef;	#- close wait message.
		$o->ask_okcancel('', N("Insert a floppy containing package selection"))
		  or return;
	    } else {
		install_any::unselectMostPackages($o);
		foreach (@{$O->{default_packages} || []}) {
		    my $pkg = pkgs::packageByName($packages, $_);
		    pkgs::selectPackage($packages, $pkg) if $pkg;
		}
		return 1;
	    }
	}
    } else {
	log::l("save package selection to floppy");
	install_any::g_default_packages($o, 'quiet');
    }
}
sub chooseGroups {
    my ($o, $packages, $compssUsers, $min_level, $individual, $max_size) = @_;

    #- for all groups available, determine package which belongs to each one.
    #- this will enable getting the size of each groups more quickly due to
    #- limitation of current implementation.
    #- use an empty state for each one (no flag update should be propagated).
    
#- OLD VERSION
    my $b = pkgs::saveSelected($packages);
    install_any::unselectMostPackages($o);
    pkgs::setSelectedFromCompssList($packages, {}, $min_level, $max_size);
    my $system_size = pkgs::selectedSize($packages);
    my ($sizes, $pkgs) = pkgs::computeGroupSize($packages, $min_level);
    pkgs::restoreSelected($b);
    log::l("system_size: $system_size");

    my @groups = @{$o->{compssUsersSorted}};
    my %stable_flags = grep_each { $::b } %{$o->{compssUsersChoice}};
    delete $stable_flags{$_} foreach map { @{$compssUsers->{$_}{flags}} } @groups;

    my $compute_size = sub {
	my %pkgs;
	my %flags = %stable_flags; @flags{@_} = ();
	my $total_size;
	A: while (my ($k, $size) = each %$sizes) {
	    Or: foreach (split "\t", $k) {
		  foreach (split "&&") {
		      exists $flags{$_} or next Or;
		  }
		  $total_size += $size;
		  $pkgs{$_} = 1 foreach @{$pkgs->{$k}};
		  next A;
	      }
	  }
	log::l("computed size $total_size");
	log::l("chooseGroups: ", join(" ", sort keys %pkgs));

	int $total_size;
    };
    my %val = map {
	$_ => every { $o->{compssUsersChoice}{$_} } @{$compssUsers->{$_}{flags}}
    } @groups;

#    @groups = grep { $size{$_} = round_down($size{$_} / sqr(1024), 10) } @groups; #- don't display the empty or small one (eg: because all packages are below $min_level)
    my ($size, $unselect_all);
    my $available_size = install_any::getAvailableSpace($o) / sqr(1024);
    my $size_to_display = sub { 
	my $lsize = $system_size + $compute_size->(map { @{$compssUsers->{$_}{flags}} } grep { $val{$_} } @groups);

	#- if a profile is deselected, deselect everything (easier than deselecting the profile packages)
	$unselect_all ||= $size > $lsize;
	$size = $lsize;
	N("Total size: %d / %d MB", pkgs::correctSize($size / sqr(1024)), $available_size);
    };

    while (1) {
	if ($available_size < 140) {
	    # too small to choose anything. Defaulting to no group chosen
	    $val{$_} = 0 foreach %val;
	    last;
	}

	$o->reallyChooseGroups($size_to_display, $individual, \%val) or return;
	last if $::testing || pkgs::correctSize($size / sqr(1024)) < $available_size;
       
	$o->ask_warn('', N("Selected size is larger than available space"));	
    }

    $o->{compssUsersChoice}{$_} = 0 foreach map { @{$compssUsers->{$_}{flags}} } grep { !$val{$_} } keys %val;