summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm62
1 files changed, 31 insertions, 31 deletions
diff --git a/urpm.pm b/urpm.pm
index 7787cb8c..1e09de18 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -386,27 +386,35 @@ sub hdlist_or_synthesis_for_virtual_medium {
sub statedir_hdlist_or_synthesis {
my ($urpm, $medium) = @_;
- "$urpm->{statedir}/" . ($medium->{synthesis} ? 'synthesis.' : '') . $medium->{hdlist};
+ $medium->{hdlist} && "$urpm->{statedir}/" . ($medium->{synthesis} ? 'synthesis.' : '') . $medium->{hdlist};
}
sub statedir_hdlist {
my ($urpm, $medium) = @_;
- "$urpm->{statedir}/$medium->{hdlist}";
+ $medium->{hdlist} && "$urpm->{statedir}/$medium->{hdlist}";
}
sub statedir_synthesis {
my ($urpm, $medium) = @_;
- "$urpm->{statedir}/synthesis.$medium->{hdlist}";
+ $medium->{hdlist} && "$urpm->{statedir}/synthesis.$medium->{hdlist}";
}
sub statedir_list {
my ($urpm, $medium) = @_;
- "$urpm->{statedir}/$medium->{list}";
+ $medium->{list} && "$urpm->{statedir}/$medium->{list}";
+}
+sub statedir_descriptions {
+ my ($urpm, $medium) = @_;
+ $medium->{name} && "$urpm->{statedir}/descriptions.$medium->{name}";
+}
+sub statedir_names {
+ my ($urpm, $medium) = @_;
+ $medium->{name} && "$urpm->{statedir}/names.$medium->{name}";
}
sub cachedir_hdlist {
my ($urpm, $medium) = @_;
- "$urpm->{cachedir}/partial/$medium->{hdlist}";
+ $medium->{hdlist} && "$urpm->{cachedir}/partial/$medium->{hdlist}";
}
sub cachedir_list {
my ($urpm, $medium) = @_;
- "$urpm->{cachedir}/partial/$medium->{list}";
+ $medium->{list} && "$urpm->{cachedir}/partial/$medium->{list}";
}
sub name2medium {
@@ -961,20 +969,17 @@ sub remove_selected_media {
sub remove_media {
my ($urpm, $to_remove) = @_;
- foreach (@$to_remove) {
- $urpm->{log}(N("removing medium \"%s\"", $_->{name}));
+ foreach my $medium (@$to_remove) {
+ $urpm->{log}(N("removing medium \"%s\"", $medium->{name}));
- #- mark to re-write configuration.
- $urpm->{modified} = 1;
+ #- mark to re-write configuration.
+ $urpm->{modified} = 1;
- #- remove files associated with this medium.
- foreach ($_->{hdlist}, $_->{list}, "synthesis.$_->{hdlist}", "descriptions.$_->{name}", "names.$_->{name}",
- "$_->{name}.cache") {
- $_ and unlink "$urpm->{statedir}/$_";
- }
+ #- remove files associated with this medium.
+ unlink grep { $_ } map { $_->($urpm, $medium) } \&statedir_hdlist, \&statedir_list, \&statedir_synthesis, \&statedir_descriptions, \&statedir_names;
- #- remove proxy settings for this media
- urpm::download::remove_proxy_media($_->{name});
+ #- remove proxy settings for this media
+ urpm::download::remove_proxy_media($medium->{name});
}
$urpm->{media} = [ difference2($urpm->{media}, $to_remove) ];
@@ -1159,9 +1164,9 @@ sub generate_media_names {
#- make sure names files are regenerated.
foreach (@{$urpm->{media}}) {
- unlink "$urpm->{statedir}/names.$_->{name}";
+ unlink statedir_names($urpm, $_);
if (is_valid_medium($_)) {
- my $fh = $urpm->open_safe(">", "$urpm->{statedir}/names.$_->{name}");
+ my $fh = $urpm->open_safe(">", statedir_names($urpm, $_));
if ($fh) {
foreach ($_->{start} .. $_->{end}) {
if (defined $urpm->{depslist}[$_]) {
@@ -1347,15 +1352,15 @@ this could happen if you mounted manually the directory when creating the medium
_update_media__virtual($urpm, $medium, $with_hdlist_dir);
}
#- try to get the description if it has been found.
- unlink "$urpm->{statedir}/descriptions.$medium->{name}";
+ unlink statedir_descriptions($urpm, $medium);
my $description_file = "$dir/media_info/descriptions"; #- new default location
-e $description_file or $description_file = "$dir/../descriptions";
if (-e $description_file) {
$urpm->{log}(N("copying description file of \"%s\"...", $medium->{name}));
- urpm::util::copy($description_file, "$urpm->{statedir}/descriptions.$medium->{name}")
+ urpm::util::copy($description_file, statedir_descriptions($urpm, $medium))
? $urpm->{log}(N("...copying done"))
: do { $urpm->{error}(N("...copying failed")); $medium->{ignore} = 1 };
- chown 0, 0, "$urpm->{statedir}/descriptions.$medium->{name}";
+ chown 0, 0, statedir_descriptions($urpm, $medium);
}
#- examine if a distant MD5SUM file is available.
@@ -1577,8 +1582,8 @@ sub _update_medium_first_pass {
#- try to get the description if it has been found.
unlink "$urpm->{cachedir}/partial/descriptions";
- if (-e "$urpm->{statedir}/descriptions.$medium->{name}") {
- urpm::util::move("$urpm->{statedir}/descriptions.$medium->{name}", "$urpm->{cachedir}/partial/descriptions");
+ if (-e statedir_descriptions($urpm, $medium)) {
+ urpm::util::move(statedir_descriptions($urpm, $medium), "$urpm->{cachedir}/partial/descriptions");
}
eval {
sync_webfetch($urpm, $medium, [ reduce_pathname("$medium->{url}/media_info/descriptions") ],
@@ -1596,7 +1601,7 @@ sub _update_medium_first_pass {
};
}
if (-e "$urpm->{cachedir}/partial/descriptions") {
- urpm::util::move("$urpm->{cachedir}/partial/descriptions", "$urpm->{statedir}/descriptions.$medium->{name}");
+ urpm::util::move("$urpm->{cachedir}/partial/descriptions", statedir_descriptions($urpm, $medium));
}
#- examine if a distant MD5SUM file is available.
@@ -3366,11 +3371,6 @@ sub check_sources_signatures {
sort keys %invalid_sources;
}
-sub dump_description_file {
- my ($urpm, $media_name) = @_;
- cat_("$urpm->{statedir}/descriptions.$media_name");
-}
-
#- get reason of update for packages to be updated
#- use all update medias if none given
sub get_updates_description {
@@ -3380,7 +3380,7 @@ sub get_updates_description {
@update_medias or @update_medias = grep { !$_->{ignore} && $_->{update} } @{$urpm->{media}};
- foreach (map { $urpm->dump_description_file($_->{name}), '%package dummy' } @update_medias) {
+ foreach (map { cat_(statedir_descriptions($urpm, $_)), '%package dummy' } @update_medias) {
/^%package (.+)/ and do {
if (exists $cur->{importance} && $cur->{importance} ne "security" && $cur->{importance} ne "bugfix") {
$cur->{importance} = 'normal';