Expand description
Getting a file onto this machine with a program the machine already has.
Design: spec/cross-compile/13-distribution.md section 13.8. That section divides a fetch in
two, and crate::install is the half that decides whether the result is correct. This is the
other half, the transport, which is the one part of a fetch that is not ours to get right and is
ours to get out of the way of.
§Why there is no HTTP client here
Because there is no HTTP client anywhere in rucc. spec/18-package-layout.md section 18.3 is a
dependency budget the compiler is held to, an HTTP client brings a TLS stack with it, and a TLS
stack is a thing with a security release schedule attached. So the bytes are moved by curl,
wget or PowerShell, all three of which are already on the hosts in the support table and all
three of which are somebody else’s job to keep current.
The division of trust that comes out of that is worth saying plainly. The downloader authenticates the connection and we authenticate the bytes. A downloader that was lied to hands us a file that does not match the hash this release pins, and that file is deleted rather than unpacked, so the worst a bad connection can do is stop a fetch.
§The order, and what a failure means
curl, then wget, then PowerShell, which is section 13.8’s order. A downloader that cannot be
run is the next one’s turn. A downloader that ran and failed is the end of it: a server that
said no is not a reason to ask it again with a different client, and a disk that is full will be
full for the second one too.
Nothing searches a PATH or a PATHEXT to find out whether a program is there, because the
question is whether the program can be run and the answer to that is what happens when it is
run.
§The machine with none of the three
It is told the URL, the hash and the exact path to put a file at, and a second run carries on from the check rather than starting again. So a host with no downloader is still a host somebody can cross compile on, which is what makes the decision above cheap rather than clever.
Enums§
- Downloader
- A program that can move bytes off a URL.
- Fetched
- How a file got to where it was asked for.
Functions§
- fetch
- Get the file at
urltointo, and refuse anything that is not the artifactsha256names.