summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-12-13 09:54:14 +0000
committerThierry Vignaud <tv@mageia.org>2012-12-13 09:54:14 +0000
commit5b4d5c4d20ed6beb1efac54dc6c03de8df4c4681 (patch)
treefde5c690f954de59c12e2732dde61feb41589e14 /urpm
parentfa37569a1609f93925063b5b8a83d0e2fb16816c (diff)
downloadurpmi-5b4d5c4d20ed6beb1efac54dc6c03de8df4c4681.tar
urpmi-5b4d5c4d20ed6beb1efac54dc6c03de8df4c4681.tar.gz
urpmi-5b4d5c4d20ed6beb1efac54dc6c03de8df4c4681.tar.bz2
urpmi-5b4d5c4d20ed6beb1efac54dc6c03de8df4c4681.tar.xz
urpmi-5b4d5c4d20ed6beb1efac54dc6c03de8df4c4681.zip
simplify using cat_()
Diffstat (limited to 'urpm')
-rw-r--r--urpm/cfg.pm8
-rw-r--r--urpm/media.pm27
-rw-r--r--urpm/sys.pm4
3 files changed, 12 insertions, 27 deletions
diff --git a/urpm/cfg.pm b/urpm/cfg.pm
index 75487c98..7b96cc54 100644
--- a/urpm/cfg.pm
+++ b/urpm/cfg.pm
@@ -64,13 +64,7 @@ sub get_arch () { _init_arch_release(); $arch }
sub get_release () { _init_arch_release(); $release }
sub get_host () {
- my $h;
- if (open my $f, '/proc/sys/kernel/hostname') {
- $h = <$f>;
- close $f;
- } else {
- $h = $ENV{HOSTNAME} || `/bin/hostname`;
- }
+ my $h = cat_('/proc/sys/kernel/hostname') || $ENV{HOSTNAME} || `/bin/hostname`;
chomp $h;
$h;
}
diff --git a/urpm/media.pm b/urpm/media.pm
index 687e2c6d..92f4a777 100644
--- a/urpm/media.pm
+++ b/urpm/media.pm
@@ -185,26 +185,19 @@ sub _read_config__read_media_info {
$distribconf->settree('mandriva');
$distribconf->parse_mediacfg($media_cfg) or next;
- if (open(my $URLS, '<', $media_dir . '/url')) {
- local $_;
- while (<$URLS>) {
- chomp($_);
- foreach my $medium ($distribconf->listmedia) {
- my $medium_path = reduce_pathname($_ . '/' . $distribconf->getpath($medium, 'path'));
- $url2mediamap{$medium_path} = [$distribconf, $medium];
- }
+ foreach (cat_($media_dir . '/url')) {
+ chomp($_);
+ foreach my $medium ($distribconf->listmedia) {
+ my $medium_path = reduce_pathname($_ . '/' . $distribconf->getpath($medium, 'path'));
+ $url2mediamap{$medium_path} = [$distribconf, $medium];
}
}
- if (open(my $MIRRORLISTS, '<', $media_dir . '/mirrorlist')) {
- local $_;
- while (<$MIRRORLISTS>) {
- my $mirrorlist = $_;
- chomp($mirrorlist);
- foreach my $medium ($distribconf->listmedia) {
- my $medium_path = $distribconf->getpath($medium, 'path');
- $mirrorlist2mediamap{$mirrorlist}{$medium_path} = [ $distribconf, $medium ];
- }
+ foreach my $mirrorlist (cat_($media_dir . '/mirrorlist')) {
+ chomp($mirrorlist);
+ foreach my $medium ($distribconf->listmedia) {
+ my $medium_path = $distribconf->getpath($medium, 'path');
+ $mirrorlist2mediamap{$mirrorlist}{$medium_path} = [ $distribconf, $medium ];
}
}
}
diff --git a/urpm/sys.pm b/urpm/sys.pm
index 231a37c7..42b4c337 100644
--- a/urpm/sys.pm
+++ b/urpm/sys.pm
@@ -31,9 +31,7 @@ typically from the inst.list or skip.list files.
sub get_packages_list {
my ($file, $o_extra) = @_;
my @l = split(/,/, $o_extra || '');
- if ($file && open(my $f, '<', $file)) {
- push @l, <$f>;
- }
+ push @l, cat_($file);
[ grep { $_ } map {
chomp; s/#.*$//; s/^\s*//; s/\s*$//;
$_;