summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-02-21 09:57:49 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-02-21 09:57:49 +0000
commit30d7067c0fd184956ca5f866e7903c6fa241717f (patch)
tree62b1f864c823295ee0d6a083ef04000573455621
parent80828e3ac6e7203d62a7004d465037c22bbe4bda (diff)
downloadurpmi-30d7067c0fd184956ca5f866e7903c6fa241717f.tar
urpmi-30d7067c0fd184956ca5f866e7903c6fa241717f.tar.gz
urpmi-30d7067c0fd184956ca5f866e7903c6fa241717f.tar.bz2
urpmi-30d7067c0fd184956ca5f866e7903c6fa241717f.tar.xz
urpmi-30d7067c0fd184956ca5f866e7903c6fa241717f.zip
Factorize out the code that handles /etc/urpmi/mirror.config
-rw-r--r--urpm/cfg.pm18
-rwxr-xr-xurpmi.addmedia23
2 files changed, 25 insertions, 16 deletions
diff --git a/urpm/cfg.pm b/urpm/cfg.pm
index 815a992a..f5186e23 100644
--- a/urpm/cfg.pm
+++ b/urpm/cfg.pm
@@ -217,6 +217,24 @@ sub dump_config ($$) {
return 1;
}
+#- routines to handle mirror list location
+
+#- Default mirror list
+our $mirrors = 'http://www.mandrakelinux.com/mirrorsfull.list';
+
+sub mirrors_cfg () {
+ if (-e "/etc/urpmi/mirror.config") {
+ local $_;
+ open my $fh, "/etc/urpmi/mirror.config" or return undef;
+ while (<$fh>) {
+ chomp; s/#.*$//; s/^\s*//; s/\s*$//;
+ /^url\s*=\s*(.*)/ and $mirrors = $1;
+ }
+ close $fh;
+ }
+ return 1;
+}
+
1;
__END__
diff --git a/urpmi.addmedia b/urpmi.addmedia
index 7f33cdb8..df54a7a6 100755
--- a/urpmi.addmedia
+++ b/urpmi.addmedia
@@ -25,9 +25,7 @@ use urpm;
use urpm::args 'options';
use urpm::msg;
use urpm::download ();
-
-# Default mirror list
-our $mirrors = 'http://www.mandrakelinux.com/mirrorsfull.list';
+use urpm::cfg;
sub usage {
my $m = shift;
@@ -61,7 +59,7 @@ and [options] are from
medium.
") . N(" --from - use specified url for list of mirrors, the default is
%s
-", $mirrors) . N(" --version - use specified distribution version, the default is taken
+", $urpm::cfg::mirrors) . N(" --version - use specified distribution version, the default is taken
from the version of the distribution told by the
installed mandrakelinux-release package.
") . N(" --arch - use specified architecture, the default is arch of
@@ -80,19 +78,12 @@ and [options] are from
}
sub main {
- #- parse /etc/urpmi/mirror.config if present, or use default mandrake mirror.
- # the --from option overrides this setting.
+ #- parse /etc/urpmi/mirror.config if present, or use default mdk mirror.
+ #- the --from option overrides this setting.
if ($options{mirrors_url}) {
- $mirrors = $options{mirrors_url};
- }
- elsif (-e "/etc/urpmi/mirror.config") {
- local $_;
- open my $fh, "/etc/urpmi/mirror.config";
- while (<$fh>) {
- chomp; s/#.*$//; s/^\s*//; s/\s*$//;
- /^url\s*=\s*(.*)/ and $mirrors = $1;
- }
- close $fh;
+ $urpm::cfg::mirrors = $options{mirrors_url};
+ } else {
+ urpm::cfg::mirrors_cfg();
}
$options{force} = 0;
$options{noclean} = 1;