On 9/6/21 6:27 AM, Scott Weaver wrote:
When downloadfilename is defined in a recipe's SRC_URI and PREMIRRORS is also
defined using the same URI, the downloadfilename is appended to the mirror
URI and it should not be.

[YOCTO #13039]

As I commented in the bugzilla, I suppose it is an invalid bug.

It save the tarball with the name of the value of downloadfilename rather than the basename of the url.
In this case, the name of tarball in the premirror downloads/ directory is uthash-2.0.2.tar.gz rather than
2.0.2.tar.gz if the premirror is created by run bitbake do_fetch. So when premirror is used, it checks
uthash-2.0.2.tar.gz in the premirrors but not the original value '2.0.2.tar.gz'.

With this patch, it fails to fetch the tarball from premirrors. It could be reproduced by config:

BB_NO_NETWORK = "1"
BB_FETCH_PREMIRRORONLY = "1"

Regards,
Kai

Signed-off-by: Scott Weaver <weaverjs@gmail.com>
---
 bitbake/lib/bb/fetch2/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 914fa5c024..47a4943369 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -466,7 +466,7 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None):
                     # Kill parameters, they make no sense for mirror tarballs
                     uri_decoded[5] = {}
                 elif ud.localpath and ud.method.supports_checksum(ud):
-                    basename = os.path.basename(ud.localpath)
+                    basename = os.path.basename(uri_decoded[loc])
                 if basename and not result_decoded[loc].endswith(basename):
                     result_decoded[loc] = os.path.join(result_decoded[loc], basename)
         else:




-- 
Kai Kang
Wind River Linux