diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-22 16:36:48 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-24 10:08:24 +0000 |
commit | 8178470ec66ed7884198ac107abb103323189129 (patch) | |
tree | 5f0ba9f10b029cf81c1d312e68680cd336aa3140 | |
parent | c4f08fc43da0658fadd585790736c47a18228f5c (diff) | |
download | poky-8178470ec66ed7884198ac107abb103323189129.tar.gz |
bitbake: fetch2: Fix url remap issue and add testcase
Using "" as a target for .replace() is a really bad idea as it duplicates the replacement
for every character in the string. Add a testcase which triggered this and correct the
code to return the correct result.
(Bitbake rev: 44a83b373e1fc34c93cd4a6c6cf8b73b230c1520)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 3af1ecf049d2eed56f6d319dc7df6eb4a3d4eebc)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index b73b369517..25179bc2e6 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -473,7 +473,7 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None): | |||
473 | basename = os.path.basename(ud.localpath) | 473 | basename = os.path.basename(ud.localpath) |
474 | if basename: | 474 | if basename: |
475 | uri_basename = os.path.basename(uri_decoded[loc]) | 475 | uri_basename = os.path.basename(uri_decoded[loc]) |
476 | if basename != uri_basename and result_decoded[loc].endswith(uri_basename): | 476 | if uri_basename and basename != uri_basename and result_decoded[loc].endswith(uri_basename): |
477 | result_decoded[loc] = result_decoded[loc].replace(uri_basename, basename) | 477 | result_decoded[loc] = result_decoded[loc].replace(uri_basename, basename) |
478 | elif not result_decoded[loc].endswith(basename): | 478 | elif not result_decoded[loc].endswith(basename): |
479 | result_decoded[loc] = os.path.join(result_decoded[loc], basename) | 479 | result_decoded[loc] = os.path.join(result_decoded[loc], basename) |
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 7edbf50b5d..a85ebdf425 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -434,6 +434,7 @@ class MirrorUriTest(FetcherTest): | |||
434 | ("git://user1@someserver.org/bitbake;tag=1234567890123456789012345678901234567890;branch=master", "git://someserver.org/bitbake;branch=master", "git://user2@git.openembedded.org/bitbake;protocol=http") | 434 | ("git://user1@someserver.org/bitbake;tag=1234567890123456789012345678901234567890;branch=master", "git://someserver.org/bitbake;branch=master", "git://user2@git.openembedded.org/bitbake;protocol=http") |
435 | : "git://user2@git.openembedded.org/bitbake;tag=1234567890123456789012345678901234567890;branch=master;protocol=http", | 435 | : "git://user2@git.openembedded.org/bitbake;tag=1234567890123456789012345678901234567890;branch=master;protocol=http", |
436 | 436 | ||
437 | ("gitsm://git.qemu.org/git/seabios.git/;protocol=https;name=roms/seabios;subpath=roms/seabios;bareclone=1;nobranch=1;rev=1234567890123456789012345678901234567890", "gitsm://.*/.*", "http://petalinux.xilinx.com/sswreleases/rel-v${XILINX_VER_MAIN}/downloads") : "http://petalinux.xilinx.com/sswreleases/rel-v%24%7BXILINX_VER_MAIN%7D/downloads/git2_git.qemu.org.git.seabios.git..tar.gz", | ||
437 | 438 | ||
438 | #Renaming files doesn't work | 439 | #Renaming files doesn't work |
439 | #("http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz") : "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz" | 440 | #("http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere.org/somedir1/somefile_1.2.3.tar.gz", "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz") : "http://somewhere2.org/somedir3/somefile_2.3.4.tar.gz" |