diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-12-04 16:31:46 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-12-04 16:31:46 +0000 |
commit | 2addf97d11faf5d819ccc4820f83a783d5d5bd91 (patch) | |
tree | 481349e8b8392d90da6ce05c862f4a926efa22d5 | |
parent | ec329cc4150b3db24c196c46b5e84d38a3a98259 (diff) | |
download | drakx-2addf97d11faf5d819ccc4820f83a783d5d5bd91.tar drakx-2addf97d11faf5d819ccc4820f83a783d5d5bd91.tar.gz drakx-2addf97d11faf5d819ccc4820f83a783d5d5bd91.tar.bz2 drakx-2addf97d11faf5d819ccc4820f83a783d5d5bd91.tar.xz drakx-2addf97d11faf5d819ccc4820f83a783d5d5bd91.zip |
- diskdrake:
o drop "Undo", "Restore partition table", "Save partition table"
(preparing to switch to libparted)
-rw-r--r-- | perl-install/NEWS | 2 | ||||
-rw-r--r-- | perl-install/diskdrake/hd_gtk.pm | 2 | ||||
-rw-r--r-- | perl-install/diskdrake/interactive.pm | 85 | ||||
-rw-r--r-- | perl-install/install/NEWS | 3 | ||||
-rw-r--r-- | perl-install/partition_table.pm | 38 |
5 files changed, 9 insertions, 121 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS index 3fa9e8bb7..c49134e60 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -10,6 +10,8 @@ o handle "root (hd...)" for menu.lst entries (#23591) (nb: when writing, "root ..." will not be used) - diskdrake: + o drop "Undo", "Restore partition table", "Save partition table" + (preparing to switch to libparted) o fix garbaged error messages when umounting fs o disallow "Use for loopback" when the partition used for loopback is not formatted (#35535) diff --git a/perl-install/diskdrake/hd_gtk.pm b/perl-install/diskdrake/hd_gtk.pm index b6c1d7565..d98049aa2 100644 --- a/perl-install/diskdrake/hd_gtk.pm +++ b/perl-install/diskdrake/hd_gtk.pm @@ -108,8 +108,6 @@ sub try { sub try_ { my ($name, $f, @args) = @_; - diskdrake::interactive::undo_prepare($all_hds) if $name ne 'Undo'; - my $v = eval { $f->($in, @args, $all_hds) }; if (my $err = $@) { $in->ask_warn(N("Error"), formatError($err)); diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index fa887949f..62e872519 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -128,7 +128,6 @@ struct hd { bool getting_rid_of_readonly_allowed # is it forbidden to write because the partition table is badly handled, or is it because we MUST not change the partition table bool isDirty # does it need to be written to the disk list will_tell_kernel # list of actions to tell to the kernel so that it knows the new partition table - bool hasBeenDirty # for undo bool rebootNeeded # happens when a kernel reread failed list partitionsRenumbered # happens when you # - remove an extended partition which is not the last one @@ -160,7 +159,7 @@ struct raw_hd inherits hd { string mntpoint # '/', '/usr' ... string options # 'defaults', 'noauto' - # invalid: isDirty, will_tell_kernel, hasBeenDirty, rebootNeeded, primary, extended + # invalid: isDirty, will_tell_kernel, rebootNeeded, primary, extended } struct all_hds { @@ -255,13 +254,7 @@ sub main { ################################################################################ sub general_possible_actions { my ($_in, $_all_hds) = @_; - N_("Undo"), ($::expert ? N_("Toggle to normal mode") : N_("Toggle to expert mode")); -} - - -sub Undo { - my ($_in, $all_hds) = @_; - undo($all_hds); + $::expert ? N_("Toggle to normal mode") : N_("Toggle to expert mode"); } sub Done { @@ -306,7 +299,7 @@ sub hd_possible_actions { ( if_(!$hd->{readonly} || $hd->{getting_rid_of_readonly_allowed}, N_("Clear all")), if_(!$hd->{readonly} && $::isInstall, N_("Auto allocate")), - N_("More"), + if_($::isInstall, N_("More")), ); } sub hd_possible_actions_interactive { @@ -356,58 +349,11 @@ sub More { my $r; $in->ask_from(N("More"), '', [ - { val => N("Save partition table"), clicked_may_quit => sub { SaveInFile($in, $hd); 1 } }, - { val => N("Restore partition table"), clicked_may_quit => sub { ReadFromFile($in, $hd); 1 } }, - if_($::isInstall, - { val => N("Reload partition table"), clicked_may_quit => sub { $r = 'force_reload'; 1 } }), + { val => N("Reload partition table"), clicked_may_quit => sub { $r = 'force_reload'; 1 } }, ], ) && $r; } -sub ReadFromFile { - my ($in, $hd) = @_; - - my ($h, $file, $fh); - if ($::isStandalone) { - $file = $in->ask_filename({ title => N("Select file") }) or return; - } else { - undef $h; #- help perl_checker - my $name = $hd->{device}; $name =~ s!/!_!g; - ($h, $fh) = install::any::media_browser($in, '', "part_$name") or return; - } - - eval { - catch_cdie { partition_table::load($hd, $file || $fh) } - sub { - $@ =~ /bad totalsectors/ or return; - $in->ask_yesorno(N("Warning"), -N("The backup partition table has not the same size -Still continue?"), 0); - }; - }; - if (my $err = $@) { - $in->ask_warn(N("Error"), formatError($err)); - } -} - -sub SaveInFile { - my ($in, $hd) = @_; - - my ($h, $file) = ('', ''); - if ($::isStandalone) { - $file = $in->ask_filename({ save => 1, title => N("Select file") }) or return; - } else { - undef $h; #- help perl_checker - my $name = $hd->{device}; $name =~ s!/!_!g; - ($h, $file) = install::any::media_browser($in, 'save', "part_$name") or return; - } - - eval { partition_table::save($hd, $file) }; - if (my $err = $@) { - $in->ask_warn(N("Error"), formatError($err)); - } -} - sub Hd_info { my ($in, $hd) = @_; $in->ask_warn(N("Warning"), [ N("Detailed information"), format_hd_info($hd) ]); @@ -1381,26 +1327,3 @@ sub update_bootloader_for_renumbered_partitions { require bootloader; bootloader::update_for_renumbered_partitions($in, \@renumbering, $all_hds); } - -sub undo_prepare { - my ($all_hds) = @_; - require Data::Dumper; - $Data::Dumper::Purity = 1; - foreach (@{$all_hds->{hds}}) { - my @h = @$_{@partition_table::fields2save}; - push @{$_->{undo}}, Data::Dumper->Dump([\@h], ['$h']); - } -} -sub undo { - my ($all_hds) = @_; - foreach (@{$all_hds->{hds}}) { - my $code = pop @{$_->{undo}} or next; - my $h; eval $code; - @$_{@partition_table::fields2save} = @$h; - - if ($_->{hasBeenDirty}) { - partition_table::will_tell_kernel($_, 'force_reboot'); #- next action needing write_partitions will force it. We can not do it now since more undo may occur, and we must not needReboot now - } - } - -} diff --git a/perl-install/install/NEWS b/perl-install/install/NEWS index de7540ed1..2b59f0c31 100644 --- a/perl-install/install/NEWS +++ b/perl-install/install/NEWS @@ -1,3 +1,6 @@ +- diskdrake: + o drop "Undo", "Restore partition table", "Save partition table" + (preparing to switch to libparted) - don't check /proc/partitions for a partition_table::lvm (ie PV on non partitioned drive) diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index 590365536..752fe7088 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -9,8 +9,6 @@ use partition_table::raw; use detect_devices; use log; -our @fields2save = qw(primary extended totalsectors isDirty will_tell_kernel); - sub hd2minimal_part { my ($hd) = @_; @@ -437,7 +435,6 @@ sub write { } } $hd->{isDirty} = 0; - $hd->{hasBeenDirty} = 1; #- used in undo (to know if undo should believe isDirty or not) if (my $tell_kernel = delete $hd->{will_tell_kernel}) { if (fs::type::is_dmraid($hd)) { @@ -604,39 +601,4 @@ sub next_start { $next ? $next->{start} : $hd->last_usable_sector; } -sub load { - my ($hd, $file, $b_force) = @_; - - my $F = ref $file ? $file : common::open_file($file) || die N("Error reading file %s", $file); - - my $h; - { - local $/ = "\0"; - eval <$F>; - } - $@ and die N("Restoring from file %s failed: %s", $file, $@); - - ref($h) eq 'ARRAY' or die N("Bad backup file"); - - my %h; @h{@fields2save} = @$h; - - $h{totalsectors} == $hd->{totalsectors} or $b_force or cdie "bad totalsectors"; - - #- unsure we do not modify totalsectors - local $hd->{totalsectors}; - - @$hd{@fields2save} = @$h; - - delete @$_{qw(isMounted isFormatted notFormatted toFormat toFormatUnsure)} foreach get_normal_parts($hd); - will_tell_kernel($hd, 'force_reboot'); #- just like undo, do not force write_partitions so that user can see the new partition table but can still discard it -} - -sub save { - my ($hd, $file) = @_; - my @h = @$hd{@fields2save}; - require Data::Dumper; - eval { output($file, Data::Dumper->Dump([\@h], ['$h']), "\0") } - or die N("Error writing to file %s", $file); -} - 1; |