# binhost ftps support

## kai.scorpio

According to the Binary Package Guide on the wiki, portage supports ftps binhosts. However, I have not been able to get this working, as specifying a binhost with ftps:// in the URL gives:

```

!!! Error fetching binhost package info from 'ftps://binhost:*password*@myhost.tld'

!!! <urlopen error unknown url type: ftps>

```

Leaving the url starting with ftp:// I get the following error from the host (pure-ftpd with option -Y 2)

```

!!! Error fetching binhost package info from 'ftp://binhost:*password*@myhost.tld'

!!! <urlopen error ftp error: 421 Sorry, cleartext sessions are not accepted on this server.>

```

Is this a mistake on the website, or do I need to change something in the configuration?

Thanks,

Kai

----------

## Genone

Is your python built with USE=ssl enabled? (just random guessing here)

----------

## kai.scorpio

It is compiled with ssl, both in version 2.7 and 3.2.

Any other ideas? What should my config contain except those binhost lines?

Kai

----------

## Genone

Checking the relevant python documentation doesn't say anything about FTPS support in the used urllib module (the urllib2 module mentions it at least). One thing you could try is to define a FETCHCOMMAND_FTPS variable in your make.conf with a command that supports ftps:// urls (see FETCHCOMMAND documentation/examples for variables supported) as portage should use that if urlopen fails.

----------

## kai.scorpio

I have tried that with the following lines in make.conf (replacing the binhost with the correct details):

```

FETCHCOMMAND_FTP= "/usr/bin/curl -R \${URI} -o ${DISTDIR}/\${FILE} --ssl"

RESUMECOMMAND_FTP="/usr/bin/curl -R \${URI} -o ${DISTDIR}/\${FILE} --ssl -C -"

PORTAGE_BINHOST="ftp://user:password@domain.tld"
```

However, this fails with the following:

```

kai@kai-laptop ~ % sudo emerge -av links                                  

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100 1103k  100 1103k    0     0   190k      0  0:00:05  0:00:05 --:--:--  247k

!!! Binhost package index  has no TIMESTAMP field.

Fetching bininfo from ftp://user:*password*@domain.tld

!!! 421 Sorry, cleartext sessions are not accepted on this server.

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R    ] www-client/links-2.7  USE="X bzip2 deprecated gpm jpeg ssl tiff unicode zlib -directfb -fbcon -livecd -lzma (-suid) (-svga)" 3,806 kB

Total: 1 package (1 reinstall), Size of downloads: 3,806 kB

Would you like to merge these packages? [Yes/No] no

```

Note it does not suggest the binary (which is definitely available) so it must be falling back to another source (probably the official mirrors).

Fetching with cURL into a normal directory works fine. I'm not sure what I'm missing or whether portage simply does not support this. I've been considering a switch to Paludis for this reason, do you have any idea whether this would help?

Kai

----------

## Genone

Yeah, was afraid of it insisting on the Packages file and not using FETCHCOMMAND for that. Could file an enhancement request at bugs.gentoo.org about that (supporting FETCHCOMMAND for Packages file and/or using urllib2).

----------

## kai.scorpio

To me it looked like it was fetching the packages file correctly, since it shows a curl-style progress indicator. I've looked at the portage source but have been unable to find where it tries to get the TIMESTAMP header from. Do you have any other ideas? If not, I'll go file that bug report.

Kai

----------

## kai.scorpio

Further errors when using --pretend :

```

kai@kai-laptop ~ % emerge -pv keepass

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

  0 1103k    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0Warning: Failed to create the file /usr/portage/distfiles/tmpf4g9tj: 

Warning: Permission denied

  1 1103k    1 16384    0     0   3337      0  0:05:38  0:00:04  0:05:34  3490

curl: (23) Failed writing body (0 != 16384)

Fetcher exited with a failure condition.

!!! Error fetching binhost package info from 'ftp://binhost:*password*@kjw-bins.crabdance.com'

!!! FETCHCOMMAND_FTP failed

```

I'm tempted to open a request for general cURL support, but I suppose that might not get a very good response since the developers seem to have decided on wget. Any ideas on how this would work with Paludis?

Kai

----------

## Genone

Curl is just as supported as wget, the latter is simply the default for fetching distfiles that's all. For binpkgs the default is to use pythons urllib and only if that fails falling back to FETCHCOMMAND_*. I don't know how well tested the latter is though. Maybe adjusting permissions on $DISTDIR helps already.

If you want to look at the relevant code see http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=blob;f=pym/portage/dbapi/bintree.py starting at the for-loop around line 830, and more specifically the else-clause and following code around line 900.

----------

