patchPhase was being run after installPhase, causing patchelf to be
run on the left-behind binary instead of the copy in $out. Fixes:
```
$ .../bin/sc
bash: .../bin/sc: No such file or directory
$ patchelf --print-interpreter .../bin/sc
/lib64/ld-linux-x86-64.so.2
```
Many (less easily automatically converted) old-style strings
remain.
Where there was any possible ambiguity about the exact version or
variant intended, nothing was changed. IANAL, nor a search robot.
Use `with stdenv.lib` wherever it makes sense.