diff options
-rw-r--r-- | drakpxelinux.pl | 178 |
1 files changed, 87 insertions, 91 deletions
diff --git a/drakpxelinux.pl b/drakpxelinux.pl index a42447b..85af02c 100644 --- a/drakpxelinux.pl +++ b/drakpxelinux.pl @@ -71,7 +71,7 @@ N("Network: DHCP or an IP address") . "\n" . N("Directory: full path to MDK install server directory") . "\n" . N("Method: installation method: choose NFS or HTTP") . "\n" . N("Ramsize: ramsize parameter on boot disk") . "\n" . -N("Display: export display on another computer (ie: 10.0.1.33:0)") . "\n" . +N("Display: export display to another computer (ie: 10.0.1.33:0)") . "\n" . N("VGA: if you encounter any problem with VGA, please adjust") . "\n" . ""; @@ -103,15 +103,15 @@ sub set_help_tip { } if (!-f $conf) { - err_dialog(N("Error!"), N("missing %s\n\nPlease install pxe package.",$conf)) and die if !$::testing; + err_dialog(N("Error!"), N("missing %s\n\nPlease install pxe package.",$conf)) and !$::testing && die; } else { save_config($conf); } my @listpxe; my @list_method = qw(nfs http); push @list_method, ""; -my @list_ram = qw(32000 48000 64000 96000 1280000); push @list_ram, ""; -my @list_vga = qw(normal 785 788 791 794 text); push @list_vga, ""; +my @list_ram = qw(32000 48000 64000 96000 128000); +my @list_vga = qw(automatic normal 785 788 791 794 text); my @list_eth = qw(eth0 eth1 eth2); push @list_eth, ""; use constant COLUMN_LABEL => 0; @@ -131,7 +131,7 @@ use constant NUM_COLUMNS => 13; # get all values from default PXE file sub get_items() { - my ($label, $kernel); + my $info; my $label; my $kernel; my $initrd; foreach (cat_($conf)) { if (any { /^label/ } cat_($conf)) { if (/^label/) { ($label) = /^label\s(.*)/ } @@ -210,7 +210,7 @@ sub set_new_default { } $conf; } -sub get_default_pxe() { +sub get_default_pxe { my ($defaultpxe) = cat_($conf) =~ /DEFAULT\s+(\S+)/; return $defaultpxe; } @@ -227,10 +227,10 @@ sub get_default_timeout() { } # write conf in default file -sub write_conf_pxe() { - my $default = get_default_pxe(); - my $_prompt = get_default_prompt(); - my $_time = get_default_timeout(); +sub write_conf_pxe { + my $default = get_default_pxe; + my $prompt = get_default_prompt; + my $time = get_default_timeout; output($conf, <<EOF); # DO NOT EDIT auto_generated by drakpxelinux.pl PROMPT 10 @@ -267,9 +267,9 @@ label $a->{label} } } -sub create_model() { +sub create_model { get_items(); - my $model = Gtk2::ListStore->new(("Glib::String") x 13); + my $model = Gtk2::ListStore->new(("Glib::String") x13); foreach my $a (@listpxe) { my $iter = $model->append; $model->set($iter, @@ -293,7 +293,7 @@ sub create_model() { # wizard to add an entry in PXE menu sub wizard_add_entry { - my ($_widget, $treeview) = @_; + my ($widget, $treeview) = @_; my $model = $treeview->get_model; local $::isEmbedded = 0; @@ -354,9 +354,9 @@ sub wizard_add_entry { server => "", directory => "", ramdisk => "128000", - vga => "", + vga => "automatic", display => "", - option => "", + option => "root=/dev/ram3 rw", }; my $iter = $model->append; $model->set($iter, @@ -396,7 +396,7 @@ sub wizard_add_entry { # remove an entry in PXE menu sub remove_item { - my ($_widget, $treeview) = @_; + my ($widget, $treeview) = @_; $::isWizard = 0; my $model = $treeview->get_model; my $selection = $treeview->get_selection; @@ -419,12 +419,12 @@ sub remove_item { } $model->remove($iter); splice @listpxe, $i, 1; - write_conf_pxe(); + write_conf_pxe; } } sub test_similar_label { - my ($newlabel, $_oldlabel) = @_; + my ($newlabel, $oldlabel) = @_; # if ($newlabel eq $oldlabel) { # err_dialog(N("hmm.."), N("You should provide a new label name.")) and return 0; # } els @@ -435,7 +435,7 @@ sub test_similar_label { # dialog box to edit a PXE entry sub edit_box_item { - my ($_widget, $treeview) = @_; + my ($widget, $treeview) = @_; $::isWizard = 0; my $model = $treeview->get_model; my $selection = $treeview->get_selection; @@ -460,21 +460,30 @@ sub edit_box_item { # create file dialog widget, with file or directory selection my $fdwidget = sub { - my ($data, $test) = @_; + my ($data, $test, $filetotest) = @_; + chdir($X86); my $fd = new Gtk2::FileSelection(N("Selection")); $fd->set_modal(TRUE); $fd->signal_connect("destroy", sub { $fd->hide }); $fd->ok_button->signal_connect(clicked => sub { - my $file = $fd->get_filename; - if ($test eq "dir") { - -d $file or err_dialog(N("Error!"), N("Should be a directory.")) and return; - } else { - -f $file or err_dialog(N("Error!"), N("Should be a file")) and return; - $file = "images/" . basename($file); - } - $data->set_text($file); - $fd->hide; - }, $fd); + my $file = $fd->get_filename; + if ($test eq "dir") { + -d $file or err_dialog(N("Error!"), N("Should be a directory.")) and return; + } else { + -f $file or err_dialog(N("Error!"), N("Should be a file")) and return; + } + if ($filetotest eq "kernel") { + run_program::get_stdout("file $file") =~ /boot sector/ or err_dialog(N("Error!"), N("Should be a boot sector file")) and return; + } elsif ($filetotest eq "initrd") { + run_program::get_stdout("file $file") =~ /initrd/ or err_dialog(N("Error!"), N("Should be an initrd file")) and return; + } + my $d = dirname($file); + my $filesel = basename($file); + if ($d =~ /images/) { print "here"; $filesel = "images/" . $filesel; } + print "$filesel\n"; + $data->set_text($filesel); + $fd->hide; + }, $fd); $fd->cancel_button->signal_connect(clicked => sub { $fd->hide }); return $fd; }; @@ -484,17 +493,17 @@ sub edit_box_item { $kernel->set_text($listpxe[$i]{kernel}); set_help_tip($kernel, 'kernel'); - my $file_dialogk = $fdwidget->($kernel, ""); + my $file_dialogk = $fdwidget->($kernel, "", "kernel"); # button kernel - my $buttonkernel = Gtk2::Button->new(N("Select kernel")); + my $buttonkernel = Gtk2::Button->new(N("Select kernel to boot")); $buttonkernel->signal_connect(clicked => sub { $file_dialogk->show }); my $initrd = Gtk2::Entry->new; $initrd->set_text($listpxe[$i]{initrd}); set_help_tip($initrd, 'initrd'); - my $file_dialog = $fdwidget->($initrd, ""); - my $buttoninitrd = Gtk2::Button->new(N("Select initrd")); + my $file_dialog = $fdwidget->($initrd, "", "initrd"); + my $buttoninitrd = Gtk2::Button->new(N("Select associated initrd")); $buttoninitrd->signal_connect(clicked => sub { $file_dialog->show }); # combo box to pop down automatic installation @@ -528,11 +537,13 @@ sub edit_box_item { my $ramdisk = new Gtk2::OptionMenu(); $ramdisk->set_popdown_strings(@list_ram); + if ($listpxe[$i]{ramdisk} eq "") { $listpxe[$i]{ramdisk} = "128000" } $ramdisk->entry->set_text($listpxe[$i]{ramdisk}); set_help_tip($ramdisk, 'ramsize'); my $vga = new Gtk2::OptionMenu(); $vga->set_popdown_strings(@list_vga); + if ($listpxe[$i]{vga} eq "automatic") { $listpxe[$i]{vga} = "" } $vga->entry->set_text($listpxe[$i]{vga}); set_help_tip($vga, 'vga'); @@ -541,6 +552,7 @@ sub edit_box_item { set_help_tip($display, 'display'); my $option = Gtk2::Entry->new; + if ($listpxe[$i]{option} eq "") { $listpxe[$i]{option} = "root=/dev/ram3 rw" } $option->set_text($listpxe[$i]{option}); set_help_tip($option, 'option'); @@ -556,38 +568,30 @@ sub edit_box_item { # ok, lets create the dialog box :-) gtkpack_($dialog->vbox, - 0, gtkadd(Gtk2::Frame->new(N("Descrition")), + 0, gtkadd(Gtk2::Frame->new(N("PXE entry")), gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3), 0, $label_and_widgets->(N("Label"), $label, ""), - 0, $label_and_widgets->(N("Info"), $info, ""), + 0, $label_and_widgets->(N("Entry description"), $info, ""), + 0, Gtk2::VSeparator->new(), + 0, $label_and_widgets->(N("Kernel image"), $kernel, $buttonkernel), + 0, $label_and_widgets->(N("Initrd image"), $initrd, $buttoninitrd), ), ), - 0, gtkadd(Gtk2::Frame->new(N("Boot image")), + 0, gtkadd(Gtk2::Frame->new(N("Mandrakelinux installer options")), gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3), - 0, Gtk2::Label->new(N("Path are relative to %s, file out of this directory\ncould not be downloaded via tftp, because tftp server is chrooted", $X86)), - 0, $label_and_widgets->(N("Kernel"), $kernel, $buttonkernel), - 0, $label_and_widgets->(N("Initrd"), $initrd, $buttoninitrd), + 0, $label_and_widgets->(N("Ramdisk size"), $ramdisk, ""), + 0, $label_and_widgets->(N("Custom Option"), $option, ""), + 0, $label_and_widgets->(N("Frame Buffer resolution"), $vga, ""), + 0, $label_and_widgets->(N("Remote IP of X server"), $display, ""), ), ), 0, gtkadd(Gtk2::Frame->new(N("Automatic Options")), gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3), - 0, $label_and_widgets->(N("Automatic"), $automatic, ""), - 0, $label_and_widgets->(N("Interface"), $interface, ""), - 0, $label_and_widgets->(N("Network"), $network, ""), - 0, $label_and_widgets->(N("Server"), $server, ""), - 0, $label_and_widgets->(N("Directory"), $directory, $buttondir), - ), - ), - 0, gtkadd(Gtk2::Frame->new(N("Display")), - gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3), - 0, $label_and_widgets->(N("Vga"), $vga, ""), - 0, $label_and_widgets->(N("Display"), $display, ""), - ), - ), - 0, gtkadd(Gtk2::Frame->new(N("Other options")), - gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3), - 0, $label_and_widgets->(N("Ramdisk"), $ramdisk, ""), - 0, $label_and_widgets->(N("Option"), $option, ""), + 0, $label_and_widgets->(N("Installation method"), $automatic, ""), + 0, $label_and_widgets->(N("Network Interface"), $interface, ""), + 0, $label_and_widgets->(N("IP address"), $network, ""), + 0, $label_and_widgets->(N("Remote Server name"), $server, ""), + 0, $label_and_widgets->(N("Remote installation Directory"), $directory, ""), ), ), 0, create_okcancel({ @@ -625,7 +629,7 @@ sub edit_box_item { COLUMN_OPTION, $listpxe[$i]{option}, ); $dialog->destroy; - write_conf_pxe(); + write_conf_pxe; add_in_help($listpxe[$i]{label}, $listpxe[$i]{info}); }, }, @@ -701,7 +705,7 @@ sub cell_edited { } } elsif ($column == COLUMN_AUTOMATIC) { my $i = ($path->get_indices)[0]; - if (!member($new_text, @list_method) || $listpxe[$i]{kernel} =~ /memdisk/) { + if (!member($new_text, @list_method) || ($listpxe[$i]{kernel} =~ /memdisk/)) { return; } else { $listpxe[$i]{automatic} = $new_text; @@ -709,49 +713,42 @@ sub cell_edited { } } elsif ($column == COLUMN_INTERFACE) { my $i = ($path->get_indices)[0]; - # FIXME: regexp on $_ which has random value here (do you means $var !~ // instead): - if (member($new_text, @list_eth) || $listpxe[$i]{kernel} != /memdisk/) { + if (member($new_text, @list_eth) || ($listpxe[$i]{kernel} != /memdisk/)) { $listpxe[$i]{interface} = $new_text; $model->set($iter, $column, $listpxe[$i]{interface}); } } elsif ($column == COLUMN_NETWORK) { my $i = ($path->get_indices)[0]; - # FIXME: regexp on $_ which has random value here (do you means $var !~ // instead): if ($listpxe[$i]{kernel} != /memdisk/) { $listpxe[$i]{network} = $new_text; $model->set($iter, $column, $listpxe[$i]{network}); } } elsif ($column == COLUMN_SERVER) { my $i = ($path->get_indices)[0]; - # FIXME: regexp on $_ which has random value here (do you means $var !~ // instead): if ($listpxe[$i]{kernel} != /memdisk/) { $listpxe[$i]{server} = $new_text; $model->set($iter, $column, $listpxe[$i]{server}); } } elsif ($column == COLUMN_DIRECTORY) { my $i = ($path->get_indices)[0]; - # FIXME: regexp on $_ which has random value here (do you means $var !~ // instead): - if (-d $new_text || $listpxe[$i]{kernel} != /memdisk/) { + if (-d $new_text || ($listpxe[$i]{kernel} != /memdisk/)) { $listpxe[$i]{directory} = $new_text; $model->set($iter, $column, $listpxe[$i]{directory}); } } elsif ($column == COLUMN_RAMDISK) { my $i = ($path->get_indices)[0]; - # FIXME: regexp on $_ which has random value here (do you means $var !~ // instead): - if (member($new_text, @list_ram) || $listpxe[$i]{kernel} != /memdisk/) { + if (member($new_text, @list_ram) || ($listpxe[$i]{kernel} != /memdisk/)) { $listpxe[$i]{ramdisk} = $new_text; $model->set($iter, $column, $listpxe[$i]{ramdisk}); } } elsif ($column == COLUMN_VGA) { my $i = ($path->get_indices)[0]; - # FIXME: regexp on $_ which has random value here (do you means $var !~ // instead): - if (member($new_text, @list_vga) || $listpxe[$i]{kernel} != /memdisk/) { + if (member($new_text, @list_vga) || ($listpxe[$i]{kernel} != /memdisk/)) { $listpxe[$i]{vga} = $new_text; $model->set($iter, $column, $listpxe[$i]{vga}); } } elsif ($column == COLUMN_DISPLAY) { my $i = ($path->get_indices)[0]; - # FIXME: regexp on $_ which has random value here (do you means $var !~ // instead): if ($listpxe[$i]{kernel} != /memdisk/) { $listpxe[$i]{display} = $new_text; $model->set($iter, $column, $listpxe[$i]{display}); @@ -761,11 +758,10 @@ sub cell_edited { $listpxe[$i]{option} = $new_text; $model->set($iter, $column, $listpxe[$i]{option}); } - write_conf_pxe(); + write_conf_pxe; } -sub show_help() { - info_dialog("help", +sub show_help { info_dialog("help", gtkpack_(gtkset_border_width(Gtk2::VBox->new, 3), 0, $help, 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("online PXE documentation")), 'helponline'), @@ -777,7 +773,7 @@ sub show_help() { } # adjust pxe confi with good value -sub pxe_conf() { +sub pxe_conf { if (!-f "$pxeconf.orig") { cp_af($pxeconf, "$pxeconf.orig") } substInFile { s/default_address.*/default_address=$IPSERVER/; @@ -786,7 +782,7 @@ sub pxe_conf() { } $pxeconf; } -sub check_pxe_conf() { +sub check_pxe_conf { if (! any { /default_address=$IPSERVER/ } cat_($pxeconf)) { # pxe.conf doesnt matche system, relaunch wizard_pxe_server err_dialog(N("Error !"), N("Your %s doesnt match your actual IP address configuration. Relaunching the PXE wizard server to readjust it.", $pxeconf)) and launch_pxe_server(); @@ -794,7 +790,7 @@ sub check_pxe_conf() { } # launch wizard to setup a PXE server -sub wizard_pxe_server() { +sub wizard_pxe_server { local $::isEmbedded = 0; my $in = 'interactive'->vnew('su'); undef $::WizardTable; @@ -833,8 +829,8 @@ sub wizard_pxe_server() { next => 'endserver', }, endserver => { - name => N("Congratulations"), - data => [ { label => N("The wizard successfully configured your PXE server.") } ], + name => N("End of PXE server configuration"), + data => [ { label => N("The wizard successfully configured your PXE server. Now you can configure the PXE menu entry.") } ], no_back => 1, end => 1, next => 0 @@ -856,7 +852,7 @@ sub save_config { } # set default PXE message -sub default_pxe_messages() { +sub default_pxe_messages { save_config($PXEMESSAGE); output($PXEMESSAGE, <<EOF); @@ -877,7 +873,7 @@ sub default_pxe_messages() { EOF } -sub default_pxe_menu() { +sub default_pxe_menu { save_config($PXEHELP); output($PXEHELP, <<EOF); Available images are: @@ -898,11 +894,11 @@ sub tftp_blksize { } # enable tftp server in xinetd conf -sub enable_tftps() { +sub enable_tftps { substInFile { s/disable.*/disable = no/ } "$XINETDDIR/tftp"; } -sub memlinux_prep() { +sub memlinux_prep { if (!-f "$X86/memdisk") { cp_af($MEMDISK, $X86); } @@ -917,7 +913,7 @@ sub check_started { } # main procedure to setup PXE server -sub do_it_pxe() { +sub do_it_pxe { return if $::testing; my $in = 'interactive'->vnew('su', 'PXE server'); my $w = $in->wait_message(N("PXE server"), N("Configuring PXE server on your system...")); @@ -963,12 +959,12 @@ sub add_columns { # check if first launch if (! -f "$X86/drakwizard_pxe") { - info_dialog(N("Please configure a PXE server"), N("Its seems this is the first time you run this tool.\n") . N("A wizard will apppear to configure your pxe server.")); + info_dialog(N("Please configure a PXE server"), N("Its seems this is the first time you run this tool.\n") . ("A wizard will apppear to configure your pxe server.")); launch_pxe_server(); } check_pxe_conf(); -sub launch_pxe_server() { +sub launch_pxe_server { eval { wizard_pxe_server() }; my $err = $@; $::WizardWindow->destroy if defined $::WizardWindow; @@ -996,14 +992,14 @@ add_columns($treeview); # labels that list pxe menu entry my $labelscombo = Gtk2::OptionMenu->new; #my @labelslist = list_label_pxe; -my $defaultlabel = get_default_pxe(); +my $defaultlabel = get_default_pxe; $labelscombo->entry->set_text($defaultlabel); $labelscombo->entry->signal_connect("changed", sub { my $new_default = $labelscombo->entry->get_text; set_new_default($new_default); } ); -my @o = list_label_pxe(); +my @o = list_label_pxe; $labelscombo->set_popdown_strings("", sort(@o)); $labelscombo->entry->set_text($defaultlabel); set_help_tip($labelscombo, 'labels'); @@ -1030,16 +1026,16 @@ $W->add(gtkpack_(Gtk2::VBox->new(0,0), } }), 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Remove PXE entry")), 'removepxe'), clicked => sub { - remove_item($model, $treeview) } + remove_item($model, $treeview); } ), 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit PXE entry")), 'editb'), clicked => sub { - edit_box_item($model, $treeview) } + edit_box_item($model, $treeview); } ), 0, Gtk2::Label->new(N("boot:")), 0, $labelscombo, - 0, Gtk2::VSeparator->new, + 0, Gtk2::VSeparator->new(), 0, gtksignal_connect(new Gtk2::Button(N("Help")), - clicked => sub { show_help() } + clicked => sub { show_help } ), ), if_($::isEmbedded, 0, $okcancel), |