From 794534f38765fac0f3a63b1a274d2ad7ac9b0fc1 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sat, 17 Sep 2011 09:22:15 +0000 Subject: (_try_to_upgrade,_prepare_upgrade) split them out of selectInstallClass() for readability --- perl-install/install/steps_interactive.pm | 94 +++++++++++++++++-------------- 1 file changed, 51 insertions(+), 43 deletions(-) (limited to 'perl-install/install/steps_interactive.pm') diff --git a/perl-install/install/steps_interactive.pm b/perl-install/install/steps_interactive.pm index a1376cfaf..e4926cb09 100644 --- a/perl-install/install/steps_interactive.pm +++ b/perl-install/install/steps_interactive.pm @@ -132,56 +132,64 @@ sub selectInstallClass { my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch(); @l = grep { $_->{arch} eq $arch } @l; if (@l) { + _try_to_upgrade($o, @l); + } +} - log::l("proposing to upgrade partitions " . join(" ", map { $_->{part} && $_->{part}{device} } @l)); - - my @releases = uniq(map { "$_->{release} $_->{version}" } @l); - if (@releases != @l) { - #- same release name so adding the device to differentiate them: - $_->{release} .= " ($_->{part}{device})" foreach @l; - } +sub _try_to_upgrade { + my ($o, @l) = @_; + log::l("proposing to upgrade partitions " . join(" ", map { $_->{part} && $_->{part}{device} } @l)); - askInstallClass: - my $p; - $o->ask_from_({ title => N("Install/Upgrade"), - interactive_help_id => 'selectInstallClass', - }, - [ - { label => N("Is this an install or an upgrade?"), title => 1 }, - { val => \$p, - list => [ @l, N_("_: This is a noun:\nInstall") ], - type => 'list', - format => sub { ref($_[0]) ? N("Upgrade %s", "$_[0]->{release} $_[0]->{version}") : translate($_[0]) } - } ]); - if (ref $p) { - _check_unsafe_upgrade_and_warn($o, $p->{part}) or $p = undef; - } + my @releases = uniq(map { "$_->{release} $_->{version}" } @l); + if (@releases != @l) { + #- same release name so adding the device to differentiate them: + $_->{release} .= " ($_->{part}{device})" foreach @l; + } - if (ref $p) { + askInstallClass: + my $p; + $o->ask_from_({ title => N("Install/Upgrade"), + interactive_help_id => 'selectInstallClass', + }, + [ + { label => N("Is this an install or an upgrade?"), title => 1 }, + { val => \$p, + list => [ @l, N_("_: This is a noun:\nInstall") ], + type => 'list', + format => sub { ref($_[0]) ? N("Upgrade %s", "$_[0]->{release} $_[0]->{version}") : translate($_[0]) } + } ]); + if (ref $p) { + _check_unsafe_upgrade_and_warn($o, $p->{part}) or $p = undef; + } - if ($p->{part}) { - log::l("choosing to upgrade partition $p->{part}{device}"); - $o->{migrate_device_names} = install::any::use_root_part($o->{all_hds}, $p->{part}, $o); - } + if (ref $p) { + _prepare_upgrade($o, $p); + } +} - #- handle encrypted partitions (esp. /home) - foreach (grep { $_->{mntpoint} } @{$o->{fstab}}) { - my ($options, $_unknown) = fs::mount_options::unpack($_); - $options->{encrypted} or next; - $o->ask_from_({ focus_first => 1 }, - [ { label => N("Encryption key for %s", $_->{mntpoint}), - hidden => 1, val => \$_->{encrypt_key} } ]); - } +sub _prepare_upgrade { + my ($o, $p) = @_; + if ($p->{part}) { + log::l("choosing to upgrade partition $p->{part}{device}"); + $o->{migrate_device_names} = install::any::use_root_part($o->{all_hds}, $p->{part}, $o); + } - $o->{previous_release} = $p; - $o->{isUpgrade} = (find { $p->{release_file} =~ /$_/ } 'mageia', 'mandriva', 'mandrake', 'conectiva', 'redhat') || 'unknown'; - $o->{upgrade_by_removing_pkgs_matching} ||= { - conectiva => 'cl', - redhat => '.', #- everything! - }->{$o->{isUpgrade}}; - log::l("upgrading $o->{isUpgrade} distribution" . ($o->{upgrade_by_removing_pkgs_matching} ? " (upgrade_by_removing_pkgs_matching $o->{upgrade_by_removing_pkgs_matching})" : '')); - } + #- handle encrypted partitions (esp. /home) + foreach (grep { $_->{mntpoint} } @{$o->{fstab}}) { + my ($options, $_unknown) = fs::mount_options::unpack($_); + $options->{encrypted} or next; + $o->ask_from_({ focus_first => 1 }, + [ { label => N("Encryption key for %s", $_->{mntpoint}), + hidden => 1, val => \$_->{encrypt_key} } ]); } + + $o->{previous_release} = $p; + $o->{isUpgrade} = (find { $p->{release_file} =~ /$_/ } 'mageia', 'mandriva', 'mandrake', 'conectiva', 'redhat') || 'unknown'; + $o->{upgrade_by_removing_pkgs_matching} ||= { + conectiva => 'cl', + redhat => '.', #- everything! + }->{$o->{isUpgrade}}; + log::l("upgrading $o->{isUpgrade} distribution" . ($o->{upgrade_by_removing_pkgs_matching} ? " (upgrade_by_removing_pkgs_matching $o->{upgrade_by_removing_pkgs_matching})" : '')); } sub _check_unsafe_upgrade_and_warn { -- cgit v1.2.1