diff options
author | Paul Barker <pbarker@konsulko.com> | 2020-06-03 20:31:16 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-04 13:28:16 +0100 |
commit | 1251765fff1c12d943091a2981b347e721b93e4e (patch) | |
tree | cbef15da992e57589c5be19167f33c05fe339c8f /bitbake/lib/bb | |
parent | d64809679436e9338555ef4e75ea6def93fc09c3 (diff) | |
download | poky-1251765fff1c12d943091a2981b347e721b93e4e.tar.gz |
bitbake: fetch2: Add the ability to list expanded URL data
Some fetchers may download additional sources along with those
explicitly listed in SRC_URI. These "implicit URLs" will be needed by
the archiver to ensure that all sources can be archived.
We can't just return a list of URL strings since each URL may need its
own SRCREV data so we return a list of FetchData objects.
Each fetcher can override the implicit_urldata() function to provide the
additional FetchData objects. For now this is just needed in the gitsm
fetcher to walk git submodules recursively.
(Bitbake rev: 1350f241b7d991bd191ce9e44f6662e4376c6e24)
Signed-off-by: Paul Barker <pbarker@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 25 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/gitsm.py | 21 |
2 files changed, 46 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py index eb112f069d..756f60212f 100644 --- a/bitbake/lib/bb/fetch2/__init__.py +++ b/bitbake/lib/bb/fetch2/__init__.py | |||
@@ -1617,6 +1617,13 @@ class FetchMethod(object): | |||
1617 | return True | 1617 | return True |
1618 | return False | 1618 | return False |
1619 | 1619 | ||
1620 | def implicit_urldata(self, ud, d): | ||
1621 | """ | ||
1622 | Get a list of FetchData objects for any implicit URLs that will also | ||
1623 | be downloaded when we fetch the given URL. | ||
1624 | """ | ||
1625 | return [] | ||
1626 | |||
1620 | class Fetch(object): | 1627 | class Fetch(object): |
1621 | def __init__(self, urls, d, cache = True, localonly = False, connection_cache = None): | 1628 | def __init__(self, urls, d, cache = True, localonly = False, connection_cache = None): |
1622 | if localonly and cache: | 1629 | if localonly and cache: |
@@ -1842,6 +1849,24 @@ class Fetch(object): | |||
1842 | if ud.lockfile: | 1849 | if ud.lockfile: |
1843 | bb.utils.unlockfile(lf) | 1850 | bb.utils.unlockfile(lf) |
1844 | 1851 | ||
1852 | def expanded_urldata(self, urls=None): | ||
1853 | """ | ||
1854 | Get an expanded list of FetchData objects covering both the given | ||
1855 | URLS and any additional implicit URLs that are added automatically by | ||
1856 | the appropriate FetchMethod. | ||
1857 | """ | ||
1858 | |||
1859 | if not urls: | ||
1860 | urls = self.urls | ||
1861 | |||
1862 | urldata = [] | ||
1863 | for url in urls: | ||
1864 | ud = self.ud[url] | ||
1865 | urldata.append(ud) | ||
1866 | urldata += ud.method.implicit_urldata(ud, self.d) | ||
1867 | |||
1868 | return urldata | ||
1869 | |||
1845 | class FetchConnectionCache(object): | 1870 | class FetchConnectionCache(object): |
1846 | """ | 1871 | """ |
1847 | A class which represents an container for socket connections. | 1872 | A class which represents an container for socket connections. |
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py index e7083001da..56bd5f0480 100644 --- a/bitbake/lib/bb/fetch2/gitsm.py +++ b/bitbake/lib/bb/fetch2/gitsm.py | |||
@@ -223,3 +223,24 @@ class GitSM(Git): | |||
223 | # up the configuration and checks out the files. The main project config should remain | 223 | # up the configuration and checks out the files. The main project config should remain |
224 | # unmodified, and no download from the internet should occur. | 224 | # unmodified, and no download from the internet should occur. |
225 | runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) | 225 | runfetchcmd("%s submodule update --recursive --no-fetch" % (ud.basecmd), d, quiet=True, workdir=ud.destdir) |
226 | |||
227 | def implicit_urldata(self, ud, d): | ||
228 | import shutil, subprocess, tempfile | ||
229 | |||
230 | urldata = [] | ||
231 | def add_submodule(ud, url, module, modpath, workdir, d): | ||
232 | url += ";bareclone=1;nobranch=1" | ||
233 | newfetch = Fetch([url], d, cache=False) | ||
234 | urldata.extend(newfetch.expanded_urldata()) | ||
235 | |||
236 | # If we're using a shallow mirror tarball it needs to be unpacked | ||
237 | # temporarily so that we can examine the .gitmodules file | ||
238 | if ud.shallow and os.path.exists(ud.fullshallow) and ud.method.need_update(ud, d): | ||
239 | tmpdir = tempfile.mkdtemp(dir=d.getVar("DL_DIR")) | ||
240 | subprocess.check_call("tar -xzf %s" % ud.fullshallow, cwd=tmpdir, shell=True) | ||
241 | self.process_submodules(ud, tmpdir, add_submodule, d) | ||
242 | shutil.rmtree(tmpdir) | ||
243 | else: | ||
244 | self.process_submodules(ud, ud.clonedir, add_submodule, d) | ||
245 | |||
246 | return urldata | ||