summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm')
-rw-r--r--urpm/cfg.pm13
-rw-r--r--urpm/download.pm7
2 files changed, 6 insertions, 14 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;
}
diff --git a/urpm/download.pm b/urpm/download.pm
index 1eba2504..1019120d 100644
--- a/urpm/download.pm
+++ b/urpm/download.pm
@@ -5,6 +5,7 @@ package urpm::download;
use strict;
use urpm::msg;
use urpm::cfg;
+use urpm::util;
use Cwd;
(our $VERSION) = q($Revision$) =~ /(\d+)/;
@@ -33,9 +34,8 @@ sub import () {
#- parses proxy.cfg (private)
sub load_proxy_config () {
return if defined $proxy_config;
- open my $f, $PROXY_CFG or $proxy_config = {}, return;
- local $_;
- while (<$f>) {
+ $proxy_config = {};
+ foreach (cat_($PROXY_CFG)) {
chomp; s/#.*$//; s/^\s*//; s/\s*$//;
if (/^(?:(.*):\s*)?(ftp_proxy|http_proxy)\s*=\s*(.*)$/) {
$proxy_config->{$1 || ''}{$2} = $3;
@@ -51,7 +51,6 @@ sub load_proxy_config () {
next;
}
}
- close $f;
}
#- writes proxy.cfg