diff options
author | Colin Guthrie <colin@mageia.org> | 2013-04-28 19:24:46 +0000 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2013-04-28 19:24:46 +0000 |
commit | 227a5089a0537e17628a34329488539f3d476318 (patch) | |
tree | 5394756b2f5e235ebeede1996d80358451904acc | |
parent | cb2c9b0a1d21a754e0f39d82ebb82d6bbecd6d47 (diff) | |
download | mgaonline-227a5089a0537e17628a34329488539f3d476318.tar mgaonline-227a5089a0537e17628a34329488539f3d476318.tar.gz mgaonline-227a5089a0537e17628a34329488539f3d476318.tar.bz2 mgaonline-227a5089a0537e17628a34329488539f3d476318.tar.xz mgaonline-227a5089a0537e17628a34329488539f3d476318.zip |
Add support for upgrades that need some form of preparation before continuing.
The basic principle of this is to do the following:
1. Check the releases webservice API to see if the distro version 'needs_preparation'.
2. If it does, check for a file /var/lib/mageia-prepare-upgrade/state.
If it says 'ready' then we are ready and the user is not questioned further.
3. If it does not exist or says anything else, the user is prompted to install the
package 'mageia-prepare-upgrade'.
4. After package installation, check the state file again as this may be
all that is required. If the state file does not yet say 'ready', then
display the text from the /usr/share/doc/mageia-prepare-upgrade/README.prepare
file (todo: add i18n)
5. Assuming that further action is required by the user (e.g. rebooting to
convert the filesystem), then the upgrade helper will exit.
6. After the user has taken the action required to do the preparation,
the state file should contain 'ready'. The next time the distro upgrade
dialog shows, the preparation checks will pass and the user can continue.
TODO:
Handle i18n in the README.prepare file.
v1: First Revision
v2: Check immediately if an upgrade state file exists (don't wait 5 mins)
Ensure config file is parsed (ensures the testing variable is read)
Show user-visible messages when bailing out due to unexpected errors
-rw-r--r-- | NEWS | 2 | ||||
-rwxr-xr-x | mgaapplet | 16 | ||||
-rwxr-xr-x | mgaapplet-upgrade-helper | 40 | ||||
-rw-r--r-- | mgaonline.pm | 2 |
4 files changed, 51 insertions, 9 deletions
@@ -1,3 +1,5 @@ +- add support for a 'mageia-prepare-upgrade' package when performing distro + upgrades - do not define the $root variable in mgaapplet-upgrade-helper as it's exported from mgaonline.pm - exit early from mgaapplet-upgrade-helper if we don't pass expected/required @@ -53,10 +53,16 @@ if (!find { $_ eq '--auto-update' } @ARGV) { my $online_site = "http://www.mageia.org/"; my ($menu, $timeout, $network_timeout, $state_global, $sub_state); +my ($download_dir); +{ + my $temp_urpm = Rpmdrake::open_db::fast_open_urpmi_db(); + $root = $temp_urpm->{root}; + $download_dir = $temp_urpm->{cachedir}; +} read_sys_config(); $config{UPDATE_FREQUENCY} ||= 3*60*60; # default to 3hours -if ($::testing) { +if ($::testing || -f "$root/var/lib/mageia-prepare-upgrade/state") { $config{FIRST_CHECK_DELAY} = 1 * 1000; # 1 second } else { $config{FIRST_CHECK_DELAY} ||= 5 * 60 * 1000; # default to 5 minutes @@ -226,13 +232,7 @@ foreach my $opt (@ARGV) { } } -my ($download_dir, $download_all); -{ - my $temp_urpm = Rpmdrake::open_db::fast_open_urpmi_db(); - $root = $temp_urpm->{root}; - $download_dir = $temp_urpm->{cachedir}; -} - +my ($download_all); my ($new_distro, $no_more_supported); my ($current_apimdv_distro); diff --git a/mgaapplet-upgrade-helper b/mgaapplet-upgrade-helper index 02cc37dd..d5c32a71 100755 --- a/mgaapplet-upgrade-helper +++ b/mgaapplet-upgrade-helper @@ -33,6 +33,8 @@ BEGIN { unshift @::textdomains, 'mgaonline' } use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 version use ugtk2 qw(:all); +use interactive; +use do_pkgs; use lib qw(/usr/lib/libDrakX/drakfirsttime); use mgaonline; use Rpmdrake::open_db; @@ -57,8 +59,46 @@ die("Usage: mgaapplet-upgrade-helper --new_distro_version=n [--rpm-root-dir] [-- $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 = (cat_($statefile) =~ /ready/) if ( -f $statefile ); + + 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 = (cat_($statefile) =~ /ready/) if ( -f $statefile ); + if (!$prepared) { + my $infofile = "$root/usr/share/doc/mageia-prepare-upgrade/README.prepare"; + my $info = ugtk2::escape_text_for_TextView_markup_format(join '', cat_($infofile)) if ( -f $infofile ); + $info = N("Further action is required before you can continue.\n\nPlease see %s for more information.", $new_distro->{url}) if !$info; + ugtk2::ask_warn(N("Next Steps"), $info); + exit(0) if !$::testing; + log::l("I would validate /var/lib/mageia-prepare-upgrade/state == 'ready'"); + } + } +} + if (!$ENV{URPMI_IGNORESIZE}) { check_available_free_space('/usr', 800) && check_available_free_space('/var', 800) diff --git a/mgaonline.pm b/mgaonline.pm index ff64b624..9288db11 100644 --- a/mgaonline.pm +++ b/mgaonline.pm @@ -92,7 +92,7 @@ sub get_distro_list_() { my $extra_path = $::testing || uc($config{TEST_DISTRO_UPGRADE}) eq 'YES' ? 'testing-' : ''; my $list = join('&', - "https://releases.mageia.org/api/a/$extra_path$product_id->{arch}?product=$product_id->{product}", + "https://releases.mageia.org/api/b/$extra_path$product_id->{arch}?product=$product_id->{product}", "version=$product_id->{version}", "mgaonline_version=$mgaonline::version", ); |