11 use POSIX
":sys_wait_h";
15 Proxmox
::Log
::init
("/tmp/install.log");
17 { # NOTE: order is important here
20 'test-image|t=s' => \
$test_image
21 ) or die "usage error\n";
23 Proxmox
::Install
::ISOEnv
::set_test_image
($test_image) if $test_image;
26 use Proxmox
::Install
::ISOEnv
;
27 use Proxmox
::Install
::RunEnv
;
29 # init singletons TODO: avoid all global initialization, use single "main" method
30 my $iso_env = Proxmox
::Install
::ISOEnv
::get
();
33 use Proxmox
::Install
::Config
;
35 use Proxmox
::Sys
::Block
qw(get_cached_disks);
36 use Proxmox
::Sys
::Command
qw(syscmd);
37 use Proxmox
::Sys
::File
qw(file_read_all file_write_all);
38 use Proxmox
::Sys
::Net
qw(parse_ip_address parse_ip_mask);
41 if (!$ENV{G_SLICE
} || $ENV{G_SLICE
} ne "always-malloc") {
42 die "do not use slice allocator (run with 'G_SLICE=always-malloc ./proxinstall ...')\n";
45 my $step_number = 0; # Init number for global function list
50 html
=> 'license.htm',
51 next_button
=> 'I a_gree',
52 function
=> \
&create_intro_view
,
57 function
=> \
&create_hdsel_view
,
61 html
=> 'country.htm',
62 function
=> \
&create_country_view
,
67 function
=> \
&create_password_view
,
72 function
=> \
&create_ipconf_view
,
77 next_button
=> '_Install',
78 function
=> \
&create_ack_view
,
82 next_button
=> '_Reboot',
83 function
=> \
&create_extract_view
,
87 # GUI global variables
90 my $target_hds; # only for the summary view
95 Gtk3-
>main_quit() if Gtk3-
>main_level() > 0;
97 # reap left over zombie processes
98 while ((my $child = waitpid(-1, POSIX
::WNOHANG
)) > 0) {
99 print STDERR
"reaped child $child\n";
105 my ($text, $fctn) = @_;
107 $fctn = $step_number if !$fctn;
108 $text = "_Previous" if !$text;
109 $gtk_state->{prev_btn
}->set_label($text);
112 $steps[$step_number]->{function
}();
114 $gtk_state->{prev_btn
}->grab_focus();
118 my ($text, $fctn) = @_;
120 $gtk_state->{next_btn_callback
} = $fctn;
121 my $step = $steps[$step_number];
122 $text //= $steps[$step_number]->{next_button
} // '_Next';
123 $gtk_state->{next_btn
}->set_label($text);
125 $gtk_state->{next_btn
}->grab_focus();
128 sub create_main_window
{
130 my $window = Gtk3
::Window-
>new();
131 $window->set_default_size(1024, 768);
132 $window->signal_connect(map => sub { $window->set_resizable(0); });
133 $window->fullscreen() if !is_test_mode
();
134 $window->set_decorated(0) if !is_test_mode
();
135 $window->signal_connect(destroy
=> sub { Gtk3-
>main_quit(); });
137 my $vbox = Gtk3
::Box-
>new('vertical', 0);
139 my $logofn = "$iso_env->{product}-banner.png";
140 my $proxmox_libdir = $iso_env->{locations
}->{lib
};
141 my $image = Gtk3
::Image-
>new_from_file("${proxmox_libdir}/$logofn");
143 my $provider = Gtk3
::CssProvider-
>new();
144 my $theming = "* {\nbackground: #171717;\n}";
145 $provider->load_from_data ([map ord, split //, $theming]);
146 my $context = $image->get_style_context();
147 $context->add_provider($provider, 600);
149 $vbox->pack_start($image, 0, 0, 0);
151 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
152 $vbox->pack_start($hbox, 1, 1, 0);
154 # my $f1 = Gtk3::Frame->new ('test');
155 # $f1->set_shadow_type ('none');
156 # $hbox->pack_start ($f1, 1, 1, 0);
158 my $sep1 = Gtk3
::Separator-
>new('horizontal');
159 $vbox->pack_start($sep1, 0, 0, 0);
161 my $cmdbox = Gtk3
::Box-
>new('horizontal', 0);
162 $vbox->pack_start($cmdbox, 0, 0, 10);
164 my $next_btn = Gtk3
::Button-
>new('_Next');
165 $next_btn->signal_connect(clicked
=> sub {
166 Proxmox
::Install
::reset_last_display_change
();
167 $gtk_state->{next_btn_callback
}->();
169 $cmdbox->pack_end($next_btn, 0, 0, 10);
171 my $prev_btn = Gtk3
::Button-
>new('_Previous');
172 $prev_btn->signal_connect(clicked
=> sub {
173 Proxmox
::Install
::reset_last_display_change
();
176 $cmdbox->pack_end($prev_btn, 0, 0, 10);
179 my $abort = Gtk3
::Button-
>new('_Abort');
180 $abort->set_can_focus(0);
181 $cmdbox->pack_start($abort, 0, 0, 10);
182 $abort->signal_connect(clicked
=> sub { app_quit
(-1); });
184 my $vbox2 = Gtk3
::Box-
>new('vertical', 0);
187 my $html_view = Gtk3
::WebKit2
::WebView-
>new();
188 $html_view->set_hexpand(1);
189 my $scrolls = Gtk3
::ScrolledWindow-
>new();
190 $scrolls->add($html_view);
192 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
193 $hbox2->pack_start($scrolls, 1, 1, 0);
195 $vbox2->pack_start($hbox2, 1, 1, 0);
197 my $vbox3 = Gtk3
::Box-
>new('vertical', 0);
198 $vbox2->pack_start($vbox3, 0, 0, 0);
200 my $sep2 = Gtk3
::Separator-
>new('horizontal');
201 $vbox3->pack_start($sep2, 0, 0, 0);
203 my $inbox = Gtk3
::Box-
>new('horizontal', 0);
204 $vbox3->pack_start($inbox, 0, 0, 0);
208 $gtk_state->{window
} = $window;
209 $gtk_state->{html_view
} = $html_view;
210 $gtk_state->{inbox
} = $inbox;
211 $gtk_state->{prev_btn
} = $prev_btn;
212 $gtk_state->{next_btn
} = $next_btn;
213 $gtk_state->{progress_bar
} = Gtk3
::ProgressBar-
>new();
214 $gtk_state->{progress_status
} = Gtk3
::Label-
>new('');
216 Proxmox
::UI
::init_gtk
($gtk_state, $iso_env);
223 $gtk_state->{inbox
}->foreach(sub {
225 $gtk_state->{inbox
}->remove ($child);
229 # fixme: newer GTK3 has special properties to handle numbers with Entry
230 # only allow floating point numbers with Gtk3::Entry
233 my ($entry, $event) = @_;
235 return check_number
($entry, $event, 1);
239 my ($entry, $event) = @_;
241 return check_number
($entry, $event, 0);
245 my ($entry, $event, $float) = @_;
247 my $val = $event->get_keyval;
249 if (($float && $val == ord '.') ||
250 $val == Gtk3
::Gdk
::KEY_ISO_Left_Tab
||
251 $val == Gtk3
::Gdk
::KEY_Shift_L
||
252 $val == Gtk3
::Gdk
::KEY_Tab
||
253 $val == Gtk3
::Gdk
::KEY_Left
||
254 $val == Gtk3
::Gdk
::KEY_Right
||
255 $val == Gtk3
::Gdk
::KEY_BackSpace
||
256 $val == Gtk3
::Gdk
::KEY_Delete
||
257 ($val >= ord '0' && $val <= ord '9') ||
258 ($val >= Gtk3
::Gdk
::KEY_KP_0
&&
259 $val <= Gtk3
::Gdk
::KEY_KP_9
)) {
266 sub create_text_input
{
267 my ($default, $text) = @_;
269 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
271 my $label = Gtk3
::Label-
>new($text);
272 $label->set_size_request(150, -1);
273 $label->set_xalign(1.0);
274 $hbox->pack_start($label, 0, 0, 10);
275 my $e1 = Gtk3
::Entry-
>new();
276 $e1->set_width_chars(35);
277 $hbox->pack_start($e1, 0, 0, 0);
278 $e1->set_text($default);
282 sub create_cidr_inputs
{
285 my ($default_ip, $default_mask) = split('/', $cidr);
287 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
289 my $label = Gtk3
::Label-
>new('IP Address (CIDR)');
290 $label->set_size_request(150, -1);
291 $label->set_xalign(1.0);
292 $hbox->pack_start($label, 0, 0, 10);
294 my $ip_el = Gtk3
::Entry-
>new();
295 $ip_el->set_width_chars(28);
296 $hbox->pack_start($ip_el, 0, 0, 0);
297 $ip_el->set_text($default_ip);
299 $label = Gtk3
::Label-
>new('/');
300 $label->set_size_request(10, -1);
301 $hbox->pack_start($label, 0, 0, 2);
303 my $cidr_el = Gtk3
::Entry-
>new();
304 $cidr_el->set_width_chars(3);
305 $hbox->pack_start($cidr_el, 0, 0, 0);
306 $cidr_el->set_text($default_mask);
308 return ($hbox, $ip_el, $cidr_el);
311 my $ipconf_first_view = 1;
313 sub create_ipconf_view
{
316 Proxmox
::UI
::display_html
('ipconf.htm');
318 my $vcontainer = Gtk3
::Box-
>new('vertical', 0);
319 $gtk_state->{inbox
}->pack_start($vcontainer, 1, 0, 0);
320 my $hcontainer = Gtk3
::Box-
>new('horizontal', 0);
321 $vcontainer->pack_start($hcontainer, 0, 0, 10);
322 my $vbox = Gtk3
::Box-
>new('vertical', 0);
323 $hcontainer->add($vbox);
325 my $cidr = Proxmox
::Install
::Config
::get_cidr
() // '192.168.100.2/24';
327 my ($cidr_box, $ipconf_entry_addr, $ipconf_entry_mask) = create_cidr_inputs
($cidr);
329 my $device_cb = Gtk3
::ComboBoxText-
>new();
330 $device_cb->set_active(0);
331 $device_cb->set_visible(1);
333 my $get_device_desc = sub {
335 return "$iface->{name} - $iface->{mac} ($iface->{driver})";
338 my $run_env = Proxmox
::Install
::RunEnv
::get
();
339 my $ipconf = $run_env->{ipconf
};
341 my ($device_active_map, $device_active_reverse_map) = ({}, {});
343 my $device_change_handler = sub {
346 my $new = $device_active_map->{$current->get_active()};
347 my $selected = Proxmox
::Install
::Config
::get_mngmt_nic_id
();
348 return if defined($selected) && $new eq $selected;
350 Proxmox
::Install
::Config
::set_mngmt_nic_id
($new);
351 my $iface = $ipconf->{ifaces
}->{$new};
352 Proxmox
::Install
::Config
::set_mngmt_nic
($iface->{name
});
353 $ipconf_entry_addr->set_text($iface->{inet
}->{addr
} || $iface->{inet6
}->{addr
})
354 if $iface->{inet
}->{addr
} || $iface->{inet6
}->{addr
};
355 $ipconf_entry_mask->set_text($iface->{inet
}->{prefix
} || $iface->{inet6
}->{prefix
})
356 if $iface->{inet
}->{prefix
} || $iface->{inet6
}->{prefix
};
360 for my $index (sort keys $ipconf->{ifaces
}->%*) {
361 my $iface = $ipconf->{ifaces
}->{$index};
362 $device_cb->append_text($get_device_desc->($iface));
363 $device_active_map->{$i} = $index;
364 $device_active_reverse_map->{$iface->{name
}} = $i;
365 if ($ipconf_first_view && $index == $ipconf->{default}) {
366 $device_cb->set_active($i);
367 &$device_change_handler($device_cb);
368 $ipconf_first_view = 0;
370 $device_cb->signal_connect('changed' => $device_change_handler);
374 if (my $nic = Proxmox
::Install
::Config
::get_mngmt_nic
()) {
375 $device_cb->set_active($device_active_reverse_map->{$nic} // 0);
377 $device_cb->set_active(0);
380 my $devicebox = Gtk3
::Box-
>new('horizontal', 0);
381 my $label = Gtk3
::Label-
>new("Management Interface:");
382 $label->set_size_request(150, -1);
383 $label->set_xalign(1.0);
384 $devicebox->pack_start($label, 0, 0, 10);
385 $devicebox->pack_start($device_cb, 0, 0, 0);
387 $vbox->pack_start($devicebox, 0, 0, 2);
389 my $fqdn = Proxmox
::Install
::Config
::get_fqdn
();
390 my $hn = $fqdn // "$iso_env->{product}." . ($ipconf->{domain
} // "example.invalid");
392 my ($hostbox, $hostentry) = create_text_input
($hn, 'Hostname (FQDN):');
393 $vbox->pack_start($hostbox, 0, 0, 2);
395 $vbox->pack_start($cidr_box, 0, 0, 2);
397 my $cfg_gateway = Proxmox
::Install
::Config
::get_gateway
();
398 my $gateway = $cfg_gateway // $ipconf->{gateway
} || '192.168.100.1';
400 my ($gwbox, $ipconf_entry_gw) = create_text_input
($gateway, 'Gateway:');
401 $vbox->pack_start($gwbox, 0, 0, 2);
403 my $cfg_dns = Proxmox
::Install
::Config
::get_dns
();
404 my $dnsserver = $cfg_dns // $ipconf->{dnsserver
} || $gateway;
406 my ($dnsbox, $ipconf_entry_dns) = create_text_input
($dnsserver, 'DNS Server:');
408 $vbox->pack_start($dnsbox, 0, 0, 0);
410 $gtk_state->{inbox
}->show_all;
411 set_next
(undef, sub {
413 my $text = $hostentry->get_text();
417 my $namere = "([a-zA-Z0-9]([a-zA-Z0-9\-]*[a-zA-Z0-9])?)";
419 # Debian does not support purely numeric hostnames
420 if ($text && $text =~ /^[0-9]+(?:\.|$)/) {
421 Proxmox
::UI
::message
("Purely numeric hostnames are not allowed.");
422 $hostentry->grab_focus();
426 if ($text && $text =~ m/^(${namere}\.)*${namere}$/ && $text !~ m/.example.invalid$/ &&
427 $text =~ m/^([^\.]+)\.(\S+)$/) {
428 Proxmox
::Install
::Config
::set_hostname
($1);
429 Proxmox
::Install
::Config
::set_domain
($2);
431 Proxmox
::UI
::message
("Hostname does not look like a fully qualified domain name.");
432 $hostentry->grab_focus();
437 $text = $ipconf_entry_addr->get_text();
438 my ($ipaddress, $ipversion) = parse_ip_address
($text);
439 if (!defined($ipaddress)) {
440 Proxmox
::UI
::message
("IP address is not valid.");
441 $ipconf_entry_addr->grab_focus();
445 $text = $ipconf_entry_mask->get_text();
446 my $netmask = parse_ip_mask
($text, $ipversion);
447 if (!defined($netmask)) {
448 Proxmox
::UI
::message
("Netmask is not valid.");
449 $ipconf_entry_mask->grab_focus();
452 Proxmox
::Install
::Config
::set_cidr
("$ipaddress/$netmask");
454 $text = $ipconf_entry_gw->get_text();
455 my ($gateway_ip, $gateway_ip_version) = parse_ip_address
($text);
456 if (!defined($gateway_ip) || $gateway_ip_version != $ipversion) {
457 my $msg = defined($gateway_ip)
458 ?
"Gateway and host IP version must not differ (IPv$gateway_ip_version != IPv$ipversion)."
459 : "Gateway is not valid.";
460 Proxmox
::UI
::message
($msg);
461 $ipconf_entry_gw->grab_focus();
464 Proxmox
::Install
::Config
::set_gateway
($gateway_ip);
466 $text = $ipconf_entry_dns->get_text();
467 my ($dns_ip, $dns_ip_version) = parse_ip_address
($text);
468 if (!defined($dns_ip) || $dns_ip_version != $ipversion) {
469 my $msg = defined($gateway_ip)
470 ?
"DNS and host IP version must not differ (IPv$gateway_ip_version != IPv$ipversion)."
471 : "DNS IP is not valid.";
472 Proxmox
::UI
::message
($msg);
473 $ipconf_entry_dns->grab_focus();
476 Proxmox
::Install
::Config
::set_dns
($dns_ip);
478 #print STDERR "TEST $ipaddress/$netmask $gateway_ip $dns_ip\n";
484 $hostentry->grab_focus();
487 sub create_ack_view
{
491 my $vbox = Gtk3
::Box-
>new('vertical', 0);
492 $gtk_state->{inbox
}->pack_start($vbox, 1, 0, 0);
494 my $reboot_checkbox = Gtk3
::CheckButton-
>new('Automatically reboot after successful installation');
495 $reboot_checkbox->set_active(1);
496 $reboot_checkbox->signal_connect ("toggled" => sub {
498 Proxmox
::Install
::Config
::set_autoreboot
(!!$cb->get_active());
500 $vbox->pack_start($reboot_checkbox, 0, 0, 2);
502 my $proxmox_libdir = $iso_env->{locations
}->{lib
};
503 my $ack_template = "${proxmox_libdir}/html/ack_template.htm";
504 my $ack_html = "${proxmox_libdir}/html/$iso_env->{product}/$steps[$step_number]->{html}";
505 my $html_data = file_read_all
($ack_template);
507 my $country = Proxmox
::Install
::Config
::get_country
();
509 my %config_values = (
510 __target_hd__
=> join(' | ', $target_hds->@*),
511 __target_fs__
=> Proxmox
::Install
::Config
::get_filesys
(),
512 __country__
=> $iso_env->{locales
}->{country
}->{$country}->{name
},
513 __timezone__
=> Proxmox
::Install
::Config
::get_timezone
(),
514 __keymap__
=> Proxmox
::Install
::Config
::get_keymap
(),
515 __mailto__
=> Proxmox
::Install
::Config
::get_mailto
(),
516 __interface__
=> Proxmox
::Install
::Config
::get_mngmt_nic
(),
517 __hostname__
=> Proxmox
::Install
::Config
::get_hostname
(),
518 __cidr__
=> Proxmox
::Install
::Config
::get_cidr
(),
519 __gateway__
=> Proxmox
::Install
::Config
::get_gateway
(),
520 __dnsserver__
=> Proxmox
::Install
::Config
::get_dns
(),
523 while (my ($k, $v) = each %config_values) {
524 $html_data =~ s/$k/$v/g;
528 my $config = Proxmox
::Install
::Config
::get
();
530 "$iso_env->{locations}->{run}/config-ack.json",
531 to_json
($config, { utf8
=> 1, canonical
=> 1 }) ."\n",
534 warn "failed to write config-for-ack - $@" if $@;
536 file_write_all
($ack_html, $html_data);
538 Proxmox
::UI
::display_html
('ack.htm');
540 $gtk_state->{inbox
}->show_all;
542 set_next
(undef, sub {
544 create_extract_view
();
548 sub get_device_desc
{
549 my ($devname, $size, $model) = @_;
551 if ($size && ($size > 0)) {
552 $size = int($size/2048); # size in MiB, from 512B "sectors"
554 my $text = "$devname (";
556 $size = $size/1024; # size in GiB
558 $size = $size/1024; # size in TiB
559 $text .= sprintf("%.2f", $size) . "TiB";
561 $text .= sprintf("%.2f", $size) . "GiB";
564 $text .= "${size}MiB";
567 $text .= ", $model" if $model;
579 my ($cb, $kmap) = @_;
584 my $kmaphash = $iso_env->{locales
}->{kmaphash
};
585 foreach my $layout (sort keys %$kmaphash) {
586 $def = $i if $kmaphash->{$layout} eq 'en-us';
587 $ind = $i if $kmap && $kmaphash->{$layout} eq $kmap;
591 my $val = $ind || $def || 0;
593 if (!defined($kmap)) {
594 $last_layout //= $val;
595 } elsif (!defined($country_layout) || $country_layout != $val) {
596 $last_layout = $country_layout = $val;
598 $cb->set_active($last_layout);
602 sub update_zonelist
{
605 my $sel = Proxmox
::Install
::Config
::get_timezone
(); # initial default
607 $sel = $lastzonecb->get_active_text();
608 $box->remove($lastzonecb);
611 my $cb = $lastzonecb = Gtk3
::ComboBoxText-
>new();
612 $cb->set_size_request(200, -1);
613 $cb->signal_connect('changed' => sub {
614 my $timezone = $cb->get_active_text();
615 Proxmox
::Install
::Config
::set_timezone
($timezone);
618 my ($cczones, $zones) = $iso_env->{locales
}->@{'cczones', 'zones'};
619 my @available_zones = $cc && defined($cczones->{$cc}) ?
keys %{$cczones->{$cc}} : keys %$zones;
621 my ($i, $selected_index) = (0, undef);
622 for my $zone (sort @available_zones) {
623 $selected_index = $i if $sel && $zone eq $sel;
624 $cb->append_text($zone);
628 # Append UTC here, so it is always the last item and never the default for any country.
629 $cb->append_text('UTC');
631 $cb->set_active($selected_index || 0);
634 $box->pack_start($cb, 0, 0, 0);
637 sub create_password_view
{
641 my $password = Proxmox
::Install
::Config
::get_password
();
643 my $vbox2 = Gtk3
::Box-
>new('vertical', 0);
644 $gtk_state->{inbox
}->pack_start($vbox2, 1, 0, 0);
645 my $vbox = Gtk3
::Box-
>new('vertical', 0);
646 $vbox2->pack_start($vbox, 0, 0, 10);
648 my $hbox1 = Gtk3
::Box-
>new('horizontal', 0);
649 my $label = Gtk3
::Label-
>new("Password");
650 $label->set_size_request(150, -1);
651 $label->set_xalign(1.0);
652 $hbox1->pack_start($label, 0, 0, 10);
653 my $pwe1 = Gtk3
::Entry-
>new();
654 $pwe1->set_visibility(0);
655 $pwe1->set_text($password) if $password;
656 $pwe1->set_size_request(200, -1);
657 $hbox1->pack_start($pwe1, 0, 0, 0);
659 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
660 $label = Gtk3
::Label-
>new("Confirm");
661 $label->set_size_request(150, -1);
662 $label->set_xalign(1.0);
663 $hbox2->pack_start($label, 0, 0, 10);
664 my $pwe2 = Gtk3
::Entry-
>new();
665 $pwe2->set_visibility(0);
666 $pwe2->set_text($password) if $password;
667 $pwe2->set_size_request(200, -1);
668 $hbox2->pack_start($pwe2, 0, 0, 0);
670 my $hbox3 = Gtk3
::Box-
>new('horizontal', 0);
671 $label = Gtk3
::Label-
>new("Email");
672 $label->set_size_request(150, -1);
673 $label->set_xalign(1.0);
674 $hbox3->pack_start($label, 0, 0, 10);
675 my $eme = Gtk3
::Entry-
>new();
676 $eme->set_size_request(200, -1);
677 $eme->set_text(Proxmox
::Install
::Config
::get_mailto
());
678 $hbox3->pack_start($eme, 0, 0, 0);
681 $vbox->pack_start($hbox1, 0, 0, 5);
682 $vbox->pack_start($hbox2, 0, 0, 5);
683 $vbox->pack_start($hbox3, 0, 0, 15);
685 $gtk_state->{inbox
}->show_all;
687 Proxmox
::UI
::display_html
('passwd.htm');
689 set_next
(undef, sub {
691 my $t1 = $pwe1->get_text;
692 my $t2 = $pwe2->get_text;
694 if (length ($t1) < 5) {
695 Proxmox
::UI
::message
("Password is too short.");
701 Proxmox
::UI
::message
("Password does not match.");
706 my $t3 = $eme->get_text;
707 if ($t3 !~ m/^[\w\+\-\~]+(\.[\w\+\-\~]+)*@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]+)*$/) {
708 Proxmox
::UI
::message
("Email does not look like a valid address (user\@domain.tld)");
713 if ($t3 eq 'mail@example.invalid') {
714 Proxmox
::UI
::message
("Please enter a valid Email address");
719 Proxmox
::Install
::Config
::set_password
($t1);
720 Proxmox
::Install
::Config
::set_mailto
($t3);
723 create_ipconf_view
();
731 sub create_country_view
{
735 my $locales = $iso_env->{locales
};
737 my $vbox2 = Gtk3
::Box-
>new('vertical', 0);
738 $gtk_state->{inbox
}->pack_start($vbox2, 1, 0, 0);
739 my $vbox = Gtk3
::Box-
>new('vertical', 0);
740 $vbox2->pack_start($vbox, 0, 0, 10);
742 my $w = Gtk3
::Entry-
>new();
743 $w->set_size_request(200, -1);
745 my $c = Gtk3
::EntryCompletion-
>new();
746 $c->set_text_column(0);
747 $c->set_minimum_key_length(0);
748 $c->set_popup_set_width(1);
749 $c->set_inline_completion(1);
751 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
752 my $label = Gtk3
::Label-
>new("Time zone");
753 $label->set_size_request(150, -1);
754 $label->set_xalign(1.0);
755 $hbox2->pack_start($label, 0, 0, 10);
756 update_zonelist
($hbox2);
758 my $hbox3 = Gtk3
::Box-
>new('horizontal', 0);
759 $label = Gtk3
::Label-
>new("Keyboard Layout");
760 $label->set_size_request(150, -1);
761 $label->set_xalign(1.0);
762 $hbox3->pack_start($label, 0, 0, 10);
764 my $kmapcb = Gtk3
::ComboBoxText-
>new();
765 $kmapcb->set_size_request (200, -1);
766 for my $layout (sort keys %{$locales->{kmaphash
}}) {
767 $kmapcb->append_text($layout);
770 update_layout
($kmapcb);
771 $hbox3->pack_start ($kmapcb, 0, 0, 0);
773 $kmapcb->signal_connect ('changed' => sub {
774 my $sel = $kmapcb->get_active_text();
775 $last_layout = $kmapcb->get_active();
776 if (my $kmap = $locales->{kmaphash
}->{$sel}) {
777 my $xkmap = $locales->{kmap
}->{$kmap}->{x11
};
778 my $xvar = $locales->{kmap
}->{$kmap}->{x11var
};
780 Proxmox
::Install
::Config
::set_keymap
($kmap);
782 return if (defined($installer_kmap) && $installer_kmap eq $kmap);
783 $installer_kmap = $kmap;
785 if (!is_test_mode
()) {
786 syscmd
("setxkbmap $xkmap $xvar");
793 $kbd_config =~ s/^\s+//gm;
795 Proxmox
::Sys
::Command
::run_in_background
(sub {
796 file_write_all
('/etc/default/keyboard', $kbd_config);
803 $w->signal_connect ('changed' => sub {
804 my ($entry, $event) = @_;
805 my $text = $entry->get_text;
807 if (my $cc = $locales->{countryhash
}->{lc($text)}) {
808 update_zonelist
($hbox2, $cc);
809 my $kmap = $locales->{country
}->{$cc}->{kmap
} || 'en-us';
810 update_layout
($kmapcb, $kmap);
814 $w->signal_connect (key_press_event
=> sub {
815 my ($entry, $event) = @_;
816 my $text = $entry->get_text;
818 my $val = $event->get_keyval;
820 if ($val == Gtk3
::Gdk
::KEY_Tab
) {
821 my $cc = $locales->{countryhash
}->{lc($text)};
828 $compl = $locales->{country
}->{$cc}->{name
};
830 for my $country (values $locales->{country
}->%*) {
831 if ($country->{name
} =~ m/^\Q$text\E.*$/i) {
833 $compl = $country->{name
};
840 $entry->set_text($compl);
849 my $buf = $w->get_buffer();
850 $buf->insert_text(-1, '', -1); # popup selection
858 my $country_store = Gtk3
::ListStore-
>new('Glib::String');
859 my $countries = $locales->{country
};
860 for my $cc (sort { $countries->{$a}->{name
} cmp $countries->{$b}->{name
} } keys %$countries) {
861 my $iter = $country_store->append();
862 $country_store->set($iter, 0, $countries->{$cc}->{name
});
864 $c->set_model($country_store);
866 $w->set_completion ($c);
868 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
870 $label = Gtk3
::Label-
>new("Country");
871 $label->set_xalign(1.0);
872 $label->set_size_request(150, -1);
873 $hbox->pack_start($label, 0, 0, 10);
874 $hbox->pack_start($w, 0, 0, 0);
876 $vbox->pack_start($hbox, 0, 0, 5);
877 $vbox->pack_start($hbox2, 0, 0, 5);
878 $vbox->pack_start($hbox3, 0, 0, 5);
880 my $country = Proxmox
::Install
::Config
::get_country
();
881 if ($country && (my $entry = $locales->{country
}->{$country})) {
882 $w->set_text($entry->{name
});
885 $gtk_state->{inbox
}->show_all;
887 Proxmox
::UI
::display_html
('country.htm');
888 set_next
(undef, sub {
890 my $text = $w->get_text;
892 if (my $cc = $locales->{countryhash
}->{lc($text)}) {
893 Proxmox
::Install
::Config
::set_country
($cc);
895 create_password_view
();
898 Proxmox
::UI
::message
("Please select a country first.");
909 my $hdoption_first_setup = 1;
911 my $create_basic_grid = sub {
912 my $grid = Gtk3
::Grid-
>new();
913 $grid->set_visible(1);
914 $grid->set_column_spacing(10);
915 $grid->set_row_spacing(10);
916 $grid->set_hexpand(1);
918 $grid->set_margin_start(10);
919 $grid->set_margin_end(20);
920 $grid->set_margin_top(5);
921 $grid->set_margin_bottom(5);
926 my $create_label_widget_grid = sub {
927 my ($labeled_widgets) = @_;
929 my $grid = &$create_basic_grid();
932 for (my $i = 0; $i < @$labeled_widgets; $i += 2) {
933 my $widget = @$labeled_widgets[$i+1];
934 my $label = Gtk3
::Label-
>new(@$labeled_widgets[$i]);
935 $label->set_visible(1);
936 $label->set_xalign(1.0);
937 $grid->attach($label, 0, $row, 1, 1);
938 $widget->set_visible(1);
939 $grid->attach($widget, 1, $row, 1, 1);
946 # only relevant for raid with its multipl diskX to diskY mappings.
947 my $get_selected_hdsize = sub {
949 return $hdsize if defined($hdsize);
951 # compute the smallest disk size of the actually selected disks
952 my $cached_disks = get_cached_disks
();
953 my $disk_count = scalar(@$cached_disks);
954 for (my $i = 0; $i < $disk_count; $i++) {
955 next if !Proxmox
::Install
::Config
::get_disk_selection
($i);
956 my $cur_hd = $cached_disks->[$i];
957 my $disksize = int(@$cur_hd[2] / (2 * 1024 * 1024.0)); # size in GB
958 $hdsize //= $disksize;
959 $hdsize = $disksize if $disksize < $hdsize;
962 if (my $cfg_hdsize = Proxmox
::Install
::Config
::get_hdsize
()) {
963 # had the dialog open previously and set an even lower size than the disk selection allows
964 $hdsize = $cfg_hdsize if $cfg_hdsize < $hdsize;
966 return $hdsize // 0; # fall back to zero, e.g., if none is selected hdsize cannot be any size
969 my sub update_hdsize_adjustment
{
970 my ($adjustment, $hdsize) = @_;
972 $hdsize = $get_selected_hdsize->($hdsize);
973 # expect that lower = 0 and step increments = 1 still are valid
974 $adjustment->set_upper($hdsize + 1);
975 $adjustment->set_value($hdsize);
978 my sub create_hdsize_adjustment
{
980 $hdsize = $get_selected_hdsize->($hdsize);
981 my $cfg_hdsize = Proxmox
::Install
::Config
::get_hdsize
();
982 # params are: initial value, lower, upper, step increment, page increment, page size
983 return Gtk3
::Adjustment-
>new($cfg_hdsize || $hdsize, 0, $hdsize+1, 1, 1, 1);
986 my sub get_hdsize_spin_button
{
989 my $hdsize_entry_buffer = Gtk3
::EntryBuffer-
>new(undef, 1);
990 my $hdsize_size_adj = create_hdsize_adjustment
($hdsize);
992 my $spinbutton_hdsize = Gtk3
::SpinButton-
>new($hdsize_size_adj, 1, 1);
993 $spinbutton_hdsize->set_buffer($hdsize_entry_buffer);
994 $spinbutton_hdsize->set_adjustment($hdsize_size_adj);
995 $spinbutton_hdsize->set_tooltip_text("only use specified size (GB) of the harddisk (rest left unpartitioned)");
996 return $spinbutton_hdsize;
999 my $create_raid_disk_grid = sub {
1000 my ($hdsize_buttons) = @_;
1002 my $cached_disks = get_cached_disks
();
1003 my $disk_count = scalar(@$cached_disks);
1004 my $disk_labeled_widgets = [];
1005 for (my $i = 0; $i < $disk_count; $i++) {
1006 my $disk_selector = Gtk3
::ComboBoxText-
>new();
1007 $disk_selector->append_text("-- do not use --");
1008 $disk_selector->set_active(0);
1009 $disk_selector->set_visible(1);
1011 for my $hd (@$cached_disks) {
1012 my ($disk, $devname, $size, $model, $logical_bsize) = @$hd;
1013 $disk_selector->append_text(get_device_desc
($devname, $size, $model));
1016 $disk_selector->{pve_disk_id
} = $i;
1017 $disk_selector->signal_connect(changed
=> sub {
1019 my $diskid = $w->{pve_disk_id
};
1020 my $a = $w->get_active - 1;
1021 Proxmox
::Install
::Config
::set_disk_selection
($diskid, $a >= 0);
1022 for my $btn (@$hdsize_buttons) {
1023 update_hdsize_adjustment
($btn->get_adjustment());
1027 if ($hdoption_first_setup) {
1028 $disk_selector->set_active ($i+1) if $cached_disks->[$i];
1031 if (Proxmox
::Install
::Config
::get_disk_selection
($i)) {
1032 my $cur_hd = $cached_disks->[$i];
1033 foreach my $hd (@$cached_disks) {
1034 if (@$hd[1] eq @$cur_hd[1]) {
1035 $disk_selector->set_active($hdind+1);
1043 push @$disk_labeled_widgets, "Harddisk $i", $disk_selector;
1046 my $clear_all_button = Gtk3
::Button-
>new('_Deselect All');
1047 if ($disk_count > 3) {
1048 $clear_all_button->signal_connect('clicked', sub {
1050 for my $disk_selector (@$disk_labeled_widgets) {
1051 $disk_selector->set_active(0) if $is_widget;
1055 $clear_all_button->set_visible(1);
1058 my $scrolled_window = Gtk3
::ScrolledWindow-
>new();
1059 $scrolled_window->set_hexpand(1);
1060 $scrolled_window->set_propagate_natural_height(1) if $disk_count > 4;
1062 my $diskgrid = $create_label_widget_grid->($disk_labeled_widgets);
1064 $scrolled_window->add($diskgrid);
1065 $scrolled_window->set_policy('never', 'automatic');
1066 $scrolled_window->set_visible(1);
1067 $scrolled_window->set_min_content_height(190);
1069 my $vbox = Gtk3
::Box-
>new('vertical', 0);
1070 $vbox->pack_start($scrolled_window, 1, 1, 10);
1072 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
1073 $hbox->pack_end($clear_all_button, 0, 0, 20);
1074 $hbox->set_visible(1);
1075 $vbox->pack_end($hbox, 0, 0, 0);
1080 my $create_raid_advanced_grid = sub {
1081 my ($hdsize_btn) = @_;
1082 my $labeled_widgets = [];
1083 my $spinbutton_ashift = Gtk3
::SpinButton-
>new_with_range(9, 13, 1);
1084 $spinbutton_ashift->set_tooltip_text("zpool ashift property (pool sector size, default 2^12)");
1085 $spinbutton_ashift->signal_connect ("value-changed" => sub {
1087 Proxmox
::Install
::Config
::set_zfs_opt
('ashift', $w->get_value_as_int());
1089 my $ashift = Proxmox
::Install
::Config
::get_zfs_opt
('ashift') // 12;
1090 $spinbutton_ashift->set_value($ashift);
1091 push @$labeled_widgets, "ashift";
1092 push @$labeled_widgets, $spinbutton_ashift;
1094 my $combo_compress = Gtk3
::ComboBoxText-
>new();
1095 $combo_compress->set_tooltip_text("zfs compression algorithm for rpool dataset");
1096 my $comp_opts = ["on","off","lzjb","lz4", "zle", "gzip", "zstd"];
1097 foreach my $opt (@$comp_opts) {
1098 $combo_compress->append($opt, $opt);
1100 my $compress = Proxmox
::Install
::Config
::get_zfs_opt
('compress') // 'on';
1101 $combo_compress->set_active_id($compress);
1102 $combo_compress->signal_connect (changed
=> sub {
1104 Proxmox
::Install
::Config
::set_zfs_opt
('compress', $w->get_active_text());
1106 push @$labeled_widgets, "compress";
1107 push @$labeled_widgets, $combo_compress;
1109 my $combo_checksum = Gtk3
::ComboBoxText-
>new();
1110 $combo_checksum->set_tooltip_text("zfs checksum algorithm for rpool dataset");
1111 my $csum_opts = ["on", "off","fletcher2", "fletcher4", "sha256"];
1112 foreach my $opt (@$csum_opts) {
1113 $combo_checksum->append($opt, $opt);
1115 my $checksum = Proxmox
::Install
::Config
::get_zfs_opt
('checksum') // 'on';
1116 $combo_checksum->set_active_id($checksum);
1117 $combo_checksum->signal_connect (changed
=> sub {
1119 Proxmox
::Install
::Config
::set_zfs_opt
('checksum', $w->get_active_text());
1121 push @$labeled_widgets, "checksum";
1122 push @$labeled_widgets, $combo_checksum;
1124 my $spinbutton_copies = Gtk3
::SpinButton-
>new_with_range(1,3,1);
1125 $spinbutton_copies->set_tooltip_text("zfs copies property for rpool dataset (in addition to RAID redundancy!)");
1126 $spinbutton_copies->signal_connect ("value-changed" => sub {
1128 Proxmox
::Install
::Config
::set_zfs_opt
('copies', $w->get_value_as_int());
1130 my $copies = Proxmox
::Install
::Config
::get_zfs_opt
('copies') // 1;
1131 $spinbutton_copies->set_value($copies);
1132 push @$labeled_widgets, "copies", $spinbutton_copies;
1134 push @$labeled_widgets, "hdsize", $hdsize_btn;
1135 return $create_label_widget_grid->($labeled_widgets);;
1138 my $create_btrfs_raid_advanced_grid = sub {
1139 my ($hdsize_btn) = @_;
1140 my $labeled_widgets = [];
1141 push @$labeled_widgets, "hdsize", $hdsize_btn;
1142 return $create_label_widget_grid->($labeled_widgets);;
1145 sub create_hdoption_view
{
1146 my $dialog = Gtk3
::Dialog-
>new();
1148 $dialog->set_title("Harddisk options");
1150 $dialog->add_button("_OK", 1);
1152 my $contarea = $dialog->get_content_area();
1154 my $hbox2 = Gtk3
::Box-
>new('horizontal', 0);
1155 $contarea->pack_start($hbox2, 1, 1, 5);
1157 my $grid = Gtk3
::Grid-
>new();
1158 $grid->set_column_spacing(10);
1159 $grid->set_row_spacing(10);
1161 $hbox2->pack_start($grid, 1, 0, 5);
1166 my $label0 = Gtk3
::Label-
>new("Filesystem");
1167 $label0->set_xalign(1.0);
1168 $grid->attach($label0, 0, $row, 1, 1);
1170 my $fstypecb = Gtk3
::ComboBoxText-
>new();
1181 push @$fstype, 'btrfs (RAID0)', 'btrfs (RAID1)', 'btrfs (RAID10)'
1182 if $iso_env->{cfg
}->{enable_btrfs
};
1184 my $filesys = Proxmox
::Install
::Config
::get_filesys
();
1186 foreach my $tmp (@$fstype) {
1187 $fstypecb->append_text($tmp);
1188 $fstypecb->set_active ($tcount) if $filesys eq $tmp;
1192 $grid->attach($fstypecb, 1, $row, 1, 1);
1198 my $sep = Gtk3
::Separator-
>new('horizontal');
1199 $sep->set_visible(1);
1200 $grid->attach($sep, 0, $row, 2, 1);
1203 my $hw_raid_note = Gtk3
::Label-
>new(""); # text will be set below, before making it visible
1204 $hw_raid_note->set_line_wrap(1);
1205 $hw_raid_note->set_max_width_chars(30);
1206 $hw_raid_note->set_visible(0);
1207 $grid->attach($hw_raid_note, 0, $row++, 2, 1);
1209 my $hdsize_labeled_widgets = [];
1211 my $target_hd = Proxmox
::Install
::Config
::get_target_hd
();
1212 my $hdsize = 0; # size compute
1213 if ( -b
$target_hd) {
1214 $hdsize = int(Proxmox
::Sys
::Block
::hd_size
($target_hd) / (1024 * 1024.0)); # size in GB
1215 } elsif ($target_hd) {
1216 $hdsize = int((-s
$target_hd) / (1024 * 1024 * 1024.0));
1219 my $spinbutton_hdsize_nonraid = get_hdsize_spin_button
($hdsize);
1220 push @$hdsize_labeled_widgets, "hdsize", $spinbutton_hdsize_nonraid;
1221 my $spinbutton_hdsize = $spinbutton_hdsize_nonraid;
1223 my $entry_swapsize = Gtk3
::Entry-
>new();
1224 $entry_swapsize->set_tooltip_text("maximum SWAP size (GB)");
1225 $entry_swapsize->signal_connect (key_press_event
=> \
&check_float
);
1226 my $swapsize = Proxmox
::Install
::Config
::get_swapsize
();
1227 $entry_swapsize->set_text($swapsize) if defined($swapsize);
1228 push @$hdsize_labeled_widgets, "swapsize", $entry_swapsize;
1230 my $entry_maxroot = Gtk3
::Entry-
>new();
1231 if ($iso_env->{product
} eq 'pve') {
1232 $entry_maxroot->set_tooltip_text("maximum size (GB) for LVM root volume");
1233 $entry_maxroot->signal_connect (key_press_event
=> \
&check_float
);
1234 if (my $maxroot = Proxmox
::Install
::Config
::get_maxroot
()) {
1235 $entry_maxroot->set_text($maxroot);
1237 push @$hdsize_labeled_widgets, "maxroot", $entry_maxroot;
1240 my $entry_minfree = Gtk3
::Entry-
>new();
1241 $entry_minfree->set_tooltip_text("minimum free LVM space (GB, required for LVM snapshots)");
1242 $entry_minfree->signal_connect (key_press_event
=> \
&check_float
);
1243 if (defined(my $minfree = Proxmox
::Install
::Config
::get_minfree
())) {
1244 $entry_minfree->set_text($minfree);
1246 push @$hdsize_labeled_widgets, "minfree", $entry_minfree;
1249 if ($iso_env->{product
} eq 'pve') {
1250 $entry_maxvz = Gtk3
::Entry-
>new();
1251 $entry_maxvz->set_tooltip_text("maximum size (GB) for LVM data volume");
1252 $entry_maxvz->signal_connect (key_press_event
=> \
&check_float
);
1253 if (defined(my $maxvz = Proxmox
::Install
::Config
::get_maxvz
())) {
1254 $entry_maxvz->set_text($maxvz);
1256 push @$hdsize_labeled_widgets, "maxvz", $entry_maxvz;
1259 my $spinbutton_hdsize_zfs = get_hdsize_spin_button
($hdsize);
1260 my $spinbutton_hdsize_btrfs = get_hdsize_spin_button
($hdsize);
1261 my $hdsize_buttons = [ $spinbutton_hdsize_zfs, $spinbutton_hdsize_btrfs ];
1262 my $options_stack = Gtk3
::Stack-
>new();
1263 $options_stack->set_visible(1);
1264 $options_stack->set_hexpand(1);
1265 $options_stack->set_vexpand(1);
1266 $options_stack->add_titled(&$create_raid_disk_grid($hdsize_buttons), "raiddisk", "Disk Setup");
1267 $options_stack->add_titled(&$create_label_widget_grid($hdsize_labeled_widgets), "hdsize", "Size Options");
1268 $options_stack->add_titled(&$create_raid_advanced_grid($spinbutton_hdsize_zfs), "raidzfsadvanced", "Advanced Options");
1269 $options_stack->add_titled(&$create_btrfs_raid_advanced_grid($spinbutton_hdsize_btrfs), "raidbtrfsadvanced", "Advanced Options");
1270 $options_stack->set_visible_child_name("raiddisk");
1271 my $options_stack_switcher = Gtk3
::StackSwitcher-
>new();
1272 $options_stack_switcher->set_halign('center');
1273 $options_stack_switcher->set_stack($options_stack);
1274 $grid->attach($options_stack_switcher, 0, $row, 2, 1);
1276 $grid->attach($options_stack, 0, $row, 2, 1);
1279 $hdoption_first_setup = 0;
1281 my $switch_view = sub {
1282 my $filesys = Proxmox
::Install
::Config
::get_filesys
();
1283 my $raid = $filesys =~ m/zfs|btrfs/;
1284 my $is_zfs = $filesys =~ m/zfs/;
1286 $target_hd_combo->set_visible(!$raid);
1287 $options_stack->get_child_by_name("hdsize")->set_visible(!$raid);
1288 $options_stack->get_child_by_name("raiddisk")->set_visible($raid);
1291 my $msg = "<b>Note</b>: " . ($is_zfs
1292 ?
"ZFS is not compatible with hardware RAID controllers, for details see the documentation."
1293 : "BTRFS integration in $iso_env->{cfg}->{fullname} is a technology preview!"
1295 $hw_raid_note->set_markup($msg);
1297 $hw_raid_note->set_visible($raid);
1298 $options_stack_switcher->set_visible($raid);
1299 $options_stack->get_child_by_name("raidzfsadvanced")->set_visible($is_zfs);
1300 $options_stack->get_child_by_name("raidbtrfsadvanced")->set_visible(!$is_zfs);
1302 $target_hd_label->set_text("Target: $filesys ");
1303 $options_stack->set_visible_child_name("raiddisk");
1305 $target_hd_label->set_text("Target Harddisk: ");
1309 $spinbutton_hdsize = $is_zfs ?
$spinbutton_hdsize_zfs : $spinbutton_hdsize_btrfs;
1311 $spinbutton_hdsize = $spinbutton_hdsize_nonraid;
1314 my (undef, $pref_width) = $dialog->get_preferred_width();
1315 my (undef, $pref_height) = $dialog->get_preferred_height();
1316 $pref_height = 750 if $pref_height > 750;
1317 $dialog->resize($pref_width, $pref_height);
1322 $fstypecb->signal_connect (changed
=> sub {
1323 my $new_filesys = $fstypecb->get_active_text();
1324 Proxmox
::Install
::Config
::set_filesys
($new_filesys);
1328 my $sep2 = Gtk3
::Separator-
>new('horizontal');
1329 $sep2->set_visible(1);
1330 $contarea->pack_end($sep2, 1, 1, 10);
1336 my $get_float = sub {
1339 my $text = $entry->get_text();
1340 return undef if !defined($text);
1345 return undef if $text !~ m/^\d+(\.\d+)?$/;
1352 if (($tmp = &$get_float($spinbutton_hdsize)) && ($tmp != $hdsize)) {
1353 Proxmox
::Install
::Config
::set_hdsize
($tmp);
1355 Proxmox
::Install
::Config
::set_hdsize
(undef);
1358 if (defined($tmp = &$get_float($entry_swapsize))) {
1359 Proxmox
::Install
::Config
::set_swapsize
($tmp);
1361 Proxmox
::Install
::Config
::set_swapsize
(undef);
1364 if (defined($tmp = &$get_float($entry_maxroot))) {
1365 Proxmox
::Install
::Config
::set_maxroot
($tmp);
1367 Proxmox
::Install
::Config
::set_maxroot
(undef);
1370 if (defined($tmp = &$get_float($entry_minfree))) {
1371 Proxmox
::Install
::Config
::set_minfree
($tmp);
1373 Proxmox
::Install
::Config
::set_minfree
(undef);
1376 if ($entry_maxvz && defined($tmp = &$get_float($entry_maxvz))) {
1377 Proxmox
::Install
::Config
::set_maxvz
($tmp);
1379 Proxmox
::Install
::Config
::set_maxvz
(undef);
1385 my $last_hd_selected = 0;
1386 sub create_hdsel_view
{
1388 $gtk_state->{prev_btn
}->set_sensitive(1); # enable previous button at this point
1392 my $vbox = Gtk3
::Box-
>new('vertical', 0);
1393 $gtk_state->{inbox
}->pack_start($vbox, 1, 0, 0);
1394 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
1395 $vbox->pack_start($hbox, 0, 0, 10);
1397 my $cached_disks = get_cached_disks
();
1398 my ($disk, $devname, $size, $model, $logical_bsize) = $cached_disks->[0]->@*;
1399 if (!defined(Proxmox
::Install
::Config
::get_target_hd
())) {
1400 Proxmox
::Install
::Config
::set_target_hd
($devname);
1403 $target_hd_label = Gtk3
::Label-
>new("Target Harddisk: ");
1404 $hbox->pack_start($target_hd_label, 0, 0, 0);
1406 $target_hd_combo = Gtk3
::ComboBoxText-
>new();
1408 foreach my $hd ($cached_disks->@*) {
1409 ($disk, $devname, $size, $model, $logical_bsize) = @$hd;
1410 $target_hd_combo->append_text(get_device_desc
($devname, $size, $model));
1413 my $raid = Proxmox
::Install
::Config
::get_filesys
() =~ m/zfs|btrfs/;
1415 my $filesys = Proxmox
::Install
::Config
::get_filesys
();
1416 $target_hd_label->set_text("Target: $filesys ");
1417 $target_hd_combo->set_visible(0);
1418 $target_hd_combo->set_no_show_all(1);
1420 $target_hd_combo->set_active($last_hd_selected);
1421 $target_hd_combo->signal_connect(changed
=> sub {
1422 $a = shift-
>get_active;
1423 my ($disk, $devname) = @{@$cached_disks[$a]};
1424 $last_hd_selected = $a;
1425 Proxmox
::Install
::Config
::set_target_hd
($devname);
1428 $hbox->pack_start($target_hd_combo, 0, 0, 10);
1430 my $options = Gtk3
::Button-
>new('_Options');
1431 $options->signal_connect (clicked
=> \
&create_hdoption_view
);
1432 $hbox->pack_start ($options, 0, 0, 0);
1435 $gtk_state->{inbox
}->show_all;
1437 Proxmox
::UI
::display_html
('page1.htm');
1439 set_next
(undef, sub {
1440 my $filesys = Proxmox
::Install
::Config
::get_filesys
();
1441 if ($filesys =~ m/zfs/) {
1442 my ($devlist) = eval { Proxmox
::Install
::get_zfs_raid_setup
() };
1444 Proxmox
::UI
::message
("Warning: $err\nPlease fix ZFS setup first.");
1447 $target_hds = [ map { $_->[1] } @$devlist ];
1448 } elsif ($filesys =~ m/btrfs/) {
1449 my ($devlist) = eval { Proxmox
::Install
::get_btrfs_raid_setup
() };
1451 Proxmox
::UI
::message
("Warning: $err\nPlease fix BTRFS setup first.");
1454 $target_hds = [ map { $_->[1] } @$devlist ];
1456 my $target_hd = Proxmox
::Install
::Config
::get_target_hd
();
1458 my $target_block_size = Proxmox
::Sys
::Block
::logical_blocksize
($target_hd);
1459 Proxmox
::Install
::legacy_bios_4k_check
($target_block_size);
1462 Proxmox
::UI
::message
("Warning: $err\n");
1465 $target_hds = [ $target_hd ];
1469 create_country_view
();
1473 sub create_extract_view
{
1476 Proxmox
::Install
::display_info
();
1478 $gtk_state->{next_btn
}->set_sensitive(0);
1479 $gtk_state->{prev_btn
}->set_sensitive(0);
1480 $gtk_state->{prev_btn
}->hide();
1482 my $vbox = Gtk3
::Box-
>new('vertical', 0);
1483 $gtk_state->{inbox
}->pack_start ($vbox, 1, 0, 0);
1484 my $hbox = Gtk3
::Box-
>new('horizontal', 0);
1485 $vbox->pack_start ($hbox, 0, 0, 10);
1487 my $vbox2 = Gtk3
::Box-
>new('vertical', 0);
1488 $hbox->pack_start ($vbox2, 0, 0, 0);
1490 $vbox2->pack_start($gtk_state->{progress_status
}, 1, 1, 0);
1492 $gtk_state->{progress_bar
}->set_show_text(1);
1493 $gtk_state->{progress_bar
}->set_size_request (600, -1);
1495 $vbox2->pack_start($gtk_state->{progress_bar
}, 0, 0, 0);
1497 $gtk_state->{inbox
}->show_all();
1499 eval { Proxmox
::Install
::extract_data
() };
1502 $gtk_state->{next_btn
}->set_sensitive(1);
1504 set_next
("_Reboot", sub { app_quit
(0); } );
1506 my $autoreboot = Proxmox
::Install
::Config
::get_autoreboot
();
1507 my $autoreboot_seconds = 5;
1508 my $success_transform = sub {
1509 my ($raw_html, $iso_env) = @_;
1511 my $ip_addr = Proxmox
::Install
::Config
::get_ip_addr
();
1512 my $ip_version = Proxmox
::Install
::Config
::get_ip_version
();
1514 my $addr = $ip_version == 6 ?
"[${ip_addr}]" : "$ip_addr";
1515 $raw_html =~ s/__IPADDR__/$addr/g;
1516 $raw_html =~ s/__PORT__/$iso_env->{cfg}->{port}/g;
1518 my $autoreboot_msg = $autoreboot ?
"Automatic reboot scheduled in $autoreboot_seconds seconds." : '';
1519 $raw_html =~ s/__AUTOREBOOT_MSG__/$autoreboot_msg/;
1525 Proxmox
::UI
::display_html
("fail.htm");
1526 # suppress "empty" error as we got some case where the user choose to abort on a prompt,
1527 # there it doesn't make sense to show them an error again, they "caused" it after all.
1528 Proxmox
::UI
::error
($err) if $err ne "\n";
1531 Proxmox
::UI
::display_html
("success.htm", $success_transform);
1534 Glib
::Timeout-
>add(1000, sub {
1535 if ($autoreboot_seconds > 0) {
1536 $autoreboot_seconds--;
1537 Proxmox
::UI
::display_html
("success.htm", $success_transform);
1546 sub create_intro_view
{
1548 $gtk_state->{prev_btn
}->set_sensitive(0);
1552 my $run_env = Proxmox
::Install
::RunEnv
::get
();
1553 if (int($run_env->{total_memory
}) < 1024) {
1554 Proxmox
::UI
::error
("Less than 1 GiB of usable memory detected, installation will probably fail.\n\n".
1555 "See 'System Requirements' in the $iso_env->{cfg}->{fullname} documentation.");
1558 if ($iso_env->{product
} eq 'pve') {
1559 my $cpuinfo = eval { file_read_all
('/proc/cpuinfo') };
1560 if (!$cpuinfo || $cpuinfo !~ /^flags\s*:.*(vmx|svm)/m) {
1562 "No support for hardware-accelerated KVM virtualization detected.\n\n"
1563 ."Check BIOS settings for Intel VT / AMD-V / SVM."
1568 Proxmox
::UI
::display_html
('license.htm', sub {
1569 my ($raw_html, $iso_env) = @_;
1571 my $proxmox_cddir = $iso_env->{locations
}->{iso
};
1572 my $license = eval { decode
('utf8', file_read_all
("${proxmox_cddir}/EULA")) };
1574 die $err if !is_test_mode
();
1575 $license = "TESTMODE: Ignore non existent EULA...\n";
1577 my $title = "END USER LICENSE AGREEMENT (EULA)";
1578 $raw_html =~ s/__LICENSE__/$license/;
1579 $raw_html =~ s/__LICENSE_TITLE__/$title/;
1585 set_next
("I a_gree", \
&create_hdsel_view
);
1590 create_main_window
();
1592 my $initial_error = 0;
1595 my $cached_disks = get_cached_disks
();
1596 if (!defined($cached_disks) || (scalar (@$cached_disks) <= 0)) {
1597 print STDERR
"no harddisks found\n";
1599 Proxmox
::UI
::display_html
("nohds.htm");
1600 set_next
("Reboot", sub { app_quit
(0); } );
1602 foreach my $hd (@$cached_disks) {
1603 my ($disk, $devname) = @$hd;
1604 next if $devname =~ m
|^/dev/md\d
+$|;
1605 print STDERR
"found Disk$disk N:$devname\n";
1610 my $run_env = Proxmox
::Install
::RunEnv
::get
();
1611 if (!$initial_error && (scalar keys $run_env->{ipconf
}->{ifaces
}->%* == 0)) {
1612 print STDERR
"no network interfaces found\n";
1614 Proxmox
::UI
::display_html
("nonics.htm");
1615 set_next
("Reboot", sub { app_quit
(0); } );
1618 create_intro_view
() if !$initial_error;