Fix target-dir update checks, fixes #2395
Retry on some 5xx errors

`composer install` gives me some intermittent 502 errors on github. Composer already does some retries. I think, on 502, 503 and 504, we should retry.
Merge pull request #2397 from smaftoul/patch-1

Retry on some 5xx errors