diff options
author | Francois Pons <fpons@mandriva.com> | 2001-12-14 09:06:20 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2001-12-14 09:06:20 +0000 |
commit | 69ca56709b131e40ef739a45db68cb0353d1add2 (patch) | |
tree | 07a7a9e191dc336545c5c5058bdb95f9657ebdb2 | |
parent | c76f6078c8bc75cefeaa1353cbc9b4dce09ddc75 (diff) | |
download | urpmi-69ca56709b131e40ef739a45db68cb0353d1add2.tar urpmi-69ca56709b131e40ef739a45db68cb0353d1add2.tar.gz urpmi-69ca56709b131e40ef739a45db68cb0353d1add2.tar.bz2 urpmi-69ca56709b131e40ef739a45db68cb0353d1add2.tar.xz urpmi-69ca56709b131e40ef739a45db68cb0353d1add2.zip |
added curl time stamp support for both http and ftp.
-rw-r--r-- | urpm.pm | 58 | ||||
-rw-r--r-- | urpmi.spec | 11 |
2 files changed, 62 insertions, 7 deletions
@@ -89,7 +89,7 @@ sub unquotespace { local $_ = $_[0]; s/\\(\s)/$1/g; $_ } sub sync_webfetch { -x "/usr/bin/curl" and return &sync_curl; -x "/usr/bin/wget" and return &sync_wget; - die _("no webfetch (curl or wget for example) found\n"); + die _("no webfetch (curl or wget currently) found\n"); } sub sync_wget { -x "/usr/bin/wget" or die _("wget is missing\n"); @@ -99,8 +99,56 @@ sub sync_wget { sub sync_curl { -x "/usr/bin/curl" or die _("curl is missing\n"); chdir shift @_; - system "/usr/bin/curl", "-R", map { ("-O", $_ ) } @_; - $? == 0 or die _("curl failed: exited with %d or signal %d\n", $? >> 8, $? & 127); + my (@ftp_files, @other_files); + foreach (@_) { + /^ftp:\/\/.*\/([^\/]*)$/ && -s $1 > 8192 and do { push @ftp_files, $_; next }; #- manage time stamp for large file only. + push @other_files; + } + if (@ftp_files) { + my ($cur_ftp_file, %ftp_files_info); + + require Date::Manip; + + #- prepare to get back size and time stamp of each file. + local *CURL; + open CURL, "/usr/bin/curl -I " . join(" ", map { "'$_'" } @ftp_files) . " |"; + while (<CURL>) { + if (/Content-Length:\s*(\d+)/) { + !$cur_ftp_file || exists $ftp_files_info{$cur_ftp_file}{size} and $cur_ftp_file = shift @ftp_files; + $ftp_files_info{$cur_ftp_file}{size} = $1; + } + if (/Last-Modified:\s*(.*)/) { + !$cur_ftp_file || exists $ftp_files_info{$cur_ftp_file}{time} and $cur_ftp_file = shift @ftp_files; + $ftp_files_info{$cur_ftp_file}{time} = Date::Manip::ParseDate($1); + $ftp_files_info{$cur_ftp_file}{time} =~ s/(\d{6}).{4}(.*)/$1$2/; #- remove day and hour. + } + } + close CURL; + + #- now analyse size and time stamp according to what already exists here. + if (@ftp_files) { + #- re-insert back shifted element of ftp_files, because curl output above + #- have not been parsed correctly, in doubt download them all. + push @ftp_files, keys %ftp_files_info; + } else { + #- for that, it should be clear ftp_files is empty... else a above work is + #- use less. + foreach (keys %ftp_files_info) { + my ($lfile) = /\/([^\/]*)$/ or next; #- strange if we can't parse it correctly. + my $ltime = Date::Manip::ParseDate(scalar gmtime((stat $1)[9])); + $ltime =~ s/(\d{6}).{4}(.*)/$1$2/; #- remove day and hour. + -s $lfile == $ftp_files_info{$_}{size} && $ftp_files_info{$_}{time} eq $ltime or + push @ftp_files, $_; + } + } + } + #- http files (and other files) are correctly managed by curl to conditionnal upload. + #- options for ftp files, -R (-O <file>)* + #- options for http files, -R (-z file -O <file>)* + if (my @all_files = ((map { ("-O", $_ ) } @ftp_files), (map { /\/([^\/]*)$/ ? ("-z", $1, "-O", $_) : () } @other_files))) { + system "/usr/bin/curl", "-R", @all_files; + $? == 0 or die _("curl failed: exited with %d or signal %d\n", $? >> 8, $? & 127); + } } #- read /etc/urpmi/urpmi.cfg as config file, keep compability with older @@ -1255,7 +1303,9 @@ sub parse_synthesis { chomp; my ($name, $tag, @data) = split '@'; if ($name ne $last_name) { - !%info || $update_info->() or $urpm->{log}(_("unable to analyse synthesis data of %s", $last_name)); + !%info || $update_info->() or + $urpm->{log}(_("unable to analyse synthesis data of %s", + $last_name =~ /^[[:print:]]*$/ ? $last_name : _("<non printable chars>"))); $last_name = $name; %info = (); } @@ -2,12 +2,12 @@ Name: urpmi Version: 3.1 -Release: 1mdk +Release: 2mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate Summary: User mode rpm install -Requires: eject, webfetch +Requires: eject, webfetch, perl-DateManip >= 5.40 PreReq: perl-gettext, rpmtools >= 4.0 BuildRequires: libbzip2-devel rpm-devel BuildRoot: %{_tmppath}/%{name}-buildroot @@ -142,7 +142,12 @@ fi %changelog -* Thu Dec 13 2001 François Pons <fpons@ackbar.mandrakesoft.com> 3.1-1mdk +* Fri Dec 14 2001 François Pons <fpons@mandrakesoft.com> 3.1-2mdk +- added time conditionnal download to curl interface for both http + and ftp protocol (so need Date::Manip because urpm library use it + for ftp as no support in curl). + +* Thu Dec 13 2001 François Pons <fpons@mandrakesoft.com> 3.1-1mdk - added --distrib flag to urpmi.addmedia to add all media from the installation medium. - fixed update on removable medium (the second to more). |