From c665b05d021c91887aacd736d4e283ab8e47a8a0 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Fri, 24 Sep 2004 05:12:15 +0000 Subject: Better handling of relative paths --- perl-install/install_any.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'perl-install/install_any.pm') 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); -- cgit v1.2.1