From 0b2e5d22188febeb98b3464bd9a9c2d487bb6357 Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Wed, 9 Mar 2011 08:12:52 +0000 Subject: add GPT support --- perl-install/install/install2.pm | 6 +++ perl-install/install/steps.pm | 6 +++ perl-install/install/steps_interactive.pm | 69 +++++++++++++++++++++++++++++++ perl-install/install/steps_list.pm | 1 + 4 files changed, 82 insertions(+) diff --git a/perl-install/install/install2.pm b/perl-install/install/install2.pm index 7c25d8112..14a073b9b 100644 --- a/perl-install/install/install2.pm +++ b/perl-install/install/install2.pm @@ -135,6 +135,12 @@ sub selectKeyboard { } #------------------------------------------------------------------------------ +sub selectPartitionTable { + my ($auto) = @_; + installStepsCall($o, $auto, 'selectPartitionTable'); +} +#------------------------------------------------------------------------------ + sub selectInstallClass { my ($auto) = @_; diff --git a/perl-install/install/steps.pm b/perl-install/install/steps.pm index 4a8089253..0bf2fa596 100644 --- a/perl-install/install/steps.pm +++ b/perl-install/install/steps.pm @@ -150,6 +150,12 @@ sub selectKeyboard { $o->{raw_X}->write; } } +sub selectPartitionTable { + my ($o) = @_; + modules::load_category($o->{modules_conf}, 'disk/ide|hardware_raid|sata|firewire'); + install::any::getHds($o); +} + #------------------------------------------------------------------------------ sub acceptLicense {} diff --git a/perl-install/install/steps_interactive.pm b/perl-install/install/steps_interactive.pm index 399f6ada6..920dad93f 100644 --- a/perl-install/install/steps_interactive.pm +++ b/perl-install/install/steps_interactive.pm @@ -121,6 +121,75 @@ sub selectKeyboard { } } +#------------------------------------------------------------------------------ +sub selectPartitionTable { + my ($o, $clicked) = @_; + my @drives = detect_devices::hds(); + my $part_type; my @bigdrives; my $reboot; + + foreach my $hd (@drives) { + my $full_dev = "/dev/$hd->{device}"; + my ($stdout, @l) = run_program::get_stdout('fdisk', '-s', $full_dev); + my ($size) = $stdout =~ m|(.*)|; + # testing paramater + if ($size > 2 * 1024 * 1024 * 1024 * 1024) { +# if ($size > 248) { + push @bigdrives, $hd; + log::l("selectPartitionTable: $hd->{device} is a big drive ($size MB)"); + } else { + log::l("selectPartitionTable: $hd->{device} not a big drive ($size MB)"); + } + } + my $howmany = @bigdrives; + log::l("selectPartitionTable: $howmany bigdrive(s)"); + sleep 10; + if ($howmany > 0) { + $o->ask_from(N("Partition table modification"), + N("Installer detects big drives (>2To). +GPT partition table is mandatory if you want to create partition bigger than 2To. + +Beware, this operation will be written to disk as soon as you validate! +ALL DATA will be lost: this will erase everything on your harddisk. + +Leave it blanck if you dont want to change the partition table type. + +CAUTION: +In case of modification, system will reboot to take into account the new partition table type and avoid errors."), + [ + (map { { label => N(("Partition table type for: %s (/dev/%s)", $_->{info}, $_->{device})), val => \$selection{$_}, list => [ "", "msdos", "gpt", "dvh", "loop", "mac", "bsd", "pc98", "sun" ], + } } @bigdrives), + ], + complete => sub { + map { + if ($selection{$_} ne "") { + $o->ask_okcancel(N("Last Chance"), N("Partition table Type of this drive %s is going to be written to disk", $_->{device}, 0)) or return 1; + eval { + run_program::run("parted", "/dev/$_->{device}", "mklabel", $selection{$_}, "--script"); + log::l("selectPartitionTable: parted to mklabel $selection{$_}"); + $reboot = 1; + }; + if (my $err = $@) { + if ($err =~ /Error/i) { + log::l("selectPartitionTable: error to switch /dev/$_->{device} to $selection{$_}"); + } else { + log::l("selectPartitionTable: Partition Table %s for /dev/%s", $selection{$_}, $_->{device}); + } + } + } else { + log::l("selectPartitionTable: Dont touch Partition Table for /dev/%s", $_->{device}); + } + } @bigdrives; + 0; + }, + ); + } + if ($reboot eq "1") { + $o->ask_warn('', N("Rebooting now, to update partition table table and avoid errors.")); + install::steps::rebootNeeded($o); + } + install::steps::selectPartitionTable($o); +} + #------------------------------------------------------------------------------ sub selectInstallClass { my ($o) = @_; diff --git a/perl-install/install/steps_list.pm b/perl-install/install/steps_list.pm index 245ff9f8e..f8cf73d36 100644 --- a/perl-install/install/steps_list.pm +++ b/perl-install/install/steps_list.pm @@ -21,6 +21,7 @@ use common; selectInstallClass => [ N_("_: Keep these entry short\nInstallation class"), 1, 1, '1', '', N_("_: Keep these entry short\nInstallation class") ], selectKeyboard => [ N_("_: Keep these entry short\nKeyboard"), 1, 1, '1', '', N_("Localization") ], + selectPartitionTable => [ N_("_: Keep these entry short\nPartitionTable"), 1, 1, '1', '', N_("PartitionTable") ], miscellaneous => [ N_("_: Keep these entry short\nSecurity"), 1, 1, '1', '', N_("Security") ], doPartitionDisks => [ N_("_: Keep these entry short\nPartitioning"), 1, 0, '', "selectInstallClass", N_("Partitioning") ], -- cgit v1.2.1