japaric / trust

Travis CI and AppVeyor template to test your Rust crate on 5 architectures and publish binary releases of it for Linux, macOS and Windows
Apache License 2.0
1.26k stars 59 forks source link

Install depends on rustc to find target triple #120

Open sjparkinson opened 5 years ago

sjparkinson commented 5 years ago

If --target isn't supplied there is a dependency on rustc to find the target triple.

https://github.com/japaric/trust/blob/08c86c03efb887c33abd4bd5bc3677f81bac98e7/install.sh#L99-L102

https://github.com/japaric/trust/blob/08c86c03efb887c33abd4bd5bc3677f81bac98e7/install.sh#L127

Given the usage instructions at https://github.com/japaric/trust#use-the-binary-releases-on-travis-ci, it surprised me that the script uses rustc to find the target triple.

If we could determine target by using commands like uname -a this script would be significantly more portable.

I'll try and dig up what could work across macOS and Linux.

sjparkinson commented 5 years ago

This is work in progress, but I've also run the script through shellcheck and made a few improvements such as checking if the repository returns a 404 before downloading the releases.

https://gist.github.com/sjparkinson/327dc78c60ab81a06c946630b4288910

I'll make a PR to include these changes too.

casey commented 5 years ago

A project I maintain recently ran into the issue the current trust download script fails on systems where rustc reports a linux-gnu target, because we only provide a prebuilt linux-musl target for portability reasons.

Please feel free to consider this not in-scope for this issue, but it would be nice if a linux system would try to download both the -gnu target and the -musl target. Ideally, it would try the -musl target first, because that's more likely to work on all linux versions of all linux distros, even ones that have a very old system libc.

rossmacarthur commented 3 years ago

I wrote a near drop-in replacement install script that will check for -musl, -gnu suffixes and also even doesn't require rustc to be present on the system to detect the platform (uses platform detection code take from rustup).

https://github.com/rossmacarthur/install

curl -LSfs https://rossmacarthur.github.io/install/crate.sh \
    | bash -s -- --repo "japaric/cross" --to ~/.cargo/bin