From 8e1922a4447fd41b5cbd0fc1d0c0596b8808197e Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Thu, 21 Sep 2006 15:47:53 +0000 Subject: Add Prozilla support --- urpm.pm | 12 +++++++++--- urpm/args.pm | 10 ++++++---- urpm/cfg.pm | 2 +- urpm/download.pm | 24 ++++++++++++++++++++++++ urpmi | 4 +++- urpmi.addmedia | 1 + urpmi.bash-completion | 10 +++++----- urpmi.update | 1 + urpmq | 1 + 9 files changed, 51 insertions(+), 14 deletions(-) diff --git a/urpm.pm b/urpm.pm index 8ca9994e..ef0a471f 100644 --- a/urpm.pm +++ b/urpm.pm @@ -72,12 +72,15 @@ sub sync_webfetch { $urpm->{fatal}(10, $@) if $@; delete @files{qw(removable file)}; } - for my $cpt (qw(wget-options curl-options rsync-options)) { + for my $cpt (qw(wget-options curl-options rsync-options prozilla-options)) { $options->{$cpt} = $urpm->{options}{$cpt} if defined $urpm->{options}{$cpt}; } if ($files{ftp} || $files{http} || $files{https}) { - my @webfetch = qw(curl wget); - my @available_webfetch = grep { -x "/usr/bin/$_" || -x "/bin/$_" } @webfetch; + my @webfetch = qw(curl wget prozilla); + my %webfetch_executables = (curl => 'curl', wget => 'wget', prozilla => 'proz'); + my @available_webfetch = grep { + -x "/usr/bin/$webfetch_executables{$_}" || -x "/bin/$webfetch_executables{$_}" + } @webfetch; #- use user default downloader if provided and available my $option_downloader = $urpm->{options}{downloader}; #- cmd-line switch if (!$option_downloader && $options->{media}) { #- per-media config @@ -98,6 +101,8 @@ sub sync_webfetch { sync_curl($options, @{$files{ftp} || []}, @{$files{http} || []}, @{$files{https} || []}); } elsif ($preferred eq 'wget') { sync_wget($options, @{$files{ftp} || []}, @{$files{http} || []}, @{$files{https} || []}); + } elsif ($preferred eq 'prozilla') { + sync_prozilla($options, @{$files{ftp} || []}, @{$files{http} || []}, @{$files{https} || []}); } else { die N("no webfetch found, supported webfetch are: %s\n", join(", ", @webfetch)); } @@ -179,6 +184,7 @@ sub read_config { curl-options rsync-options wget-options + prozilla-options )) { if (defined $config->{''}{$opt} && !exists $urpm->{options}{$opt}) { $urpm->{options}{$opt} = $config->{''}{$opt}; diff --git a/urpm/args.pm b/urpm/args.pm index b6aa04a6..a4ae78da 100644 --- a/urpm/args.pm +++ b/urpm/args.pm @@ -96,9 +96,11 @@ my %options_spec = ( 'parallel=s' => \$::parallel, wget => sub { $urpm->{options}{downloader} = 'wget' }, curl => sub { $urpm->{options}{downloader} = 'curl' }, + prozilla => sub { $urpm->{options}{downloader} = 'prozilla' }, 'curl-options=s' => sub { $urpm->{options}{'curl-options'} = $_[1] }, 'rsync-options=s' => sub { $urpm->{options}{'rsync-options'} = $_[1] }, 'wget-options=s' => sub { $urpm->{options}{'wget-options'} = $_[1] }, + 'prozilla-options=s' => sub { $urpm->{options}{'prozilla-options'} = $_[1] }, 'limit-rate=s' => sub { $urpm->{options}{'limit-rate'} = $_[1] }, 'resume!' => sub { $urpm->{options}{resume} = $_[1] }, 'retry=s' => sub { $urpm->{options}{retry} = $_[1] }, @@ -389,16 +391,16 @@ foreach my $k ("help|h", "version", "no-locales", "update", "media|mediums=s", $options_spec{urpmf}{$k} = $options_spec{urpmi}{$k}; } -foreach my $k ("help|h", "version", "wget", "curl", "proxy=s", "proxy-user=s", - "wget-options=s", "curl-options=s", "rsync-options=s") +foreach my $k ("help|h", "version", "wget", "curl", "prozilla", "proxy=s", "proxy-user=s", + "wget-options=s", "curl-options=s", "rsync-options=s", "prozilla-options=s") { $options_spec{'urpmi.update'}{$k} = $options_spec{urpmq}{$k} = $options_spec{urpmi}{$k}; } -foreach my $k ("help|h", "wget", "curl", "proxy=s", "proxy-user=s", "c", "f", "z", +foreach my $k ("help|h", "wget", "curl", "prozilla", "proxy=s", "proxy-user=s", "c", "f", "z", "limit-rate=s", "no-md5sum", "update", "norebuild!", - "wget-options=s", "curl-options=s", "rsync-options=s") + "wget-options=s", "curl-options=s", "rsync-options=s", "prozilla-options=s") { $options_spec{'urpmi.addmedia'}{$k} = $options_spec{'urpmi.update'}{$k}; } diff --git a/urpm/cfg.pm b/urpm/cfg.pm index 1493abb5..f39679e1 100644 --- a/urpm/cfg.pm +++ b/urpm/cfg.pm @@ -157,7 +157,7 @@ sub load_config ($;$) { |downloader |retry |default-media - |(?:curl|rsync|wget)-options + |(?:curl|rsync|wget|prozilla)-options )\s*:\s*['"]?(.*?)['"]?$/x and $config{$medium}{$1} = $2, next; /^key[-_]ids\s*:\s*['"]?(.*?)['"]?$/ diff --git a/urpm/download.pm b/urpm/download.pm index 57bd191b..0363f683 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -512,6 +512,30 @@ sub sync_ssh { sync_rsync($options, @_); } +sub sync_prozilla { + -x "/usr/bin/proz" or die N("prozilla is missing\n"); + my $options = shift; + $options = { dir => $options } if !ref $options; + #- force download to be done in cachedir to avoid polluting cwd. + (my $cwd) = getcwd() =~ /(.*)/; + chdir $options->{dir}; + my $proz_command = join(" ", map { "'$_'" } + "/usr/bin/proz", + "--no-curses", + (defined $options->{'prozilla-options'} ? split /\s+/, $options->{'prozilla-options'} : ()), + @_ + ); + my $ret = system($proz_command); + chdir $cwd; + if ($ret) { + if ($? == -1) { + die N("Couldn't execute prozilla\n"); + } else { + die N("prozilla failed: exited with %d or signal %d\n", $? >> 8, $? & 127); + } + } +} + sub start_ssh_master { my ($server, $user) = @_; $server or return 0; diff --git a/urpmi b/urpmi index c6dc25bd..c0361437 100755 --- a/urpmi +++ b/urpmi @@ -110,9 +110,11 @@ usage: to install a chroot with --root option. ") . N(" --wget - use wget to retrieve distant files. ") . N(" --curl - use curl to retrieve distant files. +") . N(" --prozilla - use prozilla to retrieve distant files. ") . N(" --curl-options - additional options to pass to curl ") . N(" --rsync-options- additional options to pass to rsync ") . N(" --wget-options - additional options to pass to wget +") . N(" --prozilla-options - additional options to pass to prozilla ") . N(" --limit-rate - limit the download speed. ") . N(" --resume - resume transfer of partially-downloaded files (--no-resume disables it, default is disabled). @@ -220,7 +222,7 @@ if ($restricted) { foreach (qw(keep verify-rpm norebuild)) { $urpm->{options}{$_} = 1 } #- forbid some other options urpm::error_restricted($urpm) if $root || $usedistrib || $force || $env || $parallel || $synthesis || $auto_update; - foreach (qw(allow-nodeps allow-force curl-options rsync-options wget-options noscripts)) { + foreach (qw(allow-nodeps allow-force curl-options rsync-options wget-options prozilla-options noscripts)) { urpm::error_restricted($urpm) if $urpm->{options}{$_}; } } diff --git a/urpmi.addmedia b/urpmi.addmedia index 275b5540..79ad8c32 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -44,6 +44,7 @@ and [options] are from ") . N(" --help - print this help message. ") . N(" --wget - use wget to retrieve distant files. ") . N(" --curl - use curl to retrieve distant files. +") . N(" --prozilla - use prozilla to retrieve distant files. ") . N(" --limit-rate - limit the download speed. ") . N(" --proxy - use specified HTTP proxy, the port number is assumed to be 1080 by default (format is ). diff --git a/urpmi.bash-completion b/urpmi.bash-completion index d6bf23e4..c79477f1 100644 --- a/urpmi.bash-completion +++ b/urpmi.bash-completion @@ -96,11 +96,11 @@ _urpmi() --update --media --excludemedia --sortmedia \ --synthesis --auto --auto-select --no-uninstall \ --split-level --split-length --fuzzy --src \ - --install-src --clean --noclean --parallel --wget \ + --install-src --clean --noclean --parallel --wget --prozilla \ --curl --limit-rate --proxy --proxy-user --bug \ --no-verify-rpm --no-install --test --excludepath \ --excludedocs --searchmedia --ignoresize --ignorearch \ - --strict-arch --wget-options --curl-options \ + --strict-arch --wget-options --curl-options --prozilla-options \ --rsync-options --resume --retry --skip --nolock \ --more-choices' -- $cur ) ) # add dangereous option for everything else as rurpmi @@ -165,7 +165,7 @@ _urpmq() -r -f -h -l --help --update --media --excludemedia \ --sortmedia --synthesis --auto-select --fuzzy --keep \ --list --list-url --list-media --list-nodes --list-aliases \ - --src --sources --force --parallel --wget --curl \ + --src --sources --force --parallel --wget --curl --prozilla \ --changelog --proxy --proxy-user --env --dump-config \ --use-distrib --searchmedia --ignorearch' -- $cur)) else @@ -249,7 +249,7 @@ _urpmi_update() if [[ "$cur" == -* ]]; then # return list of available options - COMPREPLY=( $( compgen -W '-a -c -f -q -v --help --wget \ + COMPREPLY=( $( compgen -W '-a -c -f -q -v --help --wget --prozilla \ --curl --limit-rate --proxy --proxy-user --update \ --ignore --no-ignore \ --no-md5sum --force-key --norebuild' \ @@ -272,7 +272,7 @@ _urpmi_addmedia() if [[ "$cur" == -* ]]; then # return list of available options - COMPREPLY=( $( compgen -W '-c -f -h -v -q --help --wget --curl \ + COMPREPLY=( $( compgen -W '-c -f -h -v -q --help --wget --curl --prozilla \ --limit-rate --proxy --proxy-user --update --raw \ --probe-synthesis --probe-hdlist --no-probe --distrib \ --env --version --arch --virtual --norebuild --nopubkey' -- $cur ) ) diff --git a/urpmi.update b/urpmi.update index 14bd5ee1..d0a0d36f 100755 --- a/urpmi.update +++ b/urpmi.update @@ -31,6 +31,7 @@ where is a medium name to update. ") . N(" --help - print this help message. ") . N(" --wget - use wget to retrieve distant files. ") . N(" --curl - use curl to retrieve distant files. +") . N(" --prozilla - use prozilla to retrieve distant files. ") . N(" --limit-rate - limit the download speed. ") . N(" --proxy - use specified HTTP proxy, the port number is assumed to be 1080 by default (format is ). diff --git a/urpmq b/urpmq index 012d72df..5f369f3a 100755 --- a/urpmq +++ b/urpmq @@ -67,6 +67,7 @@ usage: This permit to querying a distro. ") . N(" --wget - use wget to retrieve distant files. ") . N(" --curl - use curl to retrieve distant files. +") . N(" --prozilla - use prozilla to retrieve distant files. ") . N(" --proxy - use specified HTTP proxy, the port number is assumed to be 1080 by default (format is ). ") . N(" --proxy-user - specify user and password to use for proxy -- cgit v1.2.1