stdlib-git: improve integration with git-external (#30075)
Previously some of the work was shifted, leading to awkward extraneous copies
and preventing usage of DEPS_GIT=1 mode (the main point of this script).
There also seemed to be unexpected failure modes in the current usage
where the files in stdlib/Pkg would routinely go missing for me. I don't know
the source of those, but I hope that this will fix it (because it makes more of
the state immutable).
Also noticed some issues with existing scripts (expanding variables at
unintended points, not rebuilding on some changes), and fixed those.