summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-02-27 13:57:48 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-02-27 13:57:48 +0000
commit19456f175d4681a0646af79d75e04fe9e64e3648 (patch)
tree9e183a57a34f8fe3295feec3f854949703b24ae4 /urpm
parent1a8e216b62644a003e0ee4530841a0147d5f4edb (diff)
downloadurpmi-19456f175d4681a0646af79d75e04fe9e64e3648.tar
urpmi-19456f175d4681a0646af79d75e04fe9e64e3648.tar.gz
urpmi-19456f175d4681a0646af79d75e04fe9e64e3648.tar.bz2
urpmi-19456f175d4681a0646af79d75e04fe9e64e3648.tar.xz
urpmi-19456f175d4681a0646af79d75e04fe9e64e3648.zip
- create file_from_local_medium(), and use it where possible instead of
file_from_local_url() - in urpm::removable, this implies passing $blist around nb: for now file_from_local_medium() doesn't use the first parameter if url is given, but future commit will use both (needed for {url} cdrom://)
Diffstat (limited to 'urpm')
-rw-r--r--urpm/media.pm24
-rw-r--r--urpm/removable.pm39
2 files changed, 32 insertions, 31 deletions
diff --git a/urpm/media.pm b/urpm/media.pm
index 15ccc45c..2317d80a 100644
--- a/urpm/media.pm
+++ b/urpm/media.pm
@@ -2,7 +2,7 @@ package urpm::media;
# $Id$
-use urpm 'file_from_local_url', 'is_local_medium';
+use urpm 'file_from_local_medium', 'is_local_medium';
use urpm::msg;
use urpm::util;
use urpm::removable;
@@ -272,7 +272,7 @@ sub _synthesis_dir {
my ($medium) = @_;
$medium->{'no-media-info'} || $medium->{unknown_media_info} and return;
- my $base = file_from_local_url($medium->{url}) || $medium->{url};
+ my $base = file_from_local_medium($medium) || $medium->{url};
$medium->{with_synthesis}
? reduce_pathname("$base/$medium->{with_synthesis}/..")
: $medium->{media_info_dir} && reduce_pathname("$base/$medium->{media_info_dir}");
@@ -290,7 +290,7 @@ sub _valid_synthesis_dir {
sub _url_with_synthesis {
my ($medium) = @_;
- my $base = file_from_local_url($medium->{url}) || $medium->{url};
+ my $base = file_from_local_medium($medium) || $medium->{url};
$medium->{with_synthesis}
? reduce_pathname("$base/$medium->{with_synthesis}")
: _synthesis_dir($medium) . "/" . _url_with_synthesis_basename($medium);
@@ -404,7 +404,7 @@ sub probe_removable_device {
}
#- try to find device to open/close for removable medium.
- if (my $dir = file_from_local_url($medium->{url})) {
+ if (my $dir = file_from_local_medium($medium)) {
if (my $entry = urpm::sys::find_a_mntpoint($dir)) {
if ($medium->{removable} && $medium->{removable} ne $entry->{device}) {
$urpm->{log}(N("using different removable device [%s] for \"%s\"",
@@ -739,7 +739,7 @@ sub add_distrib_media {
my $distribconf;
- if (my $dir = $url && file_from_local_url($url)) {
+ if (my $dir = $url && urpm::file_from_local_url($url)) {
urpm::removable::try_mounting_($urpm, $dir)
or $urpm->{error}(N("unable to mount the distribution medium")), return ();
$distribconf = MDV::Distribconf->new($dir, undef);
@@ -924,7 +924,7 @@ sub _probe_with_try_list {
my @media_info_dirs = ('media_info', '.');
- my $base = file_from_local_url($medium->{url}) || $medium->{url};
+ my $base = file_from_local_medium($medium) || $medium->{url};
foreach my $media_info_dir (@media_info_dirs) {
my $url = reduce_pathname("$base/$media_info_dir") . '/synthesis.hdlist.cz';
@@ -944,7 +944,7 @@ sub may_reconfig_urpmi {
$medium->{url} or return; # we should handle mirrorlist?
my $f;
- if (my $dir = file_from_local_url($medium->{url})) {
+ if (my $dir = file_from_local_medium($medium)) {
$f = reduce_pathname("$dir/reconfig.urpmi");
} else {
unlink($f = "$urpm->{cachedir}/partial/reconfig.urpmi");
@@ -1075,7 +1075,7 @@ sub _copy_media_info_file {
my $name = "$prefix$suffix";
my $path = _synthesis_dir($medium) . "/$prefix" . _synthesis_suffix($medium) . $suffix;
- -e $path or $path = file_from_local_url($medium->{url}) . "/media_info/$name";
+ -e $path or $path = file_from_local_medium($medium) . "/media_info/$name";
my $result_file = "$urpm->{cachedir}/partial/$name";
if (-e $path) {
@@ -1127,7 +1127,7 @@ sub get_descriptions_local {
unlink statedir_descriptions($urpm, $medium);
- my $dir = file_from_local_url($medium->{url});
+ my $dir = file_from_local_medium($medium);
my $description_file = "$dir/media_info/descriptions"; #- new default location
-e $description_file or $description_file = "$dir/../descriptions";
-e $description_file or return;
@@ -1213,7 +1213,7 @@ sub _call_genhdlist2 {
!$medium->{with_synthesis} or $urpm->{fatal}(1, 'with_synthesis not handled with --probe-rpms');
- my $dir = file_from_local_url($medium->{url});
+ my $dir = file_from_local_medium($medium);
system('genhdlist2',
$urpm->{debug} ? '--verbose' : (), '--no-hdlist',
@@ -1238,7 +1238,7 @@ sub _update_medium__parse_if_unmodified__local {
my ($urpm, $medium, $options) = @_;
my $dir = $options->{probe_with} ne 'rpms' && _valid_synthesis_dir($medium)
- ? _synthesis_dir($medium) : file_from_local_url($medium->{url});
+ ? _synthesis_dir($medium) : file_from_local_medium($medium);
if (!-d $dir) {
#- the directory given does not exist and may be accessible
@@ -1401,7 +1401,7 @@ sub _update_medium__parse_if_unmodified__remote {
sub _get_pubkey_and_descriptions {
my ($urpm, $medium, $nopubkey) = @_;
- my $local = file_from_local_url($medium->{url});
+ my $local = file_from_local_medium($medium);
($local ? \&get_descriptions_local : \&get_descriptions_remote)->($urpm, $medium);
diff --git a/urpm/removable.pm b/urpm/removable.pm
index 19081f7b..cae0acaa 100644
--- a/urpm/removable.pm
+++ b/urpm/removable.pm
@@ -6,7 +6,7 @@ use urpm::msg;
use urpm::sys;
use urpm::util;
use urpm::get_pkgs;
-use urpm 'file_from_local_url', 'is_local_medium';
+use urpm 'file_from_local_medium', 'is_local_medium';
@@ -102,20 +102,20 @@ sub try_umounting_removables {
#- side-effects:
#- + those of try_mounting_ ($urpm->{removable_mounted}, "mount")
sub _mount_and_check_notfound {
- my ($urpm, $medium_list, $dir) = @_;
+ my ($urpm, $blist, $dir) = @_;
try_mounting_($urpm, $dir);
-e $dir or return 2;
- _check_notfound($medium_list);
+ _check_notfound($blist);
}
#- side-effects: none
sub _check_notfound {
- my ($medium_list) = @_;
+ my ($blist) = @_;
- foreach (values %$medium_list) {
- my $dir_ = _filepath($_) or next;
+ foreach (values %{$blist->{list}}) {
+ my $dir_ = _filepath($blist->{medium}, $_) or next;
-r $dir_ or return 1;
}
0;
@@ -132,7 +132,7 @@ sub _examine_removable_medium {
my $medium = $blist->{medium};
if (is_local_medium($medium)) {
- _examine_removable_medium_($urpm, $medium, $blist->{list}, $sources, $o_ask_for_medium);
+ _examine_removable_medium_($urpm, $blist, $sources, $o_ask_for_medium);
} else {
#- we have a removable device that is not removable, well...
$urpm->{error}(N("inconsistent medium \"%s\" marked removable but not really", $medium->{name}));
@@ -143,14 +143,15 @@ sub _examine_removable_medium {
#- + those of _mount_and_check_notfound ($urpm->{removable_mounted}, "mount")
#- + those of try_umounting ($urpm->{removable_mounted}, "umount")
sub _mount_it {
- my ($urpm, $medium, $medium_list, $o_ask_for_medium) = @_;
+ my ($urpm, $blist, $o_ask_for_medium) = @_;
+ my $medium = $blist->{medium};
- my $dir = file_from_local_url($medium->{url});
+ my $dir = file_from_local_medium($medium);
#- the directory given does not exist and may be accessible
#- by mounting some other directory. Try to figure it out and mount
#- everything that might be necessary.
- while (_mount_and_check_notfound($urpm, $medium_list, $dir)) {
+ while (_mount_and_check_notfound($urpm, $blist, $dir)) {
$o_ask_for_medium
or $urpm->{fatal}(4, N("medium \"%s\" is not available", $medium->{name}));
@@ -166,10 +167,10 @@ sub _mount_it {
#- side-effects: none
sub _filepath {
- my ($url) = @_;
+ my ($medium, $url) = @_;
chomp $url;
- my $filepath = file_from_local_url($url) or return;
+ my $filepath = file_from_local_medium($medium, $url) or return;
$filepath =~ m!/.*/! or return; #- is this really needed??
$filepath;
}
@@ -195,18 +196,18 @@ sub _do_the_copy {
#- + those of _mount_it ($urpm->{removable_mounted}, "mount", "umount", "eject")
#- + those of _do_the_copy: "copy-move-files"
sub _examine_removable_medium_ {
- my ($urpm, $medium, $medium_list, $sources, $o_ask_for_medium) = @_;
+ my ($urpm, $blist, $sources, $o_ask_for_medium) = @_;
- my $dir = _mount_it($urpm, $medium, $medium_list, $o_ask_for_medium);
+ my $dir = _mount_it($urpm, $blist, $o_ask_for_medium);
- while (my ($i, $url) = each %$medium_list) {
- my $filepath = _filepath($url) or next;
+ while (my ($i, $url) = each %{$blist->{list}}) {
+ my $filepath = _filepath($blist->{medium}, $url) or next;
if (my $rpm = _do_the_copy($urpm, $filepath)) {
$sources->{$i} = $rpm;
} else {
#- fallback to use other method for retrieving the file later.
- $urpm->{error}(N("unable to read rpm file [%s] from medium \"%s\"", $filepath, $medium->{name}));
+ $urpm->{error}(N("unable to read rpm file [%s] from medium \"%s\"", $filepath, $blist->{medium}{name}));
}
}
}
@@ -228,7 +229,7 @@ sub try_mounting_non_cdroms {
sub try_mounting_non_cdrom {
my ($urpm, $medium) = @_;
- my $dir = file_from_local_url($medium->{url}) or return;
+ my $dir = file_from_local_medium($medium) or return;
-e $dir || try_mounting($urpm, $dir, $medium->{iso}) or
$urpm->{error}(N("unable to access medium \"%s\"", $medium->{name})), return;
@@ -273,7 +274,7 @@ sub _sort_media {
@l = sort { values(%{$a->{list}}) <=> values(%{$b->{list}}) } @l;
#- check if a removable device is already mounted (and files present).
- if (my ($already_mounted) = grep { !_check_notfound($_->{list}) } @l) {
+ if (my ($already_mounted) = grep { !_check_notfound($_) } @l) {
@l = ($already_mounted, grep { $_ != $already_mounted } @l);
}
}