fetch2: make sure the uri added as expected
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/1 fetch2: make sure the uri added as expected
From: Mingli Yu <[email protected]>
When call uri_replace to get the new uris, we should guarantee the new uri is added when the replace uri begins with file if the find uri begin with wildcard which mapped as below.
PREMIRRORS_append = " \
.*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \
" | |
| |
| |
find replaceBefore the patch:
the original uri gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https
PREMIRRORS_append = " \
.*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \"
The new uri is git://somewhere.org/somedir/github.com.tianocore.edk2.git/git2_github.com.tianocore.edk2.git.tar.gz;protocol=http
After the patch:
the original uri gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https
PREMIRRORS_append = " \
.*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \"
The new uri is None as the find begins with wildcard but the replace doesn't begin with file.
--- lib/bb/fetch2/__init__.py | 2 ++ lib/bb/tests/fetch.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
lib/bb/fetch2/__init__.py +2 -0
@@ -430,6 +430,8 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None): uri_replace_decoded = list(decodeurl(uri_replace)) logger.debug2("For url %s comparing %s to %s" % (uri_decoded, uri_find_decoded, uri_replace_decoded)) result_decoded = ['', '', '', '', '', {}] + if uri_find_decoded[0] == '.*' and uri_replace_decoded[0] != 'file': + uri_find_decoded[0] = uri_replace_decoded[0] for loc, i in enumerate(uri_find_decoded): result_decoded[loc] = uri_decoded[loc] regexp = i
lib/bb/tests/fetch.py +7 -1
@@ -406,6 +406,8 @@ class MirrorUriTest(FetcherTest): : "git://somewhere.org/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", ("git://someserver.org/bitbake;tag=1234567890123456789012345678901234567890", "git://someserver.org/bitbake", "git://git.openembedded.org/bitbake") : "git://git.openembedded.org/bitbake;tag=1234567890123456789012345678901234567890", + ("gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https", ".*://.*/.*", "git://somewhere.org/somedir/MIRRORNAME;protocol=http") + : None, ("file://sstate-xyz.tgz", "file://.*", "file:///somewhere/1234/sstate-cache") : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", ("file://sstate-xyz.tgz", "file://.*", "file:///somewhere/1234/sstate-cache/")
@@ -447,7 +449,11 @@ class MirrorUriTest(FetcherTest): ud.setup_localpath(self.d) mirrors = bb.fetch2.mirror_from_string("%s %s" % (k[1], k[2])) newuris, uds = bb.fetch2.build_mirroruris(ud, mirrors, self.d) - self.assertEqual([v], newuris) + if not v: + self.assertEqual([v], newuris) + else: + self.assertEqual([], newuris) + def test_urilist1(self): fetcher = bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d)
Signature · 1 line
2.29.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
Any comments?
Thanks,
Quoted 81 lines · Mingli
From: Mingli Yu <[email protected]>
When call
uri_replaceto get the new uris, we should guarantee the new uri is added when the replace uri begins with file if the find uri begin with wildcard which mapped as below.PREMIRRORS_append = " \ .*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \ " | | | | | | find replaceBefore the patch:
the original uri gitsm://github.com/tianocore/edk2.git;branch=master;protocol=httpsPREMIRRORS_append = " \ .*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \"
The new uri isgit://somewhere.org/somedir/github.com.tianocore.edk2.git/git2_github.com.tianocore.edk2.git.tar.gz;protocol=httpAfter the patch:
the original uri gitsm://github.com/tianocore/edk2.git;branch=master;protocol=httpsPREMIRRORS_append = " \ .*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \"
The new uri is None as the find begins with wildcard but the replace doesn't begin with file.Signed-off-by Mingli Yu <[email protected]>--- lib/bb/fetch2/__init__.py | 2 ++ lib/bb/tests/fetch.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)lib/bb/fetch2/__init__.py +2
-0@@ -430,6 +430,8 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None): uri_replace_decoded = list(decodeurl(uri_replace)) logger.debug2("For url %s comparing %s to %s" % (uri_decoded, uri_find_decoded, uri_replace_decoded)) result_decoded = ['', '', '', '', '', {}] + if uri_find_decoded[0] == '.*' and uri_replace_decoded[0] != 'file': + uri_find_decoded[0] = uri_replace_decoded[0] for loc, i in enumerate(uri_find_decoded): result_decoded[loc] = uri_decoded[loc] regexp = ilib/bb/tests/fetch.py +7
-1@@ -406,6 +406,8 @@ class MirrorUriTest(FetcherTest): : "git://somewhere.org/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", ("git://someserver.org/bitbake;tag=1234567890123456789012345678901234567890", "git://someserver.org/bitbake", "git://git.openembedded.org/bitbake") : "git://git.openembedded.org/bitbake;tag=1234567890123456789012345678901234567890", + ("gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https", ".*://.*/.*", "git://somewhere.org/somedir/MIRRORNAME;protocol=http") + : None, ("file://sstate-xyz.tgz", "file://.*", "file:///somewhere/1234/sstate-cache") : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", ("file://sstate-xyz.tgz", "file://.*", "file:///somewhere/1234/sstate-cache/")@@ -447,7 +449,11 @@ class MirrorUriTest(FetcherTest): ud.setup_localpath(self.d) mirrors = bb.fetch2.mirror_from_string("%s %s" % (k[1], k[2])) newuris, uds = bb.fetch2.build_mirroruris(ud, mirrors, self.d) - self.assertEqual([v], newuris) + if not v: + self.assertEqual([v], newuris) + else: + self.assertEqual([], newuris) + def test_urilist1(self): fetcher = bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d)
Ping.
Thanks,
Quoted 81 lines · Mingli
From: Mingli Yu <[email protected]>
When call
uri_replaceto get the new uris, we should guarantee the new uri is added when the replace uri begins with file if the find uri begin with wildcard which mapped as below.PREMIRRORS_append = " \ .*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \ " | | | | | | find replaceBefore the patch:
the original uri gitsm://github.com/tianocore/edk2.git;branch=master;protocol=httpsPREMIRRORS_append = " \ .*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \"
The new uri isgit://somewhere.org/somedir/github.com.tianocore.edk2.git/git2_github.com.tianocore.edk2.git.tar.gz;protocol=httpAfter the patch:
the original uri gitsm://github.com/tianocore/edk2.git;branch=master;protocol=httpsPREMIRRORS_append = " \ .*://.*/.* git://somewhere.org/somedir/MIRRORNAME;protocol=http \n \"
The new uri is None as the find begins with wildcard but the replace doesn't begin with file.Signed-off-by Mingli Yu <[email protected]>--- lib/bb/fetch2/__init__.py | 2 ++ lib/bb/tests/fetch.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-)lib/bb/fetch2/__init__.py +2
-0@@ -430,6 +430,8 @@ def uri_replace(ud, uri_find, uri_replace, replacements, d, mirrortarball=None): uri_replace_decoded = list(decodeurl(uri_replace)) logger.debug2("For url %s comparing %s to %s" % (uri_decoded, uri_find_decoded, uri_replace_decoded)) result_decoded = ['', '', '', '', '', {}] + if uri_find_decoded[0] == '.*' and uri_replace_decoded[0] != 'file': + uri_find_decoded[0] = uri_replace_decoded[0] for loc, i in enumerate(uri_find_decoded): result_decoded[loc] = uri_decoded[loc] regexp = ilib/bb/tests/fetch.py +7
-1@@ -406,6 +406,8 @@ class MirrorUriTest(FetcherTest): : "git://somewhere.org/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", ("git://someserver.org/bitbake;tag=1234567890123456789012345678901234567890", "git://someserver.org/bitbake", "git://git.openembedded.org/bitbake") : "git://git.openembedded.org/bitbake;tag=1234567890123456789012345678901234567890", + ("gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https", ".*://.*/.*", "git://somewhere.org/somedir/MIRRORNAME;protocol=http") + : None, ("file://sstate-xyz.tgz", "file://.*", "file:///somewhere/1234/sstate-cache") : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", ("file://sstate-xyz.tgz", "file://.*", "file:///somewhere/1234/sstate-cache/")@@ -447,7 +449,11 @@ class MirrorUriTest(FetcherTest): ud.setup_localpath(self.d) mirrors = bb.fetch2.mirror_from_string("%s %s" % (k[1], k[2])) newuris, uds = bb.fetch2.build_mirroruris(ud, mirrors, self.d) - self.assertEqual([v], newuris) + if not v: + self.assertEqual([v], newuris) + else: + self.assertEqual([], newuris) + def test_urilist1(self): fetcher = bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d)