In format_repo_ident(), look for the "repository" annotation if PKG_REPONAME is undefined.  Use this to implement the %R query pattern.
Some tunes for portable compiling.
Merge pull request #855 from dag-erling/query-R

Implement the %R query pattern