diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2006-11-09 13:55:28 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2006-11-09 13:55:28 +0000 |
commit | 9f118da9297cb44b4ce04274129887507dd26510 (patch) | |
tree | 1ce49e47ef1e95926bf296a3417cce89d0e2bd30 /urpm/cfg.pm | |
parent | f0c1d7a629c9026d231ec943548a9a6b3eb0d939 (diff) | |
download | urpmi-9f118da9297cb44b4ce04274129887507dd26510.tar urpmi-9f118da9297cb44b4ce04274129887507dd26510.tar.gz urpmi-9f118da9297cb44b4ce04274129887507dd26510.tar.bz2 urpmi-9f118da9297cb44b4ce04274129887507dd26510.tar.xz urpmi-9f118da9297cb44b4ce04274129887507dd26510.zip |
factorize introducing proc_mounts() and cat_()
Diffstat (limited to 'urpm/cfg.pm')
-rw-r--r-- | urpm/cfg.pm | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/urpm/cfg.pm b/urpm/cfg.pm index 30d9cc8b..f1dbf9a8 100644 --- a/urpm/cfg.pm +++ b/urpm/cfg.pm @@ -109,9 +109,8 @@ sub load_config ($;$) { my $priority = 0; my $medium; $err = ''; - open my $f, $file or do { $err = N("unable to read config file [%s]", $file); return }; - local $_; - while (<$f>) { + my @conf_lines = cat_($file) or do { $err = N("unable to read config file [%s]", $file); return }; + foreach (@conf_lines) { chomp; next if /^\s*#/; #- comments s/^\s+//; s/\s+$//; @@ -192,7 +191,6 @@ sub load_config ($;$) { #- obsolete $_ eq 'modified' and next; } - close $f; return \%config; } @@ -235,14 +233,9 @@ sub dump_config ($$) { our $mirrors = 'http://www.mandrivalinux.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>) { + foreach (cat_("/etc/urpmi/mirror.config")) { chomp; s/#.*$//; s/^\s*//; s/\s*$//; /^url\s*=\s*(.*)/ and $mirrors = $1; - } - close $fh; } return 1; } |