diff options
author | Colin Guthrie <colin@mageia.org> | 2013-05-10 08:53:27 +0000 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2013-05-10 08:53:27 +0000 |
commit | 322b85c5b8762378f7f9362794004bed6fd1d179 (patch) | |
tree | 25f619b5b0eafcc325de8a3c5fcb73e464b5776d | |
parent | 1d39b99ec43bfd0788522ab9e03ae4dbb1aa792c (diff) | |
download | mgaonline-322b85c5b8762378f7f9362794004bed6fd1d179.tar mgaonline-322b85c5b8762378f7f9362794004bed6fd1d179.tar.gz mgaonline-322b85c5b8762378f7f9362794004bed6fd1d179.tar.bz2 mgaonline-322b85c5b8762378f7f9362794004bed6fd1d179.tar.xz mgaonline-322b85c5b8762378f7f9362794004bed6fd1d179.zip |
upgrade-helper: Move the code to a sub (no functional change)
-rwxr-xr-x | mgaapplet-upgrade-helper | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/mgaapplet-upgrade-helper b/mgaapplet-upgrade-helper index f06dade4..7c4286c9 100755 --- a/mgaapplet-upgrade-helper +++ b/mgaapplet-upgrade-helper @@ -62,42 +62,7 @@ $root = Rpmdrake::open_db::fast_open_urpmi_db()->{root}; read_sys_config(); my $product_id = get_product_id(); -# Find the matching new_distro_version -my @distros = get_distro_list(); -if (!@distros) { - ugtk2::ask_warn(N("Error"), N("Unable to download distro list")); - die("unable to retrieve distro list\n"); -} - -my $new_distro = find { $_->{version} eq $new_distro_version } @distros; -if (!$new_distro) { - ugtk2::ask_warn(N("Error"), N("Distribution version %s was not found in the update list", $new_distro_version)); - die("could not find version '$new_distro_version' in the distro update list\n"); -} - -if ($new_distro->{needs_preparation}) { - my $statefile = "$root/var/lib/mageia-prepare-upgrade/state"; - my $prepared = -f $statefile && cat_($statefile) =~ /ready/; - - if (!$prepared) { - ugtk2::ask_yesorno(N("Preparation Required"), N("In order to upgrade, your current installation needs to be prepared.\n\nDo you wish to do this preparation now?")) or exit(0); - - my $in = interactive->vnew; - my $do_pkgs = do_pkgs::do_pkgs($in); - $do_pkgs->ensure_is_installed("mageia-prepare-upgrade") or exit(0); - - # Check to see if installation alone is enough to ensure things are in the right state? - $prepared = -f $statefile && cat_($statefile) =~ /ready/; - if (!$prepared) { - my $infofile = "$root/usr/share/doc/mageia-prepare-upgrade/README.prepare"; - my $info = -f $infofile && ugtk2::escape_text_for_TextView_markup_format(join('', cat_($infofile))); - $info ||= N("Further action is required before you can continue.\n\nPlease see %s for more information.", $new_distro->{url}); - ugtk2::ask_warn(N("Next Steps"), $info); - exit(0) if !$::testing; - log::l("I would validate /var/lib/mageia-prepare-upgrade/state == 'ready'"); - } - } -} +check_preparation(); if (!$ENV{URPMI_IGNORESIZE}) { check_available_free_space('/usr', 800) && @@ -201,6 +166,45 @@ sub create_upgrade_succeeded_window() { return $w; } +sub check_preparation() { + # Find the matching new_distro_version + my @distros = get_distro_list(); + if (!@distros) { + ugtk2::ask_warn(N("Error"), N("Unable to download distro list")); + die("unable to retrieve distro list\n"); + } + + my $new_distro = find { $_->{version} eq $new_distro_version } @distros; + if (!$new_distro) { + ugtk2::ask_warn(N("Error"), N("Distribution version %s was not found in the update list", $new_distro_version)); + die("could not find version '$new_distro_version' in the distro update list\n"); + } + + if ($new_distro->{needs_preparation}) { + my $statefile = "$root/var/lib/mageia-prepare-upgrade/state"; + my $prepared = -f $statefile && cat_($statefile) =~ /ready/; + + if (!$prepared) { + ugtk2::ask_yesorno(N("Preparation Required"), N("In order to upgrade, your current installation needs to be prepared.\n\nDo you wish to do this preparation now?")) or exit(0); + + my $in = interactive->vnew; + my $do_pkgs = do_pkgs::do_pkgs($in); + $do_pkgs->ensure_is_installed("mageia-prepare-upgrade") or exit(0); + + # Check to see if installation alone is enough to ensure things are in the right state? + $prepared = -f $statefile && cat_($statefile) =~ /ready/; + if (!$prepared) { + my $infofile = "$root/usr/share/doc/mageia-prepare-upgrade/README.prepare"; + my $info = -f $infofile && ugtk2::escape_text_for_TextView_markup_format(join('', cat_($infofile))); + $info ||= N("Further action is required before you can continue.\n\nPlease see %s for more information.", $new_distro->{url}); + ugtk2::ask_warn(N("Next Steps"), $info); + exit(0) if !$::testing; + log::l("I would validate /var/lib/mageia-prepare-upgrade/state == 'ready'"); + } + } + } +} + sub upgrade() { my $xid = gtkroot()->XWINDOW; |