Re: [PATCH] fetch2: honour PATH placeholder on cross-scheme PREMIRROR rewrites

Paul Barker <[email protected]> Mon, 18 May 2026 19:55:00 +0100
Newsgroups org.openembedded.lists.bitbake-devel
Message-ID <[email protected]>
On Sun, 2026-05-10 at 14:00 +0200, Jhonata Poma-Hansen wrote:
> When a PREMIRROR rule rewrites a fetch URL to a different scheme
> (typically gitsm:// -> git:// for an on-disk checkout), uri_replace()
> unconditionally treats the rewrite as a mirrortarball mapping: it
> substitutes the source URL's path basename with the canonical mirror
> tarball name (git2_<host>.<repo>.tar.gz) and drops the source URL
> parameters. That is correct for tarball mirrors but breaks the case
> where the user redirects to a checkout location using HOST/PATH
> placeholders.
> 
> niqingliang2003 reported this on YOCTO #14156 (2025-07-18) with a
> PREMIRROR of:
> 
>   gitsm://.*/.*  git:///mnt/datum/repositories/HOST/PATH;protocol=file
> 
> For the input:
> 
>   gitsm://github.com/libjxl/libjxl.git;protocol=https;nobranch=1
> 
> the rewrite produces:
> 
>   git:///mnt/datum/repositories/github.com/libjxl/git2_github.com.libjxl.libjxl.git.tar.gz;protocol=file
> 
> instead of the user-intended:
> 
>   git:///mnt/datum/repositories/github.com/libjxl/libjxl.git;protocol=file;nobranch=1

Hi Jhonata,

This fixes the use case in the referenced bug, but is this universally
true whenever PATH is used in a PREMIRRORS entry? In the past I have
typically generated mirror tarballs, hosted them on a HTTP service and
put that URL in PREMIRRORS, so in that case I would expect the mirror
tarballs to be downloaded.

What you may actually want to do is handle git:// URLs in the target of
a PREMIRRORS entry, instead of looking for PATH in the URL.

> 
> The mirror fetch then fails because the resulting URL has no nobranch
> or branch parameter and no actual tarball exists at the path.
> 
> When the replacement template references the PATH placeholder, the
> user has explicitly asked for the source path to appear in the
> rewritten URL. In that case, skip the mirrortarball-basename override
> and carry the source URL parameters through. Existing PREMIRROR rules
> that do not use PATH (the canonical tarball-mirror layout) continue
> to work unchanged.
> 
> A new selftest, MirrorUriTest.test_gitsm_premirror_path_placeholder,
> captures the exact niqingliang2003 repro shape so a regression in
> this area becomes a unit-level failure rather than a runtime mirror
> fetch error.
> 
> The dict-driven test_urireplace and the broader
> GitDownloadDirectoryNamingTest / TarballNamingTest /
> GitShallowTarballNamingTest / CleanTarballTest / FetcherLocalTest /
> FetcherNoNetworkTest suites all stay green with this change (42 of
> 42 relevant fetch tests pass on master + this patch; network-only
> tests not run).
> 
> Note for reviewers: a wider bitbake-selftest run shows 4 pre-existing
> GitShallowTest errors triggered by local git environment
> (commit.gpgsign + empty editor config); they reproduce on the parent
> commit and are not related to this change.
> 
> Signed-off-by: Jhonata Poma-Hansen <[email protected]>

The commit message and comments here are way too verbose, please tidy
these up to be more readable. Please see the docs [1] on how to
reference Yocto bugs in commit messages and check if the section on AI
generated code applies here [2].

[1]: https://docs.yoctoproject.org/contributor-guide/submit-changes.html#implement-and-commit-changes
[2]: https://docs.yoctoproject.org/contributor-guide/submit-changes.html#acceptance-of-ai-generated-code

Best regards,

-- 
Paul Barker
signature.asc (application/pgp-signature, 252 B)
-----BEGIN PGP SIGNATURE-----

iIcEABYKAC8WIQSzjPXf5Y1BDWhU2iCrY1Tsnbr0bgUCagtghBEccGF1bEBwYmFy
a2VyLmRldgAKCRCrY1Tsnbr0buAMAP4szMihcdkarZ2Dl5rP26kPDwfPR0Ua3UKz
RsW13LXWpwD+ORrwT4trJbwIQJrmxbD2FLcLQzD9d/dsVXVHjQ1t0Qk=
=RY5d
-----END PGP SIGNATURE-----