summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-14 12:34:14 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-14 12:34:14 +0000
commit3f14b568762768b01d7e8d9775ec17c6ff012561 (patch)
treef29e449fde9aa8796786ec8b4c4c29ba54dffc75 /urpm.pm
parentd789a6e2f30d7cad425570e59f656d7a5fdeacea (diff)
downloadurpmi-3f14b568762768b01d7e8d9775ec17c6ff012561.tar
urpmi-3f14b568762768b01d7e8d9775ec17c6ff012561.tar.gz
urpmi-3f14b568762768b01d7e8d9775ec17c6ff012561.tar.bz2
urpmi-3f14b568762768b01d7e8d9775ec17c6ff012561.tar.xz
urpmi-3f14b568762768b01d7e8d9775ec17c6ff012561.zip
create statedir_list() and cachedir_list()
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm32
1 files changed, 20 insertions, 12 deletions
diff --git a/urpm.pm b/urpm.pm
index aef450ee..498fbf50 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -251,7 +251,7 @@ sub read_config {
$medium->{ignore} = 1;
$urpm->{error}(N("unable to access hdlist file of \"%s\", medium ignored", $medium->{name}));
}
- if ($medium->{list} && -r "$urpm->{statedir}/$medium->{list}") {}
+ if ($medium->{list} && -r statedir_list($urpm, $medium)) {}
elsif ($medium->{url}) {}
else {
$medium->{ignore} = 1;
@@ -305,7 +305,7 @@ sub probe_medium {
unless ($medium->{ignore} || $medium->{list}) {
unless (defined $medium->{url}) {
$medium->{list} = "list.$medium->{name}";
- unless (-e "$urpm->{statedir}/$medium->{list}") {
+ unless (-e statedir_list($urpm, $medium)) {
$medium->{ignore} = 1,
$urpm->{error}(N("unable to find list file for \"%s\", medium ignored", $medium->{name}));
}
@@ -315,8 +315,8 @@ sub probe_medium {
#- there is a little more to do at this point as url is not known, inspect directly list file for it.
unless ($medium->{url}) {
my %probe;
- if (-r "$urpm->{statedir}/$medium->{list}") {
- my $listfile = $urpm->open_safe("<", "$urpm->{statedir}/$medium->{list}");
+ if (-r statedir_list($urpm, $medium)) {
+ my $listfile = $urpm->open_safe("<", statedir_list($urpm, $medium));
if ($listfile) {
while (<$listfile>) {
#- /./ is end of url marker in list file (typically generated by a
@@ -392,10 +392,18 @@ sub statedir_synthesis {
my ($urpm, $medium) = @_;
"$urpm->{statedir}/synthesis.$medium->{hdlist}";
}
+sub statedir_list {
+ my ($urpm, $medium) = @_;
+ "$urpm->{statedir}/$medium->{list}";
+}
sub cachedir_hdlist {
my ($urpm, $medium) = @_;
"$urpm->{cachedir}/partial/$medium->{hdlist}";
}
+sub cachedir_list {
+ my ($urpm, $medium) = @_;
+ "$urpm->{cachedir}/partial/$medium->{list}";
+}
sub name2medium {
my ($urpm, $name) = @_;
@@ -1746,7 +1754,7 @@ sub _update_medium_first_pass {
#- make sure group and other do not have any access to this file, used to hide passwords.
if ($medium->{list}) {
my $mask = umask 077;
- open my $listfh, ">", "$urpm->{cachedir}/partial/$medium->{list}"
+ open my $listfh, ">", cachedir_list($urpm, $medium)
or $error = 1, $urpm->{error}(N("unable to write list file of \"%s\"", $medium->{name}));
umask $mask;
print $listfh values %list;
@@ -1754,7 +1762,7 @@ sub _update_medium_first_pass {
}
#- check if at least something has been written into list file.
- if ($medium->{list} && -s "$urpm->{cachedir}/partial/$medium->{list}") {
+ if ($medium->{list} && -s cachedir_list($urpm, $medium)) {
$urpm->{log}(N("writing list file for medium \"%s\"", $medium->{name}));
} else {
$error = 1, $urpm->{error}(N("nothing written in list file for \"%s\"", $medium->{name}));
@@ -1762,7 +1770,7 @@ sub _update_medium_first_pass {
} else {
#- the flag is no longer necessary.
if ($medium->{list}) {
- unlink "$urpm->{statedir}/$medium->{list}";
+ unlink statedir_list($urpm, $medium);
delete $medium->{list};
}
}
@@ -1793,7 +1801,7 @@ sub _update_medium_first_pass {
if ($error) {
#- an error has occured for updating the medium, we have to remove temporary files.
unlink cachedir_hdlist($urpm, $medium);
- $medium->{list} and unlink "$urpm->{cachedir}/partial/$medium->{list}";
+ $medium->{list} and unlink cachedir_list($urpm, $medium);
#- read default synthesis (we have to make sure nothing get out of depslist).
_parse_synthesis($urpm, $medium, statedir_synthesis($urpm, $medium));
if (!is_valid_medium($medium)) {
@@ -1808,7 +1816,7 @@ sub _update_medium_first_pass {
#- but use newly created file.
unlink statedir_hdlist($urpm, $medium);
$medium->{synthesis} and unlink statedir_synthesis($urpm, $medium);
- $medium->{list} and unlink "$urpm->{statedir}/$medium->{list}";
+ $medium->{list} and unlink statedir_list($urpm, $medium);
unless ($medium->{headers}) {
unlink statedir_synthesis($urpm, $medium);
unlink statedir_hdlist($urpm, $medium);
@@ -1819,7 +1827,7 @@ sub _update_medium_first_pass {
);
}
if ($medium->{list}) {
- urpm::util::move("$urpm->{cachedir}/partial/$medium->{list}", "$urpm->{statedir}/$medium->{list}");
+ urpm::util::move(cachedir_list($urpm, $medium), statedir_list($urpm, $medium));
}
$medium->{md5sum} = $retrieved_md5sum; #- anyway, keep it, the previous one is no longer useful.
@@ -2450,7 +2458,7 @@ sub get_source_packages {
if (is_valid_medium($medium) && !$medium->{ignore}) {
#- always prefer a list file if available.
- my $listfile = $medium->{list} ? "$urpm->{statedir}/$medium->{list}" : '';
+ my $listfile = $medium->{list} ? statedir_list($urpm, $medium) : '';
if (!$listfile && $medium->{virtual}) {
my $dir = file_from_local_url($medium->{url});
my $with_hdlist_dir = reduce_pathname($dir . ($medium->{with_hdlist} ? "/$medium->{with_hdlist}" : "/.."));
@@ -2513,7 +2521,7 @@ sub get_source_packages {
}
}
}
- $list_warning && $medium->{list} && -r "$urpm->{statedir}/$medium->{list}" && -f _
+ $list_warning && $medium->{list} && -r statedir_list($urpm, $medium) && -f _
and $urpm->{error}(N("medium \"%s\" uses an invalid list file:
mirror is probably not up-to-date, trying to use alternate method", $medium->{name}));
} elsif (!%list_examined) {