diff options
Diffstat (limited to 'perl-install/fs/partitioning_wizard.pm')
| -rw-r--r-- | perl-install/fs/partitioning_wizard.pm | 149 |
1 files changed, 74 insertions, 75 deletions
diff --git a/perl-install/fs/partitioning_wizard.pm b/perl-install/fs/partitioning_wizard.pm index 58acbf54d..fda1e3972 100644 --- a/perl-install/fs/partitioning_wizard.pm +++ b/perl-install/fs/partitioning_wizard.pm @@ -1,4 +1,4 @@ -package fs::partitioning_wizard; # $Id: partitioning_wizard.pm 269969 2010-06-09 13:01:09Z pterjan $ +package fs::partitioning_wizard; use diagnostics; use strict; @@ -13,8 +13,6 @@ use partition_table; use partition_table::raw; use partition_table::dos; use POSIX qw(ceil); -use mygtk2; -use ugtk2 qw(:wrappers); #- unit of $mb is mega bytes, min and max are in sectors, this #- function is used to convert back to sectors count the size of @@ -38,9 +36,15 @@ sub partition_with_diskdrake { do { $ok = 1; my $do_force_reload = sub { + require File::Temp; + require fs::dmcrypt; + my (undef, $tmp_file) = File::Temp::mkstemp('/tmp/crypttab.XXXXXXX'); + fs::dmcrypt::save_crypttab_($all_hds, $tmp_file); my $new_hds = fs::get::empty_all_hds(); fs::any::get_hds($new_hds, $fstab, $manual_fstab, $partitioning_flags, $skip_mtab, $in); %$all_hds = %$new_hds; + fs::dmcrypt::read_crypttab_($all_hds, $tmp_file); + rm_rf($tmp_file); $all_hds; }; require diskdrake::interactive; @@ -60,8 +64,8 @@ Then choose action ``Mount point'' and set it to `/'"), 1) or return; if (!any { isSwap($_) } @fstab) { $ok &&= $in->ask_okcancel('', N("You do not have a swap partition.\n\nContinue anyway?")); } - if (arch() =~ /ia64/ && !fs::get::has_mntpoint("/boot/efi", $all_hds)) { - $in->ask_warn('', N("You must have a FAT partition mounted in /boot/efi")); + if ( is_uefi() && !fs::get::has_mntpoint("/boot/EFI", $all_hds)) { + $in->ask_warn('', N("You must have a ESP FAT32 partition mounted in /boot/EFI")); $ok = ''; } } until $ok; @@ -69,13 +73,13 @@ Then choose action ``Mount point'' and set it to `/'"), 1) or return; } sub partitionWizardSolutions { - my ($in, $all_hds, $all_fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, $target) = @_; + my ($in, $all_hds, $all_fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, $o_target) = @_; my $hds = $all_hds->{hds}; my $fstab; my $full_fstab = [ fs::get::fstab($all_hds) ]; - if ($target) { - $hds = [ $target ]; - $fstab = [ grep { $_->{rootDevice} eq $target->{device} } fs::get::fstab($all_hds) ]; + if ($o_target) { + $hds = [ $o_target ]; + $fstab = [ grep { $_->{rootDevice} eq $o_target->{device} } fs::get::fstab($all_hds) ]; } else { $fstab = $full_fstab; } @@ -240,7 +244,7 @@ filesystem checks will be run on your next boot into Microsoft Windows®")) if $ }, \&partition_table::description, \@hds_rw) or return; } else { - $hd = $target; + $hd = $o_target; } $in->ask_okcancel_({ messages => N("ALL existing partitions and their data will be lost on drive %s", partition_table::description($hd)), title => N("Partitioning"), @@ -265,11 +269,7 @@ filesystem checks will be run on your next boot into Microsoft Windows®")) if $ When you are done, do not forget to save using `w'", partition_table::description($_)); print "\n\n"; my $pid = 0; - if (arch() =~ /ppc/) { - $pid = fork() or exec "pdisk", devices::make($_->{device}); - } else { - $pid = fork() or exec "fdisk", devices::make($_->{device}); - } + $pid = fork() or exec "fdisk", devices::make($_->{device}); waitpid($pid, 0); } $in->leave_console; @@ -291,17 +291,17 @@ sub create_display_box { my @parts = diskdrake::hd_gtk::kind2parts($kind); my $totalsectors = diskdrake::hd_gtk::kind2sectors($kind, @parts); - my $width = 540; + my $width = 520; my $minwidth = 40; - my $display_box = ugtk2::gtkset_size_request(Gtk2::HBox->new(0,0), -1, 26); + my $display_box = ugtk3::gtkset_size_request(Gtk3::HBox->new(0,0), -1, 26); my $sep_count = @parts - 1; #- ratio used to compute initial partition pixel width (each partition should be > min_width) #- though, the pixel/sectors ratio cannot be the same for all the partitions my $initial_ratio = $totalsectors ? ($width - @parts * $minwidth - $sep_count) / $totalsectors : 1; - my $vbox = Gtk2::VBox->new; + my $vbox = Gtk3::VBox->new; my $part_sep; my $desc; @@ -309,9 +309,9 @@ sub create_display_box { my $last = $resize && $resize->[-1]; foreach my $entry (@parts) { - my $part_info = Gtk2::Label->new($entry->{device_LABEL}); + my $part_info = Gtk3::Label->new($entry->{device_LABEL}); my @colorized_fs_types = qw(ext2 ext3 ext4 xfs swap vfat ntfs ntfs-3g); - my $part_widget = Gtk2::EventBox->new; + my $part_widget = Gtk3::EventBox->new; $entry->{width} = int($entry->{size} * $initial_ratio) + $minwidth; if ($last && $last->{device} eq $entry->{device}) { #- entry is the last resizable partition @@ -323,33 +323,31 @@ sub create_display_box { $part_widget->set_name("PART_vfat"); $part_info->set_size_request(ceil($ratio * $entry->{min_win}), 0); - my $mdv_widget = gtkadd(gtkset_name(Gtk2::EventBox->new, "PART_new"), + my $mdv_widget = gtkadd(gtkset_name(Gtk3::EventBox->new, "PART_new"), gtkset_size_request(gtknew("Image", file => "small-logo"), $ratio * MB(600), 0)); - my $hpane = Gtk2::HPaned->new; - $hpane->add1($part_widget); - $hpane->child1_shrink(0); - $hpane->add2($mdv_widget); - $hpane->child2_shrink(0); + my $hpane = Gtk3::HPaned->new; + $hpane->pack1($part_widget, 1, 0); + $hpane->pack2($mdv_widget, 1, 0); $hpane->set_position(ceil($ratio * $entry->{req_size})); - ugtk2::gtkset_size_request($hpane, $entry->{width}, 0); - ugtk2::gtkpack__($display_box, $hpane); + ugtk3::gtkset_size_request($hpane, $entry->{width}, 0); + ugtk3::gtkpack__($display_box, $hpane); my $add_part_size_info = sub { my ($name, $label) = @_; - ugtk2::gtkpack__($desc, - gtkadd(gtkset_name(Gtk2::EventBox->new, $name), - Gtk2::Label->new(" " x 4)), + ugtk3::gtkpack__($desc, + gtkadd(gtkset_name(Gtk3::EventBox->new, $name), + Gtk3::Label->new(" " x 4)), gtkset_size_request(gtkset_alignment($label, 0, 0.5), 150, 20)); }; - $desc = Gtk2::HBox->new(0,0); + $desc = Gtk3::HBox->new(0,0); - my $win_size_label = Gtk2::Label->new; + my $win_size_label = Gtk3::Label->new; $add_part_size_info->("PART_vfat", $win_size_label); - my $mdv_size_label = Gtk2::Label->new; + my $mdv_size_label = Gtk3::Label->new; $add_part_size_info->("PART_new", $mdv_size_label); my $update_size_labels = sub { @@ -367,7 +365,7 @@ sub create_display_box { }; $hpane->signal_connect('size-allocate' => sub { my (undef, $alloc) = @_; - $entry->{width} = $alloc->width; + $entry->{width} = $alloc->{width}; $update_ratio->(); 0; }); @@ -390,24 +388,24 @@ sub create_display_box { 'other')); } $part_widget->set_size_request($entry->{width}, 0); - ugtk2::gtkpack($display_box, $part_widget); + ugtk3::gtkpack($display_box, $part_widget); } $part_widget->add($part_info); - $part_sep = gtkadd(Gtk2::EventBox->new, - gtkset_size_request(Gtk2::Label->new("."), 1, 0)); + $part_sep = gtkadd(Gtk3::EventBox->new, + gtkset_size_request(Gtk3::Label->new("."), 1, 0)); gtkpack__($display_box, $part_sep); } $display_box->remove($part_sep) if $part_sep; unless ($resize || $fill_empty) { - my @types = (N_("Ext2/3/4"), N_("XFS"), N_("Swap"), arch() =~ /sparc/ ? N_("SunOS") : arch() eq "ppc" ? N_("HFS") : N_("Windows"), + my @types = (N_("Ext2/3/4"), N_("XFS"), N_("Swap"), N_("Windows"), N_("Other"), N_("Empty")); my %name2fs_type = ('Ext2/3/4' => 'ext3', 'XFS' => 'xfs', Swap => 'swap', Other => 'other', "Windows" => 'vfat', HFS => 'hfs'); - $desc = ugtk2::gtkpack(Gtk2::HBox->new, + $desc = ugtk3::gtkpack(Gtk3::HBox->new, map { my $t = $name2fs_type{$_}; - my $ev = Gtk2::EventBox->new; - my $w = Gtk2::Label->new(translate($_)); + my $ev = Gtk3::EventBox->new; + my $w = Gtk3::Label->new(translate($_)); $ev->add($w); $ev->set_name('PART_' . ($t || 'empty')); $ev; @@ -425,8 +423,8 @@ sub display_choices { my @solutions = sort { $solutions{$b}[0] <=> $solutions{$a}[0] } keys %solutions; my @sol = grep { $solutions{$_}[0] >= 0 } @solutions; - log::l('' . "solutions found: " . join('', map { $solutions{$_}[1] } @sol) . - " (all solutions found: " . join('', map { $solutions{$_}[1] } @solutions) . ")"); + log::l('' . "solutions found: " . join(', ', map { $solutions{$_}[1] } @sol) . + " (all solutions found: " . join(', ', map { $solutions{$_}[1] } @solutions) . ")"); @solutions = @sol if @sol > 1; log::l("solutions: ", int @solutions); @@ -437,8 +435,8 @@ sub display_choices { $contentbox->foreach(sub { $contentbox->remove($_[0]) }); $mainw->{kind}{display_box} ||= create_display_box($mainw->{kind}); - ugtk2::gtkpack2__($contentbox, $mainw->{kind}{display_box}); - ugtk2::gtkpack__($contentbox, gtknew('Label', + ugtk3::gtkpack2__($contentbox, $mainw->{kind}{display_box}); + ugtk3::gtkpack__($contentbox, gtknew('Label', text => N("The DrakX Partitioning wizard found the following solutions:"), alignment => [0, 0])); @@ -455,30 +453,30 @@ sub display_choices { $item = create_display_box($mainw->{kind}, $solutions{$s}[3], undef, $button); } elsif ($s eq 'existing_part') { } elsif ($s eq 'wipe_drive') { - $item = Gtk2::EventBox->new; + $item = Gtk3::EventBox->new; my $b2 = gtknew("Image", file => "small-logo"); $item->add($b2); - $item->set_size_request(540,26); + $item->set_size_request(520,26); $item->set_name("PART_new"); } elsif ($s eq 'diskdrake') { } else { log::l($s); next; } - ugtk2::gtkpack($vbox, + ugtk3::gtkpack($vbox, gtknew('Label', text => $solutions{$s}[1], alignment => [0, 0])); - ugtk2::gtkpack($vbox, $item) if defined($item); - $button->set_group($oldbutton->get_group) if $oldbutton; + ugtk3::gtkpack($vbox, $item) if defined($item); + $button->join_group($oldbutton) if $oldbutton; $oldbutton = $button; $button->signal_connect('toggled', sub { $mainw->{sol} = $solutions{$s} if $_[0]->get_active }); - ugtk2::gtkpack2__($choicesbox, $button); + ugtk3::gtkpack2__($choicesbox, $button); $sep = gtknew('HSeparator'); - ugtk2::gtkpack2__($choicesbox, $sep); + ugtk3::gtkpack2__($choicesbox, $sep); } $choicesbox->remove($sep); - ugtk2::gtkadd($contentbox, $choicesbox); + ugtk3::gtkadd($contentbox, $choicesbox); $mainw->{sol} = $solutions{@solutions[0]}; } @@ -488,30 +486,30 @@ sub main { my $sol; if ($o->isa('interactive::gtk')) { - require mygtk2; - mygtk2->import(qw(gtknew)); - require ugtk2; - ugtk2->import(qw(:wrappers)); + require mygtk3; + mygtk3->import(qw(gtknew)); + require ugtk3; + ugtk3->import(qw(:wrappers)); - my $mainw = ugtk2->new(N("Partitioning"), %$o, if__($::main_window, transient => $::main_window)); + my $mainw = ugtk3->new(N("Partitioning"), %$o, if__($::main_window, transient => $::main_window)); $mainw->{box_allow_grow} = 1; - mygtk2::set_main_window_size($mainw->{rwindow}); + mygtk3::set_main_window_size($mainw->{rwindow}); require diskdrake::hd_gtk; diskdrake::hd_gtk::load_theme(); - my $mainbox = Gtk2::VBox->new; + my $mainbox = Gtk3::VBox->new; my @kinds = map { diskdrake::hd_gtk::hd2kind($_) } sort { $a->{is_removable} <=> $b->{is_removable} } @{ $all_hds->{hds} }; push @kinds, diskdrake::hd_gtk::raid2real_kind($_) foreach @{$all_hds->{raids}}; push @kinds, map { diskdrake::hd_gtk::lvm2kind($_) } @{$all_hds->{lvms}}; - my $hdchoice = Gtk2::HBox->new; + my $hdchoice = Gtk3::HBox->new; - my $hdchoicelabel = Gtk2::Label->new(N("Here is the content of your disk drive ")); + my $hdchoicelabel = Gtk3::Label->new(N("Here is the content of your disk drive ")); - my $combobox = Gtk2::ComboBox->new_text; + my $combobox = Gtk3::ComboBoxText->new; foreach (@kinds) { my $info = $_->{val}{info} || $_->{val}{device}; $info =~ s|^(?:.*/)?(.{24}).*|$1|; @@ -520,29 +518,29 @@ sub main { } $combobox->set_active(0); - ugtk2::gtkpack2__($hdchoice, $hdchoicelabel); + ugtk3::gtkpack2__($hdchoice, $hdchoicelabel); $hdchoice->add($combobox); - ugtk2::gtkpack2__($mainbox, $hdchoice); + ugtk3::gtkpack2__($mainbox, $hdchoice); - my $contentbox = Gtk2::VBox->new(0, 12); + my $contentbox = Gtk3::VBox->new(0, 12); - my $scroll = Gtk2::ScrolledWindow->new; + my $scroll = Gtk3::ScrolledWindow->new; $scroll->set_policy('never', 'automatic'), - my $vp = Gtk2::Viewport->new; + my $vp = Gtk3::Viewport->new; $vp->set_shadow_type('none'); $vp->add($contentbox); $scroll->add($vp); $mainbox->add($scroll); - my $kind = @kinds[$combobox->get_active]; + my $kind = $kinds[$combobox->get_active]; my %solutions = partitionWizardSolutions($o, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, diskdrake::hd_gtk::kind2hd($kind)); delete $solutions{diskdrake} if $b_nodiskdrake; $mainw->{kind} = $kind; display_choices($o, $contentbox, $mainw, %solutions); $combobox->signal_connect("changed", sub { - $mainw->{kind} = @kinds[$combobox->get_active]; + $mainw->{kind} = $kinds[$combobox->get_active]; my %solutions = partitionWizardSolutions($o, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, diskdrake::hd_gtk::kind2hd($mainw->{kind})); delete $solutions{diskdrake} if $b_nodiskdrake; display_choices($o, $contentbox, $mainw, %solutions); @@ -553,12 +551,12 @@ sub main { if_($::isInstall, [ gtknew('Install_Button', text => N("Help"), - clicked => sub { interactive::gtk::display_help($o, {interactive_help_id => 'doPartitionDisks' }, $mainw) }), + clicked => sub { interactive::gtk::display_help($o, {interactive_help_id => 'doPartitionDisks' }) }), undef, 1 ]), ); my $buttons_pack = $mainw->create_okcancel(N("Next"), undef, '', @more_buttons); $mainbox->pack_end($buttons_pack, 0, 0, 0); - ugtk2::gtkadd($mainw->{window}, $mainbox); + ugtk3::gtkadd($mainw->{window}, $mainbox); $mainw->{window}->show_all; $mainw->main; @@ -572,8 +570,8 @@ sub main { my @solutions = sort { $b->[0] <=> $a->[0] } values %solutions; my @sol = grep { $_->[0] >= 0 } @solutions; - log::l('' . "solutions found: " . join('', map { $_->[1] } @sol) . - " (all solutions found: " . join('', map { $_->[1] } @solutions) . ")"); + log::l('' . "solutions found: " . join(', ', map { $_->[1] } @sol) . + " (all solutions found: " . join(', ', map { $_->[1] } @solutions) . ")"); @solutions = @sol if @sol > 1; log::l("solutions: ", int @solutions); @solutions or $o->ask_warn(N("Partitioning"), N("I cannot find any room for installing")), die 'already displayed'; @@ -593,6 +591,7 @@ sub main { if ($err =~ /wizcancel/) { $_->destroy foreach $::WizardTable->get_children; } else { + log::l("Partitioning failed: $err"); $o->ask_warn('', N("Partitioning failed: %s", formatError($err))); } } |
