summaryrefslogtreecommitdiffstats
path: root/urpm/cfg.pm
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-07-26 01:46:35 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-07-26 01:46:35 +0000
commit534ea0562e53859bc9ead8fa8e1308e860b6fa17 (patch)
tree97fb7cf32d2c9ade05d6b413c40324e633a17a79 /urpm/cfg.pm
parentd2dff5993cab6360557eda7d3f68d2fed47c6629 (diff)
downloadurpmi-534ea0562e53859bc9ead8fa8e1308e860b6fa17.tar
urpmi-534ea0562e53859bc9ead8fa8e1308e860b6fa17.tar.gz
urpmi-534ea0562e53859bc9ead8fa8e1308e860b6fa17.tar.bz2
urpmi-534ea0562e53859bc9ead8fa8e1308e860b6fa17.tar.xz
urpmi-534ea0562e53859bc9ead8fa8e1308e860b6fa17.zip
Preserve media order in urpmi.cfg
Diffstat (limited to 'urpm/cfg.pm')
-rw-r--r--urpm/cfg.pm8
1 files changed, 5 insertions, 3 deletions
diff --git a/urpm/cfg.pm b/urpm/cfg.pm
index f9babd84..24c2b790 100644
--- a/urpm/cfg.pm
+++ b/urpm/cfg.pm
@@ -17,7 +17,7 @@ urpm::cfg - routines to handle the urpmi configuration files
=item load_config($file)
-Reads an urpmi configuration file and return its contents in a hash ref :
+Reads an urpmi configuration file and returns its contents in a hash ref :
{
'medium name 1' => {
@@ -47,6 +47,7 @@ sub _syntax_error () { $err = N("syntax error in config file at line %s", $.) }
sub load_config ($) {
my ($file) = @_;
my %config;
+ my $priority = 0;
my $medium = undef;
$err = '';
open my $f, $file or do { $err = N("unable to read config file [%s]", $file); return };
@@ -119,6 +120,7 @@ sub load_config ($) {
}
#- obsolete
/^modified$/ and next;
+ $config{$medium}{priority} = $priority++; #- to preserve order
}
close $f;
return \%config;
@@ -128,9 +130,9 @@ sub dump_config ($$) {
my ($file, $config) = @_;
my @media = sort {
return 0 if $a eq $b;
- return -1 if $a eq '';
+ return -1 if $a eq ''; #- global options come first
return 1 if $b eq '';
- return $a cmp $b;
+ return $config->{$a}{priority} <=> $config->{$b}{priority};
} keys %$config;
open my $f, '>', $file or do {
$err = N("unable to write config file [%s]", $file);