packages/pkgbuild: internal makepkg: prepare the file for library-like usage.

Remove unwanted parts of "main" code and make check_build_status a stub.
packages/pkgbuild: pkgbuild_version: add epoch support.

(copied from makepkg code)
packages/pkgbuild: improve parameter passing in _pkgbuild_vcs_process.

Use (existing) bash local variables instead of positional arguments
to pass some data.
packages/pkgbuild: add top-level support for new-style VCS repositories.

- add library functions _pkgbuild_vcs_get_repo_name and
_pkgbuild_vcs_match_repo_type
- source the makepkg internal file to parse the PKGBUILD
and prepare the sources
- use "$srcdir" instead of "$DIR/src"
- finally, iterate over source array and find VCS elements to process
scripts/globals: fix report_debug to avoid returning false when debug is disabled.
packages/pkgbuild: fix epoch handling in pkgbuild_version
packages/pkgbuild: internal makepkg: re-add "Sources are ready" message at the end of fetch.
packages/pkgbuild: pkgbuild_update: fix error handling (popd before returning).
packages/pkgbuild: pkgbuild_update: fix check for PKGBUILD (it's a file, not directory).
packages/pkgbuild: pkgbuild_update: force-remove target directory if it is not intact.

If at the target neither git-tree nor PKBUILD exists, the directory is
probably not worth keeping at all.
packages/pkgbuild: pkgbuild_update_vcs: add error handling.
packages/pkgbuild: pkgbuild_update_vcs: minor fixes (tolerate input data better).
packages/pkgbuild: _pkgbuild_vcs_handle_legacy: downgrade "no legacy repos" diagnostic to debug.
packages/pkgbuild: revert local version changes before comparing PKGBUILD version to AUR.

Since we want to re-download tarball from AUR if version changes,
we'd better use verbatim version from previous fetch than our local
version when comparing these.

Fixes behavior in following scenario:
"v1 fetched - built v3 from upstream - v2 released"
packages/pkgbuild: save/restore file mtime when reverting local changes (esp. pkgver).

Hence do not cause unneeded rebuilds.
packages/pkgbuild: _pkgbuild_update_selective_revert: apply residual diff only if it isn't empty.

Avoid "fatal: unrecognized input" message from git-apply.
packages/pkgbuild: internal makepkg: make update_pkgver a stub.

Hence do not cause unneeded rebuilds (do not modify PKGBUILD before
rebuilding is actually determined to be required).