Project

General

Profile

Bug #1136

[pacman] pacman.conf: curl XferCommand broken (mirror redirect)

GNUtoo - almost 6 years ago - . Updated over 4 years ago.

Status:
fixed
Priority:
feature
Assignee:
% Done:

100%


Description

Hi, in pacman.conf we have:

#XferCommand = /usr/bin/curl -C - -f %u > %o

If we uncomment it, curl will download the mirror redirect page:

$ /usr/bin/curl -C - -f https://redirector.parabola.nu/libre/os/i686/vim-runtime-8.0.0055-1.parabola1-i686.pkg.tar.xz > file.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   161  100   161    0     0    228      0 --:--:-- --:--:-- --:--:--   228
$ cat file.tar.xz 
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.10.1</center>
</body>
</html>

$ man curl
has the following:
       -L, --location
              (HTTP/HTTPS) If the server reports that the requested page has moved to a different location (indicated with
              a  Location:  header and a 3XX response code), this option will make curl redo the request on the new place.
              If used together with -i, --include or -I, --head, headers from all requested  pages  will  be  shown.  When
              authentication  is  used, curl only sends its credentials to the initial host. If a redirect takes curl to a
              different host, it won't be able to intercept the user+password.  See  also  --location-trusted  on  how  to
              change this. You can limit the amount of redirects to follow by using the --max-redirs option.

              When  curl  follows  a redirect and the request is not a plain GET (for example POST or PUT), it will do the
              following request with a GET if the HTTP response was 301, 302, or 303. If the response code was  any  other
              3xx code, curl will re-send the following request using the same unmodified method.

              You  can  tell  curl to not change the non-GET request method to GET after a 30x response by using the dedi‐
              cated options for that: --post301, --post302 and --post303.

Using -L result in the correct file being downloaded:

$ /usr/bin/curl -L -C - -f https://redirector.parabola.nu/libre/os/i686/vim-runtime-8.0.0055-1.parabola1-i686.pkg.tar.xz > file.tar.xz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   161  100   161    0     0    424      0 --:--:-- --:--:-- --:--:--   424
  0     0    0     0    0     0      0      0 --:--:--  0:00:05 --:--:--     0
100 5269k  100 5269k    0     0   661k      0  0:00:07  0:00:07 --:--:-- 3465k
$ file file.tar.xz 
file.tar.xz: XZ compressed data
$ tar tf file.tar.xz | head -n 10
.PKGINFO
.BUILDINFO
.MTREE
etc/
etc/vimrc
usr/
usr/share/
usr/share/libalpm/
usr/share/licenses/
usr/share/vim/

So we should change pacman.conf to use something like that instead:

#XferCommand = /usr/bin/curl -L -C - -f %u > %o

History

#1

Updated by isacdaavid almost 6 years ago

  • Priority changed from bug to feature

While we are at it, I suggest:

#XferCommand = /usr/bin/curl -L -C - -f -o %o %u

Output redirection kills partial downloads.

#2

Updated by oaken-source over 4 years ago

  • % Done changed from 0 to 100
  • Assignee set to oaken-source
  • Status changed from open to fixed

silence is consent. I applied the proposed changes.
-A

Also available in: Atom PDF