From 5443ef24e434a6635f086d491c9c0e86dfec68bd Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Fri, 29 Nov 2002 12:31:24 +0000 Subject: 4.1-4mdk --- urpm.pm | 51 +++++++++++++++++++++++++++++++++++++++++---------- urpmi.addmedia | 2 +- urpmi.spec | 11 +++++++++-- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/urpm.pm b/urpm.pm index 9537801a..8e42dd76 100644 --- a/urpm.pm +++ b/urpm.pm @@ -206,13 +206,17 @@ sub sync_webfetch { } delete @files{qw(ftp http)}; } - if ($files{rsync} || $files{ssh}) { - my @rsync_files = @{$files{rsync} || []}; + if ($files{rsync}) { + sync_rsync($options, @{$files{rsync} || []}); + delete $files{rsync}; + } + if ($files{ssh}) { + my @ssh_files; foreach (@{$files{ssh} || []}) { - /^ssh:\/\/([^\/]*)(.*)/ and push @rsync_files, "$1:$2"; + /^ssh:\/\/([^\/]*)(.*)/ and push @ssh_files, "$1:$2"; } - sync_rsync($options, @rsync_files); - delete @files{qw(rsync ssh)}; + sync_ssh($options, @ssh_files); + delete $files{ssh}; } %files and die _("unable to handle protocol: %s", join ', ', keys %files); } @@ -287,6 +291,20 @@ sub sync_curl { } } sub sync_rsync { + -x "/usr/bin/rsync" or die _("rsync is missing\n"); + -x "/usr/bin/ssh" or die _("ssh is missing\n"); + my $options = shift @_; + foreach (@_) { + my $count = 10; #- retry count on error (if file exists). + my $basename = (/^.*\/([^\/]*)$/ && $1) || $_; + do { + system "/usr/bin/rsync", (ref $options && $options->{quiet} ? ("-q") : ("--progress", "-v")), "--partial", + $_, (ref $options ? $options->{dir} : $options); + } while ($? != 0 && --$count > 0 && (-e (ref $options ? $options->{dir} : $options) . "/$basename")); + } + $? == 0 or die _("rsync failed: exited with %d or signal %d\n", $? >> 8, $? & 127); +} +sub sync_ssh { -x "/usr/bin/rsync" or die _("rsync is missing\n"); -x "/usr/bin/ssh" or die _("ssh is missing\n"); my $options = shift @_; @@ -1220,7 +1238,7 @@ sub update_media { } else { #- if url is clear and no relative list file has been downloaded, #- there is no need for a list file. - if ($medium->{url} eq $medium->{clear_url}) { + if ($medium->{url} ne $medium->{clear_url}) { foreach ($medium->{start} .. $medium->{end}) { my $filename = $urpm->{depslist}[$_]->filename; $list{$filename} = "$medium->{url}/$filename\n"; @@ -1569,13 +1587,26 @@ sub register_rpms { #- depslist and provides environment. $start = @{$urpm->{depslist}}; foreach (@files) { - /(.*\/)?[^\/]*\.rpm$/ or $error = 1, $urpm->{error}(_("invalid rpm file name [%s]", $_)), next; - -r $_ or $error = 1, $urpm->{error}(_("unable to access rpm file [%s]", $_)), next; + /\.rpm$/ or $error = 1, $urpm->{error}(_("invalid rpm file name [%s]", $_)), next; + + #- allow url to be given. + if (my ($basename) = /^[^:]*:\/.*\/([^\/]*\.rpm)$/) { + unlink "$urpm->{cachedir}/partial/$basename"; + eval { + $urpm->{log}(_("retrieving rpm file [%s] ...", $_)); + $urpm->{sync}({dir => "$urpm->{cachedir}/partial", quiet => 0, proxy => $urpm->{proxy}}, $_); + $urpm->{log}(_("...retrieving done")); + $_ = "$urpm->{cachedir}/partial/$basename"; + }; + $@ and $urpm->{log}(_("...retrieving failed: %s", $@)); + } else { + -r $_ or $error = 1, $urpm->{error}(_("unable to access rpm file [%s]", $_)), next; + } ($id, undef) = $urpm->parse_rpm($_); - my $pkg = $urpm->{depslist}[$id]; + my $pkg = defined $id && $urpm->{depslist}[$id]; $pkg or $urpm->{error}(_("unable to register rpm file")), next; - $urpm->{source}{$id} = $1 ? $_ : "./$_"; + $urpm->{source}{$id} = $_; } $error and $urpm->{fatal}(1, _("error registering local packages")); $start <= $id and @requested{($start .. $id)} = (1) x ($id-$start+1); diff --git a/urpmi.addmedia b/urpmi.addmedia index 72d4d043..edbc5a46 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -150,7 +150,7 @@ and [options] are from $urpm->add_medium("$name$i", $options{distrib} eq 'updates' ? "$burl/$options{version}/RPMS" : $options{distrib} eq 'contrib' ? $burl."2" : $burl, - $options{distrib} ne 'contrib' && $relative_hdlist, + ($options{distrib} ne 'contrib' || $options{version} ne 'cooker') && $relative_hdlist, update => $options{update}); ++$i; } diff --git a/urpmi.spec b/urpmi.spec index 997871c1..481c4a26 100644 --- a/urpmi.spec +++ b/urpmi.spec @@ -2,7 +2,7 @@ Name: urpmi Version: 4.1 -Release: 3mdk +Release: 4mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -204,13 +204,20 @@ fi %changelog +* Fri Nov 29 2002 François Pons 4.1-4mdk +- allow urpmi to work with rpm filename with all supported + protocols (ftp, http, ssh, rsync). +- fixed rsync:// protocol not to use rsync with -e along with + an rsync server. +- fixed missing list creation update. + * Thu Nov 28 2002 François Pons 4.1-3mdk - added mirrors management for urpmi.addmedia, so added --distrib-XXX, --from, --version, --arch options. is now just a regex for choosing a mirror, and will have an numeric index appended to it. anyway for more info, look in the code or guess with - --help ;-) + --help ;-) too late here in Paris ... - urpmi.addmedia now delete failing media to create. - added --update option to urpmi.update, guess for what ? -- cgit v1.2.1