From 534ea0562e53859bc9ead8fa8e1308e860b6fa17 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Mon, 26 Jul 2004 01:46:35 +0000 Subject: Preserve media order in urpmi.cfg --- urpm/cfg.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'urpm') 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); -- cgit v1.2.1