summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2013-05-17 12:35:10 +0000
committerThierry Vignaud <tv@mageia.org>2013-05-17 12:35:10 +0000
commit2b0c898bec008dee6e725da8348a98a9f8579fd3 (patch)
tree2917bcdfdf9b795ad9ca7386f51715bf6c8c9399
parent342c51b281dac91d3bb95bcf0d9fd4b36d14982a (diff)
downloadurpmi-2b0c898bec008dee6e725da8348a98a9f8579fd3.tar
urpmi-2b0c898bec008dee6e725da8348a98a9f8579fd3.tar.gz
urpmi-2b0c898bec008dee6e725da8348a98a9f8579fd3.tar.bz2
urpmi-2b0c898bec008dee6e725da8348a98a9f8579fd3.tar.xz
urpmi-2b0c898bec008dee6e725da8348a98a9f8579fd3.zip
auto enable nonfree/taitned media if needed when adding distrib media
-rw-r--r--NEWS1
-rw-r--r--urpm/media.pm20
2 files changed, 18 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 9ee4d3a3..96795d0d 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@
o do not popup errors at end in auto mode
- library (mga#8368, #8379 & #9758):
o enable to see if nonfree/tainted packages are installed
+ o auto enable nonfree/tainted media if needed when adding distrib media
Version 7.26 - 2 May 2013, by Thierry Vignaud
diff --git a/urpm/media.pm b/urpm/media.pm
index 5adb67d4..2ef9d911 100644
--- a/urpm/media.pm
+++ b/urpm/media.pm
@@ -5,7 +5,7 @@ package urpm::media;
use strict;
use urpm qw(file_from_local_medium is_local_medium);
use urpm::msg;
-use urpm::util qw(any append_to_file basename cat_ difference2 dirname member output_safe begins_with copy_and_own file_size offset_pathname reduce_pathname);
+use urpm::util qw(any append_to_file basename cat_ difference2 dirname intersection member output_safe begins_with copy_and_own file_size offset_pathname reduce_pathname);
use urpm::removable;
use urpm::lock;
use urpm::md5sum;
@@ -777,7 +777,7 @@ sub needed_extra_media {
}
sub is_media_to_add_by_default {
- my ($urpm, $distribconf, $medium, $product_id) = @_;
+ my ($urpm, $distribconf, $medium, $product_id, $nonfree, $tainted) = @_;
my $add_by_default = !$distribconf->getvalue($medium, 'noauto');
my @media_types = split(':', $distribconf->getvalue($medium, 'media_type'));
if ($product_id->{product} eq 'Free') {
@@ -785,6 +785,19 @@ sub is_media_to_add_by_default {
$urpm->{log}(N("ignoring non-free medium `%s'", $medium));
$add_by_default = 0;
}
+ } else {
+ my $non_regular_medium = intersection(\@media_types, [ qw(backports debug source testing) ]);
+ if (!$add_by_default && !$non_regular_medium) {
+ my $medium_name = $distribconf->getvalue($medium, 'name') || '';
+ if ($medium_name =~ /Nonfree/ && $nonfree) {
+ $add_by_default = 1;
+ $urpm->{log}(N("un-ignoring non-free medium `%s' b/c nonfree packages are installed", $medium_name));
+ }
+ if ($medium_name =~ /Nonfree/ && $tainted) {
+ $add_by_default = 1;
+ $urpm->{log}(N("un-ignoring tainted medium `%s' b/c tainted packages are installed", $medium_name));
+ }
+ }
}
$add_by_default;
}
@@ -1125,6 +1138,7 @@ sub add_distrib_media {
require urpm::mirrors;
my $product_id = urpm::mirrors::parse_LDAP_namespace_structure(cat_('/etc/product.id'));
+ my ($nonfree, $tainted) = needed_extra_media($urpm);
foreach my $media ($distribconf->listmedia) {
my $media_name = $distribconf->getvalue($media, 'name') || '';
@@ -1142,7 +1156,7 @@ sub add_distrib_media {
$is_update_media or next;
}
- my $add_by_default = is_media_to_add_by_default($urpm, $distribconf, $media, $product_id);
+ my $add_by_default = is_media_to_add_by_default($urpm, $distribconf, $media, $product_id, $nonfree, $tainted);
my $ignore;
if ($options{ask_media}) {