Use fallback mirrors in the install script#291
Conversation
|
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
71fae3c to
81b1fa2
Compare
| retry curl2 -sS "$url" -o "$path" | ||
| try_all_mirrors() { | ||
| for mirror in "${mirrors[@]}" ; do | ||
| if curl2 -sS "$mirror" -o "$path" ; then |
There was a problem hiding this comment.
This is copy due to curl2 being used here and curl in download. Is there any reason not to use curl2 in download?
| mirrors=( | ||
| "https://dlang.org/install.sh" | ||
| "https://downloads.dlang.org/other/install.sh" | ||
| "https://nightlies.dlang.org/install.sh" |
There was a problem hiding this comment.
I would add https://github.com/dlang/installer/raw/stable/script/install.sh to the list too, but I wasn't sure whether you would be okay with it.
There was a problem hiding this comment.
Let's not automatically deploy this, it's not worth the security implications.
Even without sudo (which often is cached), rm -rf ~ can do a lot of damage.
script/install.sh
Outdated
| verify() { | ||
| local keyring_mirrors=( | ||
| "https://dlang.org/d-keyring.gpg" | ||
| "https://github.com/dlang/dlang.org/raw/846269e913114fd77af0cc1aff67269046b70db8/d-keyring.gpg" |
There was a problem hiding this comment.
I couldn't find another mirror for this.
There was a problem hiding this comment.
There you go, https://nightlies.dlang.org/d-keyring.gpg.
In fact you can upload files to sebastian@nightlies.dlang.org:/var/www/builds yourself.
But you cannot move or delete my entries in that folder (sticky bit). Allowing any nginx group member to mess with the install script and the signature key sounds like disaster.
|
FWIW for gdc downloads (e.g. at dlang/dmd) I still see failures related to the dub-registry being down often, e.g. https://semaphoreci.com/cybershadow/dmd/branches/pull-request-7659/builds/2, as gdc doesn't ship with dub. So it would be cool to add a mirror for the DUB binaries too (see #273) |
code.dlang.org is often down and there's no mirror for http://code.dlang.org/download/LATEST yet See also: - dlang/dub#1290 - dlang/installer#273 - dlang/installer#291 CC @ibuclaw
script/install.sh
Outdated
| "http://ftp.digitalmars.com/LATEST_BETA" | ||
| ) | ||
| logV "Determing latest dmd-beta version (${mirrors[0]})." | ||
| COMPILER="dmd-$(fetch "${mirrors[*]}")" |
There was a problem hiding this comment.
Think this should be [@] expanded, so fetch really gets 2 arguments.
cnt() { echo $#; }
args=('entry with' 'spaces')
cnt "${args[*]}" # 1
cnt "${args[@]}" # 2
cnt ${args[*]} # 3
cnt ${args[@]} # 3As with "$@" you always want to pass arguments in an array using `"${ary[@]}".
script/install.sh
Outdated
| local url path | ||
| url=$1 | ||
| local mirrors path | ||
| mirrors=($1) |
There was a problem hiding this comment.
This does IFS/whitespace splitting. Rather pass all the arguments separately on the call-side and use ("$@") here.
cnt() { echo $#; }
bug() { ary=($@); cnt "${ary[@]}"; }
bug 1 2 # -> 2
bug '1 1' 2 # -> 3 :/
ok() { ary=("$@"); cnt "${ary[@]}"; }
ok 1 2 # -> 2
ok '1 1' 2 # -> 2 :)There was a problem hiding this comment.
I'm aware (I did it on purpose after all) - urls aren't supposed to contain spaces 😉
I did have this, s.t. I can pack the urls for mirrors and their signatures as individual arguments for the download function.
script/install.sh
Outdated
| } | ||
|
|
||
| # url, path, [gpg signature url to verify] | ||
| # url and the gpg signature can be an array of urls |
There was a problem hiding this comment.
Let's change it to path, verify, url... then, and always require 0 or 1 for verify.
There was a problem hiding this comment.
The signature can be assumed to be url+.sig.
script/install.sh
Outdated
| log "Downloading $url" | ||
| download "$url" "$tmp/install.sh" "$url.sig" | ||
| log "Downloading ${mirrors[0]}" | ||
| download "${mirrors[*]}" "$tmp/install.sh" "${mirrors[*]/%/.sig}" |
There was a problem hiding this comment.
Again .sig is implicit when verify=1, so the call would be.
download "$tmp/install.sh" 1 "${mirrors[@]}"Or for better readability, use download_and_verify and plain download.
|
LMostlyGTM |
72c54ec to
24dffbf
Compare
|
Ping @MartinNowak - are we good here? |
| # path, urls... | ||
| download_without_verify() { | ||
| download "$1" 0 "${@:2}" | ||
| } |
There was a problem hiding this comment.
I added these to functions to avoid the need of passing around a magic 1 or 0
|
|
||
| # path, urls... | ||
| download_and_unpack_without_verify() { | ||
| download_and_unpack "$1" 0 "${@:2}" |
There was a problem hiding this comment.
These two functions were added to avoid passing around magic 0 or 1
|
Ping @MartinNowak - just saw another random failure on Travis :/ |
- no https on s3 - gh url for keyring needs to be updated in install.sh script (we already have a distribution/update problem for d-keyring.gpg, so let's not add another one) (also shattered.io to a tiny degree)
Failures are getting more frequent, see e.g. travis-ci/travis-build#1282
This is a first step at adding more mirrors.