]> git.proxmox.com Git - pve-installer.git/commitdiff
add dialog to edit options
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 9 Oct 2014 10:14:28 +0000 (12:14 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 9 Oct 2014 10:15:40 +0000 (12:15 +0200)
Makefile
changelog.Debian
proxinstall

index 636e1d9acb4a7a2c630ce1a510ed5a09c0782273..fdebfe93d20a379c7f2cad2f56bdc26b084bd3aa 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -61,7 +61,7 @@ packages: /pve/${RELEASE}/install/pve.files
        mv packages.tmp packages
 
 test.img:
-       dd if=/dev/zero of=test.img bs=1024 count=1000000
+       dd if=/dev/zero of=test.img bs=1024 count=1M
 
 check: packages test.img
        G_SLICE=always-malloc ./proxinstall -t test.img
index cb78f0d2912080be818ee33e3ea54c086320ae43..69e77cd9676219023d133f8bbe0dd7ce053f8d42 100644 (file)
@@ -1,6 +1,8 @@
 pve-installer (3.3-2) unstable; urgency=low
   
   * support UEFI systems
+  
+  * add new 'Options' Dialog
 
   * do not install xorg.conf (not needed, and makes problems with EFI boot)
 
index 17d0fc237dfdc5e7e4b421959fa729bf0441d854..69e3475510523efa44de30a9dc884f91ccb72720 100755 (executable)
@@ -58,7 +58,31 @@ my $mailto;
 my $keymap = 'en-us';
 my $cmap;
 
-my $filesys = ($cmdline =~ m/\sext4(\s.*)$/) ? 'ext4' : 'ext3';
+# parse command line args
+
+my $config_options = {};
+
+$config_options->{filesys} = ($cmdline =~ m/\sext4(\s.*)$/) ? 'ext4' : 'ext3';
+
+if ($cmdline =~ m/hdsize=(\d+(\.\d+)?)[\s\n]/i) {
+    $config_options->{hdsize} = $1;
+}
+
+if ($cmdline =~ m/swapsize=(\d+(\.\d+)?)[\s\n]/i) {
+    $config_options->{swapsize} = $1;
+}
+
+if ($cmdline =~ m/maxroot=(\d+(\.\d+)?)[\s\n]/i) {
+    $config_options->{maxroot} = $1;
+}
+
+if ($cmdline =~ m/minfree=(\d+(\.\d+)?)[\s\n]/i) {
+    $config_options->{minfree} = $1;
+}
+if ($cmdline =~ m/maxvz=(\d+(\.\d+)?)[\s\n]/i) {
+    $config_options->{maxvz} = $1;
+}
 
 my $postfix_main_cf = <<_EOD;
 # See /usr/share/postfix/main.cf.dist for a commented, more complete version
@@ -589,6 +613,8 @@ sub extract_data {
     my $datadev;
     my $swapfile;
 
+    my $filesys = $config_options->{filesys};
+
     eval {
 
        my $maxper = 0.25;
@@ -599,9 +625,9 @@ sub extract_data {
            syscmd ("dd if=/dev/zero of=${target_hd} bs=512 count=256");
            my $hdsize = hd_size ($target_hd); # size in blocks (1024 bytes)
 
-           if ($cmdline =~ m/hdsize=(\d+)[\s\n]/i) {
+           if ($config_options->{hdsize}) {
                # max hdsize passed on cmdline (GB)
-               my $maxhdsize=$1*1024*1024;
+               my $maxhdsize= $config_options->{hdsize}*1024*1024;
 
                # use $maxhdsize if specified size is lower than hdsize
                if ($maxhdsize < $hdsize) {
@@ -675,8 +701,8 @@ sub extract_data {
            die "hardisk too small (${hdgb}GB)" if $hdgb < 4;
 
            my $swapsize;
-           if ($cmdline =~ m/swapsize=(\d+)[\s\n]/i) {
-               $swapsize=$1*1024*1024;
+           if ($config_options->{swapsize}) {
+               $swapsize = $config_options->{swapsize}*1024*1024;
            } else {
                my $ss = int ($total_memory / 1024);
                $ss = 4 if $ss < 4;
@@ -687,8 +713,8 @@ sub extract_data {
            my $space = (($hdgb > 128) ? 16 : ($hdgb/8))*1024*1024;
 
            my $maxroot;
-           if ($cmdline =~ m/maxroot=(\d+)[\s\n]/i) {
-               $maxroot = $1;
+           if ($config_options->{maxroot}) {
+               $maxroot = $config_options->{maxroot};
            } else {
                $maxroot = 96;
            }
@@ -701,16 +727,18 @@ sub extract_data {
            my $rest = int($hdsize) - $bootsize - $swapsize - $rootsize; # in KB
 
            my $minfree;
-            if ($cmdline =~ m/minfree=(\d+)[\s\n]/i) {
-               $minfree = (($1*1024*1024) >= $rest ) ? $space : $1*1024*1024 ;
+            if ($config_options->{minfree}) {
+               $minfree = (($config_options->{minfree}*1024*1024) >= $rest ) ? $space : 
+                   $config_options->{minfree}*1024*1024 ;
             } else {
                $minfree = $space;
             }
 
            $rest = $rest - $minfree;
 
-            if ($cmdline =~ m/maxvz=(\d+)[\s\n]/i) {
-               $rest = (($1*1024*1024) <= $rest) ? $1*1024*1024 : $rest;
+            if ($config_options->{maxvz}) {
+               $rest = (($config_options->{maxvz}*1024*1024) <= $rest) ? 
+                   $config_options->{maxvz}*1024*1024 : $rest;
            }
 
            syscmd ("/sbin/lvcreate -L${swapsize}K -nswap pve") == 0 ||
@@ -1091,27 +1119,6 @@ sub display_html {
     $htmlview->load_html_string($data, $url);
 }
 
-sub display_html_old {
-    my ($filename) = @_;
-
-    $htmlview->set_document(undef);
-
-    my $document;
-
-    $document->clear;
-    $htmlview->set_document($document);
-
-    $document->open_stream ("text/html");
-
-    my $fn = "${proxmox_dir}/html/$filename";
-    open (HTML, $fn) ||
-       die "unable to open file '$fn' - $!\n";
-    while (<HTML>) { $document->write_stream ($_); }
-    close (HTML);
-
-    $document->close_stream;
-}
-
 sub set_next {
     my ($text, $fctn) = @_;
 
@@ -1211,6 +1218,32 @@ sub cleanup_view {
     }
 }
 
+# fixme: newer GTK3 has special properties to handle numbers with Entry
+# only allow floating point numbers with Gtk3::Entry
+sub check_float {
+    my ($entry, $event) = @_;
+
+
+    my $val = $event->get_keyval;
+
+    if ($val == ord '.' ||
+       $val == Gtk3::Gdk::KEY_ISO_Left_Tab ||
+       $val == Gtk3::Gdk::KEY_Shift_L ||
+       $val == Gtk3::Gdk::KEY_Tab ||
+       $val == Gtk3::Gdk::KEY_Left ||
+       $val == Gtk3::Gdk::KEY_Right ||
+       $val == Gtk3::Gdk::KEY_BackSpace ||
+       $val == Gtk3::Gdk::KEY_Delete ||
+       ($val >= ord '0' && $val <= ord '9') ||
+       ($val >= Gtk3::Gdk::KEY_KP_0 &&
+        $val <= Gtk3::Gdk::KEY_KP_9)) {
+       return undef;
+    }
+
+    return 1;
+}
+
+# used by the IP input entry
 sub check_num {
     my ($entry, $event) = @_;
 
@@ -1747,6 +1780,157 @@ sub create_country_view {
     $w->grab_focus();
 }
 
+sub create_hdoption_view {
+
+    my $dialog = Gtk3::Dialog->new();
+
+    $dialog->set_title("Harddisk options");
+
+    $dialog->add_button("_OK", 1);
+
+    my $contarea = $dialog->get_content_area();
+
+    my $hbox2 =  Gtk3::Box->new('horizontal', 0);
+    $contarea->pack_start($hbox2, 1, 1, 10);
+
+    my $grid =  Gtk3::Grid->new();
+    $grid->set_column_spacing(10);
+    $grid->set_row_spacing(10);
+
+    $hbox2->pack_start($grid, 1, 0, 10);
+    # Filesystem type
+
+    my $label0 = Gtk3::Label->new ("Filesystem");
+    $label0->set_alignment (1, 0.5);
+    $grid->attach($label0, 0, 0, 1, 1);
+
+    my $fstypecb = Gtk3::ComboBoxText->new_with_entry ();
+
+    $fstypecb->append_text ('ext3');
+    $fstypecb->append_text ('ext4');
+
+    if ($config_options->{filesys} eq 'ext4') {
+       $fstypecb->set_active (1);
+    } else {
+       $fstypecb->set_active (0);
+    }
+
+    $fstypecb->signal_connect (changed => sub {
+       $config_options->{filesys} = $fstypecb->get_active_text();
+    });
+    $grid->attach($fstypecb, 1, 0, 1, 1);
+
+    my $label_hdsize = Gtk3::Label->new ("hdsize");
+    $label_hdsize->set_alignment (1, 0.5);
+    $grid->attach($label_hdsize, 0, 1, 1, 1);
+
+    # size compute 
+    my $hdsize;
+    if ( -b $target_hd) {
+       $hdsize = int(hd_size ($target_hd) / (1024*1024.0)); # size in GB
+    } else {
+       $hdsize = int((-s $target_hd) / (1024*1024*1024.0));
+    }
+
+    my $hdsize_size_adj = Gtk3::Adjustment->new($config_options->{hdsize} || $hdsize, 0, $hdsize+1, 1, 1, 1);
+    my $spinbutton_hdsize = Gtk3::SpinButton->new($hdsize_size_adj, 1, 1);
+    $spinbutton_hdsize->set_tooltip_text("only use specified size (GB) of the harddisk (rest left unpartitioned)");
+    $grid->attach($spinbutton_hdsize, 1, 1, 1, 1);
+
+    my $label_swapsize = Gtk3::Label->new ("swapsize");
+    $label_swapsize->set_alignment (1, 0.5);
+    $grid->attach($label_swapsize, 0, 2, 1, 1);
+
+    my $entry_swapsize = Gtk3::Entry->new();
+    $entry_swapsize->set_tooltip_text("maximum SWAP size (GB)");
+    $entry_swapsize->signal_connect (key_press_event => \&check_float);
+    $entry_swapsize->set_text($config_options->{swapsize}) if $config_options->{swapsize};
+    $grid->attach($entry_swapsize, 1, 2, 1, 1);
+
+    my $label_maxroot = Gtk3::Label->new ("maxroot");
+    $label_maxroot->set_alignment (1, 0.5);
+    $grid->attach($label_maxroot, 0, 3, 1, 1);
+
+    my $entry_maxroot = Gtk3::Entry->new();
+    $entry_maxroot->set_tooltip_text("maximum size (GB) for LVM root volume");
+    $entry_maxroot->signal_connect (key_press_event => \&check_float);
+    $entry_maxroot->set_text($config_options->{maxroot}) if $config_options->{maxroot};
+    $grid->attach($entry_maxroot, 1, 3, 1, 1);
+
+    my $label_minfree = Gtk3::Label->new ("minfree");
+    $label_minfree->set_alignment (1, 0.5);
+    $grid->attach($label_minfree, 0, 4, 1, 1);
+
+    my $entry_minfree = Gtk3::Entry->new();
+    $entry_minfree->set_tooltip_text("minumum free LVM space (GB, required for LVM snapshots)");
+    $entry_minfree->signal_connect (key_press_event => \&check_float);
+    $entry_minfree->set_text($config_options->{minfree}) if $config_options->{minfree};
+    $grid->attach($entry_minfree, 1, 4, 1, 1);
+
+    my $label_maxvz = Gtk3::Label->new ("maxvz");
+    $label_maxvz->set_alignment (1, 0.5);
+    $grid->attach($label_maxvz, 0, 5, 1, 1);
+
+    my $entry_maxvz = Gtk3::Entry->new();
+    $entry_maxvz->set_tooltip_text("maximum size (GB) for LVM data volume");
+    $entry_maxvz->signal_connect (key_press_event => \&check_float);
+    $entry_maxvz->set_text($config_options->{maxvz}) if $config_options->{maxvz};
+    $grid->attach($entry_maxvz, 1, 5, 1, 1);
+
+    $dialog->show_all;
+
+    $dialog->run();
+
+    my $get_float = sub {
+       my ($entry) = @_;
+
+       my $text = $entry->get_text();
+       return undef if !defined($text);
+
+       $text =~ s/^\s+//;
+       $text =~ s/\s+$//;
+
+       return undef if $text !~ m/^\d+(\.\d+)?$/;
+
+       return $text;
+    };
+
+    my $tmp;
+
+    if (($tmp = &$get_float($spinbutton_hdsize)) && ($tmp != $hdsize)) {
+       $config_options->{hdsize} = $tmp;
+    } else {
+       delete $config_options->{hdsize};
+    }
+
+    if (defined($tmp = &$get_float($entry_swapsize))) {
+       $config_options->{swapsize} = $tmp;
+    } else {
+       delete $config_options->{swapsize};
+    }
+
+    if (defined($tmp = &$get_float($entry_maxroot))) {
+       $config_options->{maxroot} = $tmp;
+    } else {
+       delete $config_options->{maxroot};
+    }
+
+    if (defined($tmp = &$get_float($entry_minfree))) {
+       $config_options->{minfree} = $tmp;
+    } else {
+       delete $config_options->{minfree};
+    }
+
+    if (defined($tmp = &$get_float($entry_maxvz))) {
+       $config_options->{maxvz} = $tmp;
+    } else {
+       delete $config_options->{maxvz};
+    }
+
+    $dialog->destroy();
+}
+
 sub create_hdsel_view {
 
     cleanup_view ();
@@ -1781,7 +1965,12 @@ sub create_hdsel_view {
        $master_hd = find_master ($target_hd);
     });
 
-    $hbox->pack_start ($combo, 0, 0, 0);
+    $hbox->pack_start ($combo, 0, 0, 10);
+
+    my $options = Gtk3::Button->new ('_Options');
+    $options->signal_connect (clicked => \&create_hdoption_view);
+    $hbox->pack_start ($options, 0, 0, 0);
+
 
     $inbox->show_all;