diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-21 15:34:57 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-06-25 14:57:16 +0100 |
commit | 9334b0d0027cf38921bd635ab24fb1c4e835f20c (patch) | |
tree | 336cfa4315da5e2d447280d1d5274c124d2734c0 /bitbake/lib/bb/tests/fetch.py | |
parent | e63dada7325857e031bc737495c62d327e816cc5 (diff) | |
download | poky-9334b0d0027cf38921bd635ab24fb1c4e835f20c.tar.gz |
bitbake: fetch2: Add new mirror syntax to simplify mirror specifications
When writing mirror specifications, the current regexp syntax can be awkward
and hard to get it to do what you want. For example, extracting the 'basename'
of a repository:
PREMIRRORS = "git://.*/([^/]+/)*([^/]*) git://somewhere.org/somedir/\\2;protocol=file"
can now become:
PREMIRRORS = "git://.*/.* git://somewhere.org/somedir/BASENAME;protocol=file"
which is much clearer. A MIRRORNAME substitution is also added which contains
an encoded form of both host and path. One of the problems with the existing
regexp syntax is you couldn't access HOST information from PATH and vice-versa
which is an issue this patch also addresses.
Tests for the new syntax are also added.
(Bitbake rev: c6b1acbad7b3d2698530eb8b5249adb4ab95da21)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/fetch.py')
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 9961343d76..1477fab0e7 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -48,7 +48,14 @@ class FetcherTest(unittest.TestCase): | |||
48 | ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://www.apache.org/dist", "http://archive.apache.org/dist") | 48 | ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://www.apache.org/dist", "http://archive.apache.org/dist") |
49 | : "http://archive.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", | 49 | : "http://archive.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", |
50 | ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://.*/.*", "file:///somepath/downloads/") | 50 | ("http://www.apache.org/dist/subversion/subversion-1.7.1.tar.bz2", "http://.*/.*", "file:///somepath/downloads/") |
51 | : "file:///somepath/downloads/subversion-1.7.1.tar.bz2" | 51 | : "file:///somepath/downloads/subversion-1.7.1.tar.bz2", |
52 | ("git://git.invalid.infradead.org/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://somewhere.org/somedir/BASENAME;protocol=http") | ||
53 | : "git://somewhere.org/somedir/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", | ||
54 | ("git://git.invalid.infradead.org/foo/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://somewhere.org/somedir/BASENAME;protocol=http") | ||
55 | : "git://somewhere.org/somedir/mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", | ||
56 | ("git://git.invalid.infradead.org/foo/mtd-utils.git;tag=1234567890123456789012345678901234567890", "git://.*/.*", "git://somewhere.org/somedir/MIRRORNAME;protocol=http") | ||
57 | : "git://somewhere.org/somedir/git.invalid.infradead.org.foo.mtd-utils.git;tag=1234567890123456789012345678901234567890;protocol=http", | ||
58 | |||
52 | #Renaming files doesn't work | 59 | #Renaming files doesn't work |
53 | #("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" | 60 | #("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" |
54 | #("file://sstate-xyz.tgz", "file://.*/.*", "file:///somewhere/1234/sstate-cache") : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", | 61 | #("file://sstate-xyz.tgz", "file://.*/.*", "file:///somewhere/1234/sstate-cache") : "file:///somewhere/1234/sstate-cache/sstate-xyz.tgz", |
@@ -143,8 +150,9 @@ class FetcherTest(unittest.TestCase): | |||
143 | for k, v in self.replaceuris.items(): | 150 | for k, v in self.replaceuris.items(): |
144 | ud = bb.fetch.FetchData(k[0], self.d) | 151 | ud = bb.fetch.FetchData(k[0], self.d) |
145 | ud.setup_localpath(self.d) | 152 | ud.setup_localpath(self.d) |
146 | newuris = bb.fetch2.uri_replace(ud, k[1], k[2], self.d) | 153 | mirrors = bb.fetch2.mirror_from_string("%s %s" % (k[1], k[2])) |
147 | self.assertEqual(newuris, v) | 154 | newuris, uds = bb.fetch2.build_mirroruris(ud, mirrors, self.d) |
155 | self.assertEqual(newuris, [v]) | ||
148 | 156 | ||
149 | def test_urilist1(self): | 157 | def test_urilist1(self): |
150 | fetcher = bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d) | 158 | fetcher = bb.fetch.FetchData("http://downloads.yoctoproject.org/releases/bitbake/bitbake-1.0.tar.gz", self.d) |