summaryrefslogtreecommitdiffstats
path: root/perl-install/install_any.pm
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-09-24 05:12:15 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-09-24 05:12:15 +0000
commitc665b05d021c91887aacd736d4e283ab8e47a8a0 (patch)
tree0d69648633d123560757fea0377782df6a5ac518 /perl-install/install_any.pm
parentfd83996e8269c6c927a63134f01ef34059d86419 (diff)
downloaddrakx-c665b05d021c91887aacd736d4e283ab8e47a8a0.tar
drakx-c665b05d021c91887aacd736d4e283ab8e47a8a0.tar.gz
drakx-c665b05d021c91887aacd736d4e283ab8e47a8a0.tar.bz2
drakx-c665b05d021c91887aacd736d4e283ab8e47a8a0.tar.xz
drakx-c665b05d021c91887aacd736d4e283ab8e47a8a0.zip
Better handling of relative paths
Diffstat (limited to 'perl-install/install_any.pm')
-rw-r--r--perl-install/install_any.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index e6a2e36fa..3b10a255c 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -132,8 +132,9 @@ sub errorOpeningFile($) {
}
sub getFile {
- my ($f, $o_method, $altroot) = @_;
- log::l("getFile $f:$o_method");
+ my ($f, $o_method, $o_altroot) = @_;
+ my $current_method = ($asked_medium ? $::o->{packages}{mediums}{$asked_medium}{method} : '') || $::o->{method};
+ log::l("getFile $f:$o_method ($asked_medium:$current_method)");
my $rel = relGetFile($f);
do {
if ($f =~ m|^http://|) {
@@ -142,24 +143,25 @@ sub getFile {
} elsif ($o_method =~ /crypto|update/i) {
require crypto;
crypto::getFile($f);
- } elsif ($::o->{method} eq "ftp") {
+ } elsif ($current_method eq "ftp") {
require ftp;
ftp::getFile($rel);
- } elsif ($::o->{method} eq "http") {
+ } elsif ($current_method eq "http") {
require http;
- http::getFile("$ENV{URLPREFIX}/$rel");
+ http::getFile(($ENV{URLPREFIX} || $o_altroot) . "/$rel");
} else {
#- try to open the file, but examine if it is present in the repository,
#- this allows handling changing a media when some of the files on the
#- first CD have been copied to other to avoid media change...
my $f2 = "$postinstall_rpms/$f";
- $altroot = '/tmp/image' unless $altroot;
- $f2 = "$altroot/$rel" if !$postinstall_rpms || !-e $f2;
- $f2 = $rel if $rel =~ m!^/! && !-e $f2; #- not a relative path
- my $F; open($F, $f2) && $F;
+ $o_altroot ||= '/tmp/image';
+ $f2 = "$o_altroot/$rel" if $rel !~ m,^/, && (!$postinstall_rpms || !-e $f2);
+ $f2 = "/$rel" if !$::o->{packages}{mediums}{$asked_medium}{rpmsdir} && !-e $f2;
+ my $F; open($F, $f2) ? $F : do { $f2 !~ /XXX/ and log::l("Can't open $f2: $!"); undef }
}
} || errorOpeningFile($f);
}
+
sub getAndSaveFile {
my ($file, $local) = @_ == 1 ? ("Mandrake/mdkinst$_[0]", $_[0]) : @_;
local $/ = \ (16 * 1024);