diff options
Diffstat (limited to 'perl-install/install/http.pm')
| -rw-r--r-- | perl-install/install/http.pm | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/perl-install/install/http.pm b/perl-install/install/http.pm index 91b27601c..db111564c 100644 --- a/perl-install/install/http.pm +++ b/perl-install/install/http.pm @@ -1,21 +1,18 @@ -package install::http; # $Id$ +package install::http; use urpm::download; use common; - -# to be killed once callers got fixed -sub close() { -} +use Cwd; sub getFile { - my ($url) = @_; - my ($_size, $fh) = get_file_and_size($url) or return; + my ($url, %o_options) = @_; + my ($_size, $fh) = get_file_and_size($url, %o_options) or return; $fh; } sub parse_http_url { my ($url) = @_; - $url =~ m,^(?:http|ftp)://([^/:]+)(?::(\d+))?(/\S*)?$,; + $url =~ m,^(?:https?|ftp)://(?:[^:/]+:[^:/]+\@)?([^/:@]+)(?::(\d+))?(/\S*)?$,; } sub get_file_and_size_ { @@ -30,13 +27,19 @@ sub get_file_and_size_ { } sub get_file_and_size { - my ($url) = @_; + my ($url, %o_options) = @_; # can be used for ftp urls (with http proxy) my ($host) = parse_http_url($url); defined $host or return undef; my $urpm = $::o->{packages}; + if (!$urpm) { + require install::pkgs; + $urpm = install::pkgs::empty_packages($::o->{keep_unrequested_dependencies}); + $urpm->{options}{'curl-options'} = '-s'; + } + my $cachedir = $urpm->{cachedir} || '/root'; my $file = $url; $file =~ s!.*/!$cachedir/!; @@ -49,10 +52,15 @@ sub get_file_and_size { urpm::download::set_cmdline_proxy(http_proxy => "http://$proxy/"); } - my $res = urpm::download::sync_url($urpm, $url, dir => $cachedir); - $res or die N("retrieval of [%s] failed", $file) . "\n"; - open(my $f, $file); - ( -s $file, $f); + my $res = eval { urpm::download::sync_url($urpm, $url, %o_options, dir => $cachedir) }; + + if ($res) { + open(my $f, $file); + (-s $file, $f); + } else { + log::l("retrieval of [$file] failed"); + undef; + } } 1; |
