packages/pkgbuild: pkgbuild_sources, pkgbuild_ls_files: fix sorting.

Move PKGBUILD line generation into pkgbuild_sources (semantic change!).
packages/pkgbuild: add _pkgbuild_vcs_get_legacy, remove similar code pieces.

_pkgbuild_vcs_get_legacy: get legacy repo name if it exists, otherwise return 1.