diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-06-18 09:28:22 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2004-06-18 09:28:22 +0000 |
commit | 5ad43fb7b274deeffadae230f84c08ccbd6db33f (patch) | |
tree | 41369ffbb4c3a4afcba710d500817a3675ca7175 | |
parent | 475292bfc5e70d938410dd2ef5e7d0f0c101ea9f (diff) | |
download | rpmdrake-5ad43fb7b274deeffadae230f84c08ccbd6db33f.tar rpmdrake-5ad43fb7b274deeffadae230f84c08ccbd6db33f.tar.gz rpmdrake-5ad43fb7b274deeffadae230f84c08ccbd6db33f.tar.bz2 rpmdrake-5ad43fb7b274deeffadae230f84c08ccbd6db33f.tar.xz rpmdrake-5ad43fb7b274deeffadae230f84c08ccbd6db33f.zip |
When rpmdrake detects a media that looks like an update media added
by the installation, it now checks whether it corresponds to the current
Mandrakelinux release, and if it doesn't, it disables the media.
Probably still a bit rough.
-rwxr-xr-x | rpmdrake | 44 | ||||
-rw-r--r-- | rpmdrake.pm | 75 |
2 files changed, 91 insertions, 28 deletions
@@ -400,8 +400,7 @@ sub run_treeview_dialog { my (undef, $size_free) = MDK::Common::System::df('/usr'); $::noBorder = 1; - (my $mdk_version) = (cat_('/etc/mandrake-release') || '') =~ /(\d+\.\d+)/; - $w = ugtk2->new(N("Rpmdrake %s", $mdk_version || '')); + $w = ugtk2->new(N("Rpmdrake %s", $rpmdrake::mdk_version || '')); $::noBorder = 0; my $formatlistpkg = sub { myformatList(sort { uc($a) cmp uc($b) } @_) }; @@ -853,23 +852,29 @@ or you already installed all of them.")); $MODE ne 'remove' and push @menu_treeview_actions, [ 'update_sources', N("Update media") ]; foreach (@menu_treeview_actions) { my ($action, $text) = @$_; - my %action2fun; %action2fun = ( - reset_selection => sub { - if ($MODE ne 'remove') { - $urpm->disable_selected(db(), $urpm->{state}, - map { if_($pkgs->{$_}{selected}, $pkgs->{$_}{pkg}) } keys %$pkgs); - } - $pkgs->{$_}{selected} = 0 foreach keys %$pkgs; - $size_selected = 0; - $options->{rebuild_tree}->(); - }, - reload_pkg => sub { - ($urpm, $pkgs, $descriptions) = $pkgs_provider->({ skip_updating_mu => 1 }); - $size_selected = 0; - $options->{rebuild_tree}->(); - }, - update_sources => sub { update_sources_interactive($urpm, transient => $w->{rwindow}) - and $action2fun{reload_pkg}->() }); + my %action2fun; + %action2fun = ( + reset_selection => sub { + if ($MODE ne 'remove') { + $urpm->disable_selected( + db(), $urpm->{state}, + map { if_($pkgs->{$_}{selected}, $pkgs->{$_}{pkg}) } keys %$pkgs + ); + } + $pkgs->{$_}{selected} = 0 foreach keys %$pkgs; + $size_selected = 0; + $options->{rebuild_tree}->(); + }, + reload_pkg => sub { + ($urpm, $pkgs, $descriptions) = $pkgs_provider->({ skip_updating_mu => 1 }); + $size_selected = 0; + $options->{rebuild_tree}->(); + }, + update_sources => sub { + update_sources_interactive($urpm, transient => $w->{rwindow}) + and $action2fun{reload_pkg}->(); + } + ); $menu_treeview->append(gtksignal_connect(gtkshow(Gtk2::MenuItem->new_with_label($text)), activate => sub { $action2fun{$action}->() })); } $tree->signal_connect(button_press_event => sub { $_[1]->button == 3 or return 0; @@ -1092,6 +1097,7 @@ Then, restart MandrakeUpdate.")), myexit(-1); $urpm->configure(media => $media); @update_medias = grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}}; + check_update_media_version($urpm, @update_medias); $urpm->compute_installed_flags(db()); diff --git a/rpmdrake.pm b/rpmdrake.pm index 1a49956e..c630f3a4 100644 --- a/rpmdrake.pm +++ b/rpmdrake.pm @@ -37,11 +37,46 @@ use c; use curl_download; @ISA = qw(Exporter); -@EXPORT = qw($configfile %config $mandrakeupdate_wanted_categories $already_splashed $max_info_in_descr $tree_mode $tree_flat $typical_width - N N_ translate to_utf8 myexit readconf writeconf interactive_msg interactive_packtable interactive_list fatal_msg - wait_msg remove_wait_msg but but_ slow_func mirrors choose_mirror make_url_mirror show_urpm_progress - update_sources update_sources_interactive add_medium_and_check); - +@EXPORT = qw( + $configfile + %config + $mandrakeupdate_wanted_categories + $already_splashed + $max_info_in_descr + $tree_mode + $tree_flat + $typical_width + N + N_ + translate + to_utf8 + myexit + readconf + writeconf + interactive_msg + interactive_packtable + interactive_list + fatal_msg + wait_msg + remove_wait_msg + but + but_ + slow_func + mirrors + choose_mirror + make_url_mirror + show_urpm_progress + update_sources + update_sources_interactive + add_medium_and_check + check_update_media_version +); + + +our $mandrake_release = cat_( + -e '/etc/mandrakelinux-release' ? '/etc/mandrakelinux-release' : '/etc/mandrake-release' +) || ''; +(our $mdk_version) = $mandrake_release =~ /(\d+\.\d+)/; eval { require ugtk2; ugtk2->import(qw(:all)) }; if ($@) { @@ -311,8 +346,8 @@ my %sites2countries = ('proxad.net' => 'fr', sub distro_type { - cat_('/etc/mandrake-release') =~ /community/i ? 'community' - : cat_('/etc/mandrake-release') =~ /cooker/i ? 'cooker' + $mandrake_release =~ /community/i ? 'community' + : $mandrake_release =~ /cooker/i ? 'cooker' : 'updates'; } @@ -413,7 +448,7 @@ sub make_url_mirror { #- esp. for distro_type() =~ /cooker|community/ "$mirror/"; } else { - my ($class, $release) = cat_('/etc/mandrake-release') =~ /(\S+)\s+release\s+(\S+)/; + my ($class, $release) = $mandrake_release =~ /(\S+)\s+release\s+(\S+)/; $class !~ /linux/i and $release = lc($class) . "/$release"; #- handle subdirectory for corporate/clustering/etc "$mirror/$release/RPMS/"; } @@ -536,7 +571,8 @@ sub update_sources_interactive { ) ); if ($w->main) { - foreach (@{$urpm->{media}}) { #- force ignored media to be returned alive (forked from urpmi.updatemedia...) + #- force ignored media to be returned alive (forked from urpmi.updatemedia...) + foreach (@{$urpm->{media}}) { $_->{modified} and delete $_->{ignore}; } standalone::explanations("Updating media @media"); @@ -589,3 +625,24 @@ sub add_medium_and_check { return 0; } +#- Check whether the default update media (added by installation) +#- matches the current mdk version +sub check_update_media_version { + my $urpm = shift; + for (@_) { + if ($_->{name} =~ /(\d+\.\d+).*\bftp\du\b/ && $1 ne $mdk_version) { + interactive_msg( + 'rpmdrake', + N("Your medium `%s', used for updates, does not match the version of Mandrakelinux you're running (%s). +It will be disabled.", + $_->{name}, $mdk_version), + ); + $_->{ignore} = 1; + $urpm->write_config if -w $urpm->{config}; + return 0; + } + } + 1; +} + +1; |