summaryrefslogtreecommitdiffstats
path: root/urpm.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-15 15:21:58 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-15 15:21:58 +0000
commit44b3028524dd01049132485fafa7d1d344546054 (patch)
treef6951d799b33fc619f2722c743f6857c5c73d9ab /urpm.pm
parentac6f86b1d591eb045dfcb7d1bb1f32e015022b89 (diff)
downloadurpmi-44b3028524dd01049132485fafa7d1d344546054.tar
urpmi-44b3028524dd01049132485fafa7d1d344546054.tar.gz
urpmi-44b3028524dd01049132485fafa7d1d344546054.tar.bz2
urpmi-44b3028524dd01049132485fafa7d1d344546054.tar.xz
urpmi-44b3028524dd01049132485fafa7d1d344546054.zip
- create _update_medium__get_descriptions_local() out of _update_medium_first_pass__local()
- create _update_medium__get_descriptions_remote() out of _update_medium_first_pass__remote()
Diffstat (limited to 'urpm.pm')
-rw-r--r--urpm.pm84
1 files changed, 50 insertions, 34 deletions
diff --git a/urpm.pm b/urpm.pm
index cb175c60..8da42422 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -1313,6 +1313,53 @@ sub clean_dir {
mkdir $dir, 0755;
}
+sub _update_medium__get_descriptions_local {
+ my ($urpm, $medium) = @_;
+
+ unlink statedir_descriptions($urpm, $medium);
+
+ my $dir = file_from_local_url($medium->{url});
+ my $description_file = "$dir/media_info/descriptions"; #- new default location
+ -e $description_file or $description_file = "$dir/../descriptions";
+ -e $description_file or return;
+
+ $urpm->{log}(N("copying description file of \"%s\"...", $medium->{name}));
+ if (urpm::util::copy($description_file, statedir_descriptions($urpm, $medium))) {
+ $urpm->{log}(N("...copying done"));
+ } else {
+ $urpm->{error}(N("...copying failed"));
+ $medium->{ignore} = 1;
+ }
+ chown 0, 0, statedir_descriptions($urpm, $medium);
+}
+sub _update_medium__get_descriptions_remote {
+ my ($urpm, $medium, $options) = @_;
+
+ unlink "$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") ],
+ $options, quiet => 1);
+ };
+ #- It is possible that the original fetch of the descriptions
+ #- failed, but the file still remains in partial/ because it was
+ #- moved from $urpm->{statedir} earlier. So we need to check if
+ #- the previous download failed.
+ if ($@ || ! -e "$urpm->{cachedir}/partial/descriptions") {
+ eval {
+ #- try older location
+ sync_webfetch($urpm, $medium, [ reduce_pathname("$medium->{url}/../descriptions") ],
+ $options, quiet => 1);
+ };
+ }
+ if (-e "$urpm->{cachedir}/partial/descriptions") {
+ urpm::util::move("$urpm->{cachedir}/partial/descriptions", statedir_descriptions($urpm, $medium));
+ }
+}
+
sub _update_medium_first_pass__local {
my ($urpm, $medium, $second_pass, $clean_cache, $retrieved_md5sum, $rpm_files, $options) = @_;
@@ -1351,17 +1398,8 @@ this could happen if you mounted manually the directory when creating the medium
#- determine its type, once a with_hdlist has been found (but is mandatory).
_update_media__virtual($urpm, $medium, $with_hdlist_dir);
}
- #- try to get the description if it has been found.
- 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, statedir_descriptions($urpm, $medium))
- ? $urpm->{log}(N("...copying done"))
- : do { $urpm->{error}(N("...copying failed")); $medium->{ignore} = 1 };
- chown 0, 0, statedir_descriptions($urpm, $medium);
- }
+
+ _update_medium__get_descriptions_local($urpm, $medium);
#- examine if a distant MD5SUM file is available.
#- this will only be done if $with_hdlist is not empty in order to use
@@ -1506,29 +1544,7 @@ sub _update_medium_first_pass__remote {
my ($urpm, $medium, $retrieved_md5sum, $options) = @_;
my ($error, $basename);
- #- try to get the description if it has been found.
- unlink "$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") ],
- $options, quiet => 1);
- };
- #- It is possible that the original fetch of the descriptions
- #- failed, but the file still remains in partial/ because it was
- #- moved from $urpm->{statedir} earlier. So we need to check if
- #- the previous download failed.
- if ($@ || ! -e "$urpm->{cachedir}/partial/descriptions") {
- eval {
- #- try older location
- sync_webfetch($urpm, $medium, [ reduce_pathname("$medium->{url}/../descriptions") ],
- $options, quiet => 1);
- };
- }
- if (-e "$urpm->{cachedir}/partial/descriptions") {
- urpm::util::move("$urpm->{cachedir}/partial/descriptions", statedir_descriptions($urpm, $medium));
- }
+ _update_medium__get_descriptions_remote($urpm, $medium, $options);
#- examine if a distant MD5SUM file is available.
#- this will only be done if $with_hdlist is not empty in order to use