xref: /OK3568_Linux_fs/yocto/poky/bitbake/doc/bitbake-user-manual/bitbake-user-manual-fetching.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: CC-BY-2.5
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun=====================
4*4882a593SmuzhiyunFile Download Support
5*4882a593Smuzhiyun=====================
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun|
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunBitBake's fetch module is a standalone piece of library code that deals
10*4882a593Smuzhiyunwith the intricacies of downloading source code and files from remote
11*4882a593Smuzhiyunsystems. Fetching source code is one of the cornerstones of building
12*4882a593Smuzhiyunsoftware. As such, this module forms an important part of BitBake.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunThe current fetch module is called "fetch2" and refers to the fact that
15*4882a593Smuzhiyunit is the second major version of the API. The original version is
16*4882a593Smuzhiyunobsolete and has been removed from the codebase. Thus, in all cases,
17*4882a593Smuzhiyun"fetch" refers to "fetch2" in this manual.
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunThe Download (Fetch)
20*4882a593Smuzhiyun====================
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunBitBake takes several steps when fetching source code or files. The
23*4882a593Smuzhiyunfetcher codebase deals with two distinct processes in order: obtaining
24*4882a593Smuzhiyunthe files from somewhere (cached or otherwise) and then unpacking those
25*4882a593Smuzhiyunfiles into a specific location and perhaps in a specific way. Getting
26*4882a593Smuzhiyunand unpacking the files is often optionally followed by patching.
27*4882a593SmuzhiyunPatching, however, is not covered by this module.
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunThe code to execute the first part of this process, a fetch, looks
30*4882a593Smuzhiyunsomething like the following::
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun   src_uri = (d.getVar('SRC_URI') or "").split()
33*4882a593Smuzhiyun   fetcher = bb.fetch2.Fetch(src_uri, d)
34*4882a593Smuzhiyun   fetcher.download()
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunThis code sets up an instance of the fetch class. The instance uses a
37*4882a593Smuzhiyunspace-separated list of URLs from the :term:`SRC_URI`
38*4882a593Smuzhiyunvariable and then calls the ``download`` method to download the files.
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunThe instantiation of the fetch class is usually followed by::
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun   rootdir = l.getVar('WORKDIR')
43*4882a593Smuzhiyun   fetcher.unpack(rootdir)
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunThis code unpacks the downloaded files to the specified by ``WORKDIR``.
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun.. note::
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun   For convenience, the naming in these examples matches the variables
50*4882a593Smuzhiyun   used by OpenEmbedded. If you want to see the above code in action,
51*4882a593Smuzhiyun   examine the OpenEmbedded class file ``base.bbclass``
52*4882a593Smuzhiyun   .
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunThe :term:`SRC_URI` and ``WORKDIR`` variables are not hardcoded into the
55*4882a593Smuzhiyunfetcher, since those fetcher methods can be (and are) called with
56*4882a593Smuzhiyundifferent variable names. In OpenEmbedded for example, the shared state
57*4882a593Smuzhiyun(sstate) code uses the fetch module to fetch the sstate files.
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunWhen the ``download()`` method is called, BitBake tries to resolve the
60*4882a593SmuzhiyunURLs by looking for source files in a specific search order:
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun-  *Pre-mirror Sites:* BitBake first uses pre-mirrors to try and find
63*4882a593Smuzhiyun   source files. These locations are defined using the
64*4882a593Smuzhiyun   :term:`PREMIRRORS` variable.
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun-  *Source URI:* If pre-mirrors fail, BitBake uses the original URL (e.g
67*4882a593Smuzhiyun   from :term:`SRC_URI`).
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun-  *Mirror Sites:* If fetch failures occur, BitBake next uses mirror
70*4882a593Smuzhiyun   locations as defined by the :term:`MIRRORS` variable.
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunFor each URL passed to the fetcher, the fetcher calls the submodule that
73*4882a593Smuzhiyunhandles that particular URL type. This behavior can be the source of
74*4882a593Smuzhiyunsome confusion when you are providing URLs for the :term:`SRC_URI` variable.
75*4882a593SmuzhiyunConsider the following two URLs::
76*4882a593Smuzhiyun
77*4882a593Smuzhiyun   https://git.yoctoproject.org/git/poky;protocol=git
78*4882a593Smuzhiyun   git://git.yoctoproject.org/git/poky;protocol=http
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunIn the former case, the URL is passed to the ``wget`` fetcher, which does not
81*4882a593Smuzhiyununderstand "git". Therefore, the latter case is the correct form since the Git
82*4882a593Smuzhiyunfetcher does know how to use HTTP as a transport.
83*4882a593Smuzhiyun
84*4882a593SmuzhiyunHere are some examples that show commonly used mirror definitions::
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun   PREMIRRORS ?= "\
87*4882a593Smuzhiyun      bzr://.*/.\*  http://somemirror.org/sources/ \
88*4882a593Smuzhiyun      cvs://.*/.\*  http://somemirror.org/sources/ \
89*4882a593Smuzhiyun      git://.*/.\*  http://somemirror.org/sources/ \
90*4882a593Smuzhiyun      hg://.*/.\*   http://somemirror.org/sources/ \
91*4882a593Smuzhiyun      osc://.*/.\*  http://somemirror.org/sources/ \
92*4882a593Smuzhiyun      p4://.*/.\*   http://somemirror.org/sources/ \
93*4882a593Smuzhiyun     svn://.*/.\*   http://somemirror.org/sources/"
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun   MIRRORS =+ "\
96*4882a593Smuzhiyun      ftp://.*/.\*   http://somemirror.org/sources/ \
97*4882a593Smuzhiyun      http://.*/.\*  http://somemirror.org/sources/ \
98*4882a593Smuzhiyun      https://.*/.\* http://somemirror.org/sources/"
99*4882a593Smuzhiyun
100*4882a593SmuzhiyunIt is useful to note that BitBake
101*4882a593Smuzhiyunsupports cross-URLs. It is possible to mirror a Git repository on an
102*4882a593SmuzhiyunHTTP server as a tarball. This is what the ``git://`` mapping in the
103*4882a593Smuzhiyunprevious example does.
104*4882a593Smuzhiyun
105*4882a593SmuzhiyunSince network accesses are slow, BitBake maintains a cache of files
106*4882a593Smuzhiyundownloaded from the network. Any source files that are not local (i.e.
107*4882a593Smuzhiyundownloaded from the Internet) are placed into the download directory,
108*4882a593Smuzhiyunwhich is specified by the :term:`DL_DIR` variable.
109*4882a593Smuzhiyun
110*4882a593SmuzhiyunFile integrity is of key importance for reproducing builds. For
111*4882a593Smuzhiyunnon-local archive downloads, the fetcher code can verify SHA-256 and MD5
112*4882a593Smuzhiyunchecksums to ensure the archives have been downloaded correctly. You can
113*4882a593Smuzhiyunspecify these checksums by using the :term:`SRC_URI` variable with the
114*4882a593Smuzhiyunappropriate varflags as follows::
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun   SRC_URI[md5sum] = "value"
117*4882a593Smuzhiyun   SRC_URI[sha256sum] = "value"
118*4882a593Smuzhiyun
119*4882a593SmuzhiyunYou can also specify the checksums as
120*4882a593Smuzhiyunparameters on the :term:`SRC_URI` as shown below::
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun  SRC_URI = "http://example.com/foobar.tar.bz2;md5sum=4a8e0f237e961fd7785d19d07fdb994d"
123*4882a593Smuzhiyun
124*4882a593SmuzhiyunIf multiple URIs exist, you can specify the checksums either directly as
125*4882a593Smuzhiyunin the previous example, or you can name the URLs. The following syntax
126*4882a593Smuzhiyunshows how you name the URIs::
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun   SRC_URI = "http://example.com/foobar.tar.bz2;name=foo"
129*4882a593Smuzhiyun   SRC_URI[foo.md5sum] = 4a8e0f237e961fd7785d19d07fdb994d
130*4882a593Smuzhiyun
131*4882a593SmuzhiyunAfter a file has been downloaded and
132*4882a593Smuzhiyunhas had its checksum checked, a ".done" stamp is placed in :term:`DL_DIR`.
133*4882a593SmuzhiyunBitBake uses this stamp during subsequent builds to avoid downloading or
134*4882a593Smuzhiyuncomparing a checksum for the file again.
135*4882a593Smuzhiyun
136*4882a593Smuzhiyun.. note::
137*4882a593Smuzhiyun
138*4882a593Smuzhiyun   It is assumed that local storage is safe from data corruption. If
139*4882a593Smuzhiyun   this were not the case, there would be bigger issues to worry about.
140*4882a593Smuzhiyun
141*4882a593SmuzhiyunIf :term:`BB_STRICT_CHECKSUM` is set, any
142*4882a593Smuzhiyundownload without a checksum triggers an error message. The
143*4882a593Smuzhiyun:term:`BB_NO_NETWORK` variable can be used to
144*4882a593Smuzhiyunmake any attempted network access a fatal error, which is useful for
145*4882a593Smuzhiyunchecking that mirrors are complete as well as other things.
146*4882a593Smuzhiyun
147*4882a593SmuzhiyunIf :term:`BB_CHECK_SSL_CERTS` is set to ``0`` then SSL certificate checking will
148*4882a593Smuzhiyunbe disabled. This variable defaults to ``1`` so SSL certificates are normally
149*4882a593Smuzhiyunchecked.
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun.. _bb-the-unpack:
152*4882a593Smuzhiyun
153*4882a593SmuzhiyunThe Unpack
154*4882a593Smuzhiyun==========
155*4882a593Smuzhiyun
156*4882a593SmuzhiyunThe unpack process usually immediately follows the download. For all
157*4882a593SmuzhiyunURLs except Git URLs, BitBake uses the common ``unpack`` method.
158*4882a593Smuzhiyun
159*4882a593SmuzhiyunA number of parameters exist that you can specify within the URL to
160*4882a593Smuzhiyungovern the behavior of the unpack stage:
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun-  *unpack:* Controls whether the URL components are unpacked. If set to
163*4882a593Smuzhiyun   "1", which is the default, the components are unpacked. If set to
164*4882a593Smuzhiyun   "0", the unpack stage leaves the file alone. This parameter is useful
165*4882a593Smuzhiyun   when you want an archive to be copied in and not be unpacked.
166*4882a593Smuzhiyun
167*4882a593Smuzhiyun-  *dos:* Applies to ``.zip`` and ``.jar`` files and specifies whether
168*4882a593Smuzhiyun   to use DOS line ending conversion on text files.
169*4882a593Smuzhiyun
170*4882a593Smuzhiyun-  *striplevel:* Strip specified number of leading components (levels)
171*4882a593Smuzhiyun   from file names on extraction
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun-  *subdir:* Unpacks the specific URL to the specified subdirectory
174*4882a593Smuzhiyun   within the root directory.
175*4882a593Smuzhiyun
176*4882a593SmuzhiyunThe unpack call automatically decompresses and extracts files with ".Z",
177*4882a593Smuzhiyun".z", ".gz", ".xz", ".zip", ".jar", ".ipk", ".rpm". ".srpm", ".deb" and
178*4882a593Smuzhiyun".bz2" extensions as well as various combinations of tarball extensions.
179*4882a593Smuzhiyun
180*4882a593SmuzhiyunAs mentioned, the Git fetcher has its own unpack method that is
181*4882a593Smuzhiyunoptimized to work with Git trees. Basically, this method works by
182*4882a593Smuzhiyuncloning the tree into the final directory. The process is completed
183*4882a593Smuzhiyunusing references so that there is only one central copy of the Git
184*4882a593Smuzhiyunmetadata needed.
185*4882a593Smuzhiyun
186*4882a593Smuzhiyun.. _bb-fetchers:
187*4882a593Smuzhiyun
188*4882a593SmuzhiyunFetchers
189*4882a593Smuzhiyun========
190*4882a593Smuzhiyun
191*4882a593SmuzhiyunAs mentioned earlier, the URL prefix determines which fetcher submodule
192*4882a593SmuzhiyunBitBake uses. Each submodule can support different URL parameters, which
193*4882a593Smuzhiyunare described in the following sections.
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun.. _local-file-fetcher:
196*4882a593Smuzhiyun
197*4882a593SmuzhiyunLocal file fetcher (``file://``)
198*4882a593Smuzhiyun--------------------------------
199*4882a593Smuzhiyun
200*4882a593SmuzhiyunThis submodule handles URLs that begin with ``file://``. The filename
201*4882a593Smuzhiyunyou specify within the URL can be either an absolute or relative path to
202*4882a593Smuzhiyuna file. If the filename is relative, the contents of the
203*4882a593Smuzhiyun:term:`FILESPATH` variable is used in the same way
204*4882a593Smuzhiyun``PATH`` is used to find executables. If the file cannot be found, it is
205*4882a593Smuzhiyunassumed that it is available in :term:`DL_DIR` by the
206*4882a593Smuzhiyuntime the ``download()`` method is called.
207*4882a593Smuzhiyun
208*4882a593SmuzhiyunIf you specify a directory, the entire directory is unpacked.
209*4882a593Smuzhiyun
210*4882a593SmuzhiyunHere are a couple of example URLs, the first relative and the second
211*4882a593Smuzhiyunabsolute::
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun   SRC_URI = "file://relativefile.patch"
214*4882a593Smuzhiyun   SRC_URI = "file:///Users/ich/very_important_software"
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun.. _http-ftp-fetcher:
217*4882a593Smuzhiyun
218*4882a593SmuzhiyunHTTP/FTP wget fetcher (``http://``, ``ftp://``, ``https://``)
219*4882a593Smuzhiyun-------------------------------------------------------------
220*4882a593Smuzhiyun
221*4882a593SmuzhiyunThis fetcher obtains files from web and FTP servers. Internally, the
222*4882a593Smuzhiyunfetcher uses the wget utility.
223*4882a593Smuzhiyun
224*4882a593SmuzhiyunThe executable and parameters used are specified by the
225*4882a593Smuzhiyun``FETCHCMD_wget`` variable, which defaults to sensible values. The
226*4882a593Smuzhiyunfetcher supports a parameter "downloadfilename" that allows the name of
227*4882a593Smuzhiyunthe downloaded file to be specified. Specifying the name of the
228*4882a593Smuzhiyundownloaded file is useful for avoiding collisions in
229*4882a593Smuzhiyun:term:`DL_DIR` when dealing with multiple files that
230*4882a593Smuzhiyunhave the same name.
231*4882a593Smuzhiyun
232*4882a593SmuzhiyunIf a username and password are specified in the ``SRC_URI``, a Basic
233*4882a593SmuzhiyunAuthorization header will be added to each request, including across redirects.
234*4882a593SmuzhiyunTo instead limit the Authorization header to the first request, add
235*4882a593Smuzhiyun"redirectauth=0" to the list of parameters.
236*4882a593Smuzhiyun
237*4882a593SmuzhiyunSome example URLs are as follows::
238*4882a593Smuzhiyun
239*4882a593Smuzhiyun   SRC_URI = "http://oe.handhelds.org/not_there.aac"
240*4882a593Smuzhiyun   SRC_URI = "ftp://oe.handhelds.org/not_there_as_well.aac"
241*4882a593Smuzhiyun   SRC_URI = "ftp://you@oe.handhelds.org/home/you/secret.plan"
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun.. note::
244*4882a593Smuzhiyun
245*4882a593Smuzhiyun   Because URL parameters are delimited by semi-colons, this can
246*4882a593Smuzhiyun   introduce ambiguity when parsing URLs that also contain semi-colons,
247*4882a593Smuzhiyun   for example::
248*4882a593Smuzhiyun
249*4882a593Smuzhiyun           SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git;a=snapshot;h=a5dd47"
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun   Such URLs should should be modified by replacing semi-colons with '&'
253*4882a593Smuzhiyun   characters::
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun           SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git&a=snapshot&h=a5dd47"
256*4882a593Smuzhiyun
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun   In most cases this should work. Treating semi-colons and '&' in
259*4882a593Smuzhiyun   queries identically is recommended by the World Wide Web Consortium
260*4882a593Smuzhiyun   (W3C). Note that due to the nature of the URL, you may have to
261*4882a593Smuzhiyun   specify the name of the downloaded file as well::
262*4882a593Smuzhiyun
263*4882a593Smuzhiyun           SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git&a=snapshot&h=a5dd47;downloadfilename=myfile.bz2"
264*4882a593Smuzhiyun
265*4882a593Smuzhiyun
266*4882a593Smuzhiyun.. _cvs-fetcher:
267*4882a593Smuzhiyun
268*4882a593SmuzhiyunCVS fetcher (``(cvs://``)
269*4882a593Smuzhiyun-------------------------
270*4882a593Smuzhiyun
271*4882a593SmuzhiyunThis submodule handles checking out files from the CVS version control
272*4882a593Smuzhiyunsystem. You can configure it using a number of different variables:
273*4882a593Smuzhiyun
274*4882a593Smuzhiyun-  :term:`FETCHCMD_cvs <FETCHCMD>`: The name of the executable to use when running
275*4882a593Smuzhiyun   the ``cvs`` command. This name is usually "cvs".
276*4882a593Smuzhiyun
277*4882a593Smuzhiyun-  :term:`SRCDATE`: The date to use when fetching the CVS source code. A
278*4882a593Smuzhiyun   special value of "now" causes the checkout to be updated on every
279*4882a593Smuzhiyun   build.
280*4882a593Smuzhiyun
281*4882a593Smuzhiyun-  :term:`CVSDIR`: Specifies where a temporary
282*4882a593Smuzhiyun   checkout is saved. The location is often ``DL_DIR/cvs``.
283*4882a593Smuzhiyun
284*4882a593Smuzhiyun-  CVS_PROXY_HOST: The name to use as a "proxy=" parameter to the
285*4882a593Smuzhiyun   ``cvs`` command.
286*4882a593Smuzhiyun
287*4882a593Smuzhiyun-  CVS_PROXY_PORT: The port number to use as a "proxyport="
288*4882a593Smuzhiyun   parameter to the ``cvs`` command.
289*4882a593Smuzhiyun
290*4882a593SmuzhiyunAs well as the standard username and password URL syntax, you can also
291*4882a593Smuzhiyunconfigure the fetcher with various URL parameters:
292*4882a593Smuzhiyun
293*4882a593SmuzhiyunThe supported parameters are as follows:
294*4882a593Smuzhiyun
295*4882a593Smuzhiyun-  *"method":* The protocol over which to communicate with the CVS
296*4882a593Smuzhiyun   server. By default, this protocol is "pserver". If "method" is set to
297*4882a593Smuzhiyun   "ext", BitBake examines the "rsh" parameter and sets ``CVS_RSH``. You
298*4882a593Smuzhiyun   can use "dir" for local directories.
299*4882a593Smuzhiyun
300*4882a593Smuzhiyun-  *"module":* Specifies the module to check out. You must supply this
301*4882a593Smuzhiyun   parameter.
302*4882a593Smuzhiyun
303*4882a593Smuzhiyun-  *"tag":* Describes which CVS TAG should be used for the checkout. By
304*4882a593Smuzhiyun   default, the TAG is empty.
305*4882a593Smuzhiyun
306*4882a593Smuzhiyun-  *"date":* Specifies a date. If no "date" is specified, the
307*4882a593Smuzhiyun   :term:`SRCDATE` of the configuration is used to
308*4882a593Smuzhiyun   checkout a specific date. The special value of "now" causes the
309*4882a593Smuzhiyun   checkout to be updated on every build.
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun-  *"localdir":* Used to rename the module. Effectively, you are
312*4882a593Smuzhiyun   renaming the output directory to which the module is unpacked. You
313*4882a593Smuzhiyun   are forcing the module into a special directory relative to
314*4882a593Smuzhiyun   :term:`CVSDIR`.
315*4882a593Smuzhiyun
316*4882a593Smuzhiyun-  *"rsh":* Used in conjunction with the "method" parameter.
317*4882a593Smuzhiyun
318*4882a593Smuzhiyun-  *"scmdata":* Causes the CVS metadata to be maintained in the tarball
319*4882a593Smuzhiyun   the fetcher creates when set to "keep". The tarball is expanded into
320*4882a593Smuzhiyun   the work directory. By default, the CVS metadata is removed.
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun-  *"fullpath":* Controls whether the resulting checkout is at the
323*4882a593Smuzhiyun   module level, which is the default, or is at deeper paths.
324*4882a593Smuzhiyun
325*4882a593Smuzhiyun-  *"norecurse":* Causes the fetcher to only checkout the specified
326*4882a593Smuzhiyun   directory with no recurse into any subdirectories.
327*4882a593Smuzhiyun
328*4882a593Smuzhiyun-  *"port":* The port to which the CVS server connects.
329*4882a593Smuzhiyun
330*4882a593SmuzhiyunSome example URLs are as follows::
331*4882a593Smuzhiyun
332*4882a593Smuzhiyun   SRC_URI = "cvs://CVSROOT;module=mymodule;tag=some-version;method=ext"
333*4882a593Smuzhiyun   SRC_URI = "cvs://CVSROOT;module=mymodule;date=20060126;localdir=usethat"
334*4882a593Smuzhiyun
335*4882a593Smuzhiyun.. _svn-fetcher:
336*4882a593Smuzhiyun
337*4882a593SmuzhiyunSubversion (SVN) Fetcher (``svn://``)
338*4882a593Smuzhiyun-------------------------------------
339*4882a593Smuzhiyun
340*4882a593SmuzhiyunThis fetcher submodule fetches code from the Subversion source control
341*4882a593Smuzhiyunsystem. The executable used is specified by ``FETCHCMD_svn``, which
342*4882a593Smuzhiyundefaults to "svn". The fetcher's temporary working directory is set by
343*4882a593Smuzhiyun:term:`SVNDIR`, which is usually ``DL_DIR/svn``.
344*4882a593Smuzhiyun
345*4882a593SmuzhiyunThe supported parameters are as follows:
346*4882a593Smuzhiyun
347*4882a593Smuzhiyun-  *"module":* The name of the svn module to checkout. You must provide
348*4882a593Smuzhiyun   this parameter. You can think of this parameter as the top-level
349*4882a593Smuzhiyun   directory of the repository data you want.
350*4882a593Smuzhiyun
351*4882a593Smuzhiyun-  *"path_spec":* A specific directory in which to checkout the
352*4882a593Smuzhiyun   specified svn module.
353*4882a593Smuzhiyun
354*4882a593Smuzhiyun-  *"protocol":* The protocol to use, which defaults to "svn". If
355*4882a593Smuzhiyun   "protocol" is set to "svn+ssh", the "ssh" parameter is also used.
356*4882a593Smuzhiyun
357*4882a593Smuzhiyun-  *"rev":* The revision of the source code to checkout.
358*4882a593Smuzhiyun
359*4882a593Smuzhiyun-  *"scmdata":* Causes the ".svn" directories to be available during
360*4882a593Smuzhiyun   compile-time when set to "keep". By default, these directories are
361*4882a593Smuzhiyun   removed.
362*4882a593Smuzhiyun
363*4882a593Smuzhiyun-  *"ssh":* An optional parameter used when "protocol" is set to
364*4882a593Smuzhiyun   "svn+ssh". You can use this parameter to specify the ssh program used
365*4882a593Smuzhiyun   by svn.
366*4882a593Smuzhiyun
367*4882a593Smuzhiyun-  *"transportuser":* When required, sets the username for the
368*4882a593Smuzhiyun   transport. By default, this parameter is empty. The transport
369*4882a593Smuzhiyun   username is different than the username used in the main URL, which
370*4882a593Smuzhiyun   is passed to the subversion command.
371*4882a593Smuzhiyun
372*4882a593SmuzhiyunFollowing are three examples using svn::
373*4882a593Smuzhiyun
374*4882a593Smuzhiyun   SRC_URI = "svn://myrepos/proj1;module=vip;protocol=http;rev=667"
375*4882a593Smuzhiyun   SRC_URI = "svn://myrepos/proj1;module=opie;protocol=svn+ssh"
376*4882a593Smuzhiyun   SRC_URI = "svn://myrepos/proj1;module=trunk;protocol=http;path_spec=${MY_DIR}/proj1"
377*4882a593Smuzhiyun
378*4882a593Smuzhiyun.. _git-fetcher:
379*4882a593Smuzhiyun
380*4882a593SmuzhiyunGit Fetcher (``git://``)
381*4882a593Smuzhiyun------------------------
382*4882a593Smuzhiyun
383*4882a593SmuzhiyunThis fetcher submodule fetches code from the Git source control system.
384*4882a593SmuzhiyunThe fetcher works by creating a bare clone of the remote into
385*4882a593Smuzhiyun:term:`GITDIR`, which is usually ``DL_DIR/git2``. This
386*4882a593Smuzhiyunbare clone is then cloned into the work directory during the unpack
387*4882a593Smuzhiyunstage when a specific tree is checked out. This is done using alternates
388*4882a593Smuzhiyunand by reference to minimize the amount of duplicate data on the disk
389*4882a593Smuzhiyunand make the unpack process fast. The executable used can be set with
390*4882a593Smuzhiyun``FETCHCMD_git``.
391*4882a593Smuzhiyun
392*4882a593SmuzhiyunThis fetcher supports the following parameters:
393*4882a593Smuzhiyun
394*4882a593Smuzhiyun-  *"protocol":* The protocol used to fetch the files. The default is
395*4882a593Smuzhiyun   "git" when a hostname is set. If a hostname is not set, the Git
396*4882a593Smuzhiyun   protocol is "file". You can also use "http", "https", "ssh" and
397*4882a593Smuzhiyun   "rsync".
398*4882a593Smuzhiyun
399*4882a593Smuzhiyun   .. note::
400*4882a593Smuzhiyun
401*4882a593Smuzhiyun     When ``protocol`` is "ssh", the URL expected in :term:`SRC_URI` differs
402*4882a593Smuzhiyun     from the one that is typically passed to ``git clone`` command and provided
403*4882a593Smuzhiyun     by the Git server to fetch from. For example, the URL returned by GitLab
404*4882a593Smuzhiyun     server for ``mesa`` when cloning over SSH is
405*4882a593Smuzhiyun     ``git@gitlab.freedesktop.org:mesa/mesa.git``, however the expected URL in
406*4882a593Smuzhiyun     :term:`SRC_URI` is the following::
407*4882a593Smuzhiyun
408*4882a593Smuzhiyun       SRC_URI = "git://git@gitlab.freedesktop.org/mesa/mesa.git;branch=main;protocol=ssh;..."
409*4882a593Smuzhiyun
410*4882a593Smuzhiyun     Note the ``:`` character changed for a ``/`` before the path to the project.
411*4882a593Smuzhiyun
412*4882a593Smuzhiyun-  *"nocheckout":* Tells the fetcher to not checkout source code when
413*4882a593Smuzhiyun   unpacking when set to "1". Set this option for the URL where there is
414*4882a593Smuzhiyun   a custom routine to checkout code. The default is "0".
415*4882a593Smuzhiyun
416*4882a593Smuzhiyun-  *"rebaseable":* Indicates that the upstream Git repository can be
417*4882a593Smuzhiyun   rebased. You should set this parameter to "1" if revisions can become
418*4882a593Smuzhiyun   detached from branches. In this case, the source mirror tarball is
419*4882a593Smuzhiyun   done per revision, which has a loss of efficiency. Rebasing the
420*4882a593Smuzhiyun   upstream Git repository could cause the current revision to disappear
421*4882a593Smuzhiyun   from the upstream repository. This option reminds the fetcher to
422*4882a593Smuzhiyun   preserve the local cache carefully for future use. The default value
423*4882a593Smuzhiyun   for this parameter is "0".
424*4882a593Smuzhiyun
425*4882a593Smuzhiyun-  *"nobranch":* Tells the fetcher to not check the SHA validation for
426*4882a593Smuzhiyun   the branch when set to "1". The default is "0". Set this option for
427*4882a593Smuzhiyun   the recipe that refers to the commit that is valid for any namespace
428*4882a593Smuzhiyun   (branch, tag, ...) instead of the branch.
429*4882a593Smuzhiyun
430*4882a593Smuzhiyun-  *"bareclone":* Tells the fetcher to clone a bare clone into the
431*4882a593Smuzhiyun   destination directory without checking out a working tree. Only the
432*4882a593Smuzhiyun   raw Git metadata is provided. This parameter implies the "nocheckout"
433*4882a593Smuzhiyun   parameter as well.
434*4882a593Smuzhiyun
435*4882a593Smuzhiyun-  *"branch":* The branch(es) of the Git tree to clone. Unless
436*4882a593Smuzhiyun   "nobranch" is set to "1", this is a mandatory parameter. The number of
437*4882a593Smuzhiyun   branch parameters must match the number of name parameters.
438*4882a593Smuzhiyun
439*4882a593Smuzhiyun-  *"rev":* The revision to use for the checkout. The default is
440*4882a593Smuzhiyun   "master".
441*4882a593Smuzhiyun
442*4882a593Smuzhiyun-  *"tag":* Specifies a tag to use for the checkout. To correctly
443*4882a593Smuzhiyun   resolve tags, BitBake must access the network. For that reason, tags
444*4882a593Smuzhiyun   are often not used. As far as Git is concerned, the "tag" parameter
445*4882a593Smuzhiyun   behaves effectively the same as the "rev" parameter.
446*4882a593Smuzhiyun
447*4882a593Smuzhiyun-  *"subpath":* Limits the checkout to a specific subpath of the tree.
448*4882a593Smuzhiyun   By default, the whole tree is checked out.
449*4882a593Smuzhiyun
450*4882a593Smuzhiyun-  *"destsuffix":* The name of the path in which to place the checkout.
451*4882a593Smuzhiyun   By default, the path is ``git/``.
452*4882a593Smuzhiyun
453*4882a593Smuzhiyun-  *"usehead":* Enables local ``git://`` URLs to use the current branch
454*4882a593Smuzhiyun   HEAD as the revision for use with ``AUTOREV``. The "usehead"
455*4882a593Smuzhiyun   parameter implies no branch and only works when the transfer protocol
456*4882a593Smuzhiyun   is ``file://``.
457*4882a593Smuzhiyun
458*4882a593SmuzhiyunHere are some example URLs::
459*4882a593Smuzhiyun
460*4882a593Smuzhiyun   SRC_URI = "git://github.com/fronteed/icheck.git;protocol=https;branch=${PV};tag=${PV}"
461*4882a593Smuzhiyun   SRC_URI = "git://github.com/asciidoc/asciidoc-py;protocol=https;branch=main"
462*4882a593Smuzhiyun   SRC_URI = "git://git@gitlab.freedesktop.org/mesa/mesa.git;branch=main;protocol=ssh;..."
463*4882a593Smuzhiyun
464*4882a593Smuzhiyun.. note::
465*4882a593Smuzhiyun
466*4882a593Smuzhiyun   When using ``git`` as the fetcher of the main source code of your software,
467*4882a593Smuzhiyun   ``S`` should be set accordingly::
468*4882a593Smuzhiyun
469*4882a593Smuzhiyun       S = "${WORKDIR}/git"
470*4882a593Smuzhiyun
471*4882a593Smuzhiyun.. note::
472*4882a593Smuzhiyun
473*4882a593Smuzhiyun   Specifying passwords directly in ``git://`` urls is not supported.
474*4882a593Smuzhiyun   There are several reasons: :term:`SRC_URI` is often written out to logs and
475*4882a593Smuzhiyun   other places, and that could easily leak passwords; it is also all too
476*4882a593Smuzhiyun   easy to share metadata without removing passwords. SSH keys, ``~/.netrc``
477*4882a593Smuzhiyun   and ``~/.ssh/config`` files can be used as alternatives.
478*4882a593Smuzhiyun
479*4882a593Smuzhiyun
480*4882a593Smuzhiyun.. _gitsm-fetcher:
481*4882a593Smuzhiyun
482*4882a593SmuzhiyunGit Submodule Fetcher (``gitsm://``)
483*4882a593Smuzhiyun------------------------------------
484*4882a593Smuzhiyun
485*4882a593SmuzhiyunThis fetcher submodule inherits from the :ref:`Git
486*4882a593Smuzhiyunfetcher<bitbake-user-manual/bitbake-user-manual-fetching:git fetcher
487*4882a593Smuzhiyun(\`\`git://\`\`)>` and extends that fetcher's behavior by fetching a
488*4882a593Smuzhiyunrepository's submodules. :term:`SRC_URI` is passed to the Git fetcher as
489*4882a593Smuzhiyundescribed in the :ref:`bitbake-user-manual/bitbake-user-manual-fetching:git
490*4882a593Smuzhiyunfetcher (\`\`git://\`\`)` section.
491*4882a593Smuzhiyun
492*4882a593Smuzhiyun.. note::
493*4882a593Smuzhiyun
494*4882a593Smuzhiyun   You must clean a recipe when switching between '``git://``' and
495*4882a593Smuzhiyun   '``gitsm://``' URLs.
496*4882a593Smuzhiyun
497*4882a593Smuzhiyun   The Git Submodules fetcher is not a complete fetcher implementation.
498*4882a593Smuzhiyun   The fetcher has known issues where it does not use the normal source
499*4882a593Smuzhiyun   mirroring infrastructure properly. Further, the submodule sources it
500*4882a593Smuzhiyun   fetches are not visible to the licensing and source archiving
501*4882a593Smuzhiyun   infrastructures.
502*4882a593Smuzhiyun
503*4882a593Smuzhiyun.. _clearcase-fetcher:
504*4882a593Smuzhiyun
505*4882a593SmuzhiyunClearCase Fetcher (``ccrc://``)
506*4882a593Smuzhiyun-------------------------------
507*4882a593Smuzhiyun
508*4882a593SmuzhiyunThis fetcher submodule fetches code from a
509*4882a593Smuzhiyun`ClearCase <http://en.wikipedia.org/wiki/Rational_ClearCase>`__
510*4882a593Smuzhiyunrepository.
511*4882a593Smuzhiyun
512*4882a593SmuzhiyunTo use this fetcher, make sure your recipe has proper
513*4882a593Smuzhiyun:term:`SRC_URI`, :term:`SRCREV`, and
514*4882a593Smuzhiyun:term:`PV` settings. Here is an example::
515*4882a593Smuzhiyun
516*4882a593Smuzhiyun   SRC_URI = "ccrc://cc.example.org/ccrc;vob=/example_vob;module=/example_module"
517*4882a593Smuzhiyun   SRCREV = "EXAMPLE_CLEARCASE_TAG"
518*4882a593Smuzhiyun   PV = "${@d.getVar("SRCREV", False).replace("/", "+")}"
519*4882a593Smuzhiyun
520*4882a593SmuzhiyunThe fetcher uses the ``rcleartool`` or
521*4882a593Smuzhiyun``cleartool`` remote client, depending on which one is available.
522*4882a593Smuzhiyun
523*4882a593SmuzhiyunFollowing are options for the :term:`SRC_URI` statement:
524*4882a593Smuzhiyun
525*4882a593Smuzhiyun-  *vob*: The name, which must include the prepending "/" character,
526*4882a593Smuzhiyun   of the ClearCase VOB. This option is required.
527*4882a593Smuzhiyun
528*4882a593Smuzhiyun-  *module*: The module, which must include the prepending "/"
529*4882a593Smuzhiyun   character, in the selected VOB.
530*4882a593Smuzhiyun
531*4882a593Smuzhiyun   .. note::
532*4882a593Smuzhiyun
533*4882a593Smuzhiyun      The module and vob options are combined to create the load rule in the
534*4882a593Smuzhiyun      view config spec. As an example, consider the vob and module values from
535*4882a593Smuzhiyun      the SRC_URI statement at the start of this section. Combining those values
536*4882a593Smuzhiyun      results in the following::
537*4882a593Smuzhiyun
538*4882a593Smuzhiyun         load /example_vob/example_module
539*4882a593Smuzhiyun
540*4882a593Smuzhiyun-  *proto*: The protocol, which can be either ``http`` or ``https``.
541*4882a593Smuzhiyun
542*4882a593SmuzhiyunBy default, the fetcher creates a configuration specification. If you
543*4882a593Smuzhiyunwant this specification written to an area other than the default, use
544*4882a593Smuzhiyunthe ``CCASE_CUSTOM_CONFIG_SPEC`` variable in your recipe to define where
545*4882a593Smuzhiyunthe specification is written.
546*4882a593Smuzhiyun
547*4882a593Smuzhiyun.. note::
548*4882a593Smuzhiyun
549*4882a593Smuzhiyun   the SRCREV loses its functionality if you specify this variable. However,
550*4882a593Smuzhiyun   SRCREV is still used to label the archive after a fetch even though it does
551*4882a593Smuzhiyun   not define what is fetched.
552*4882a593Smuzhiyun
553*4882a593SmuzhiyunHere are a couple of other behaviors worth mentioning:
554*4882a593Smuzhiyun
555*4882a593Smuzhiyun-  When using ``cleartool``, the login of ``cleartool`` is handled by
556*4882a593Smuzhiyun   the system. The login require no special steps.
557*4882a593Smuzhiyun
558*4882a593Smuzhiyun-  In order to use ``rcleartool`` with authenticated users, an
559*4882a593Smuzhiyun   "rcleartool login" is necessary before using the fetcher.
560*4882a593Smuzhiyun
561*4882a593Smuzhiyun.. _perforce-fetcher:
562*4882a593Smuzhiyun
563*4882a593SmuzhiyunPerforce Fetcher (``p4://``)
564*4882a593Smuzhiyun----------------------------
565*4882a593Smuzhiyun
566*4882a593SmuzhiyunThis fetcher submodule fetches code from the
567*4882a593Smuzhiyun`Perforce <https://www.perforce.com/>`__ source control system. The
568*4882a593Smuzhiyunexecutable used is specified by ``FETCHCMD_p4``, which defaults to "p4".
569*4882a593SmuzhiyunThe fetcher's temporary working directory is set by
570*4882a593Smuzhiyun:term:`P4DIR`, which defaults to "DL_DIR/p4".
571*4882a593SmuzhiyunThe fetcher does not make use of a perforce client, instead it
572*4882a593Smuzhiyunrelies on ``p4 files`` to retrieve a list of
573*4882a593Smuzhiyunfiles and ``p4 print`` to transfer the content
574*4882a593Smuzhiyunof those files locally.
575*4882a593Smuzhiyun
576*4882a593SmuzhiyunTo use this fetcher, make sure your recipe has proper
577*4882a593Smuzhiyun:term:`SRC_URI`, :term:`SRCREV`, and
578*4882a593Smuzhiyun:term:`PV` values. The p4 executable is able to use the
579*4882a593Smuzhiyunconfig file defined by your system's ``P4CONFIG`` environment variable
580*4882a593Smuzhiyunin order to define the Perforce server URL and port, username, and
581*4882a593Smuzhiyunpassword if you do not wish to keep those values in a recipe itself. If
582*4882a593Smuzhiyunyou choose not to use ``P4CONFIG``, or to explicitly set variables that
583*4882a593Smuzhiyun``P4CONFIG`` can contain, you can specify the ``P4PORT`` value, which is
584*4882a593Smuzhiyunthe server's URL and port number, and you can specify a username and
585*4882a593Smuzhiyunpassword directly in your recipe within :term:`SRC_URI`.
586*4882a593Smuzhiyun
587*4882a593SmuzhiyunHere is an example that relies on ``P4CONFIG`` to specify the server URL
588*4882a593Smuzhiyunand port, username, and password, and fetches the Head Revision::
589*4882a593Smuzhiyun
590*4882a593Smuzhiyun   SRC_URI = "p4://example-depot/main/source/..."
591*4882a593Smuzhiyun   SRCREV = "${AUTOREV}"
592*4882a593Smuzhiyun   PV = "p4-${SRCPV}"
593*4882a593Smuzhiyun   S = "${WORKDIR}/p4"
594*4882a593Smuzhiyun
595*4882a593SmuzhiyunHere is an example that specifies the server URL and port, username, and
596*4882a593Smuzhiyunpassword, and fetches a Revision based on a Label::
597*4882a593Smuzhiyun
598*4882a593Smuzhiyun   P4PORT = "tcp:p4server.example.net:1666"
599*4882a593Smuzhiyun   SRC_URI = "p4://user:passwd@example-depot/main/source/..."
600*4882a593Smuzhiyun   SRCREV = "release-1.0"
601*4882a593Smuzhiyun   PV = "p4-${SRCPV}"
602*4882a593Smuzhiyun   S = "${WORKDIR}/p4"
603*4882a593Smuzhiyun
604*4882a593Smuzhiyun.. note::
605*4882a593Smuzhiyun
606*4882a593Smuzhiyun   You should always set S to "${WORKDIR}/p4" in your recipe.
607*4882a593Smuzhiyun
608*4882a593SmuzhiyunBy default, the fetcher strips the depot location from the local file paths. In
609*4882a593Smuzhiyunthe above example, the content of ``example-depot/main/source/`` will be placed
610*4882a593Smuzhiyunin ``${WORKDIR}/p4``.  For situations where preserving parts of the remote depot
611*4882a593Smuzhiyunpaths locally is desirable, the fetcher supports two parameters:
612*4882a593Smuzhiyun
613*4882a593Smuzhiyun- *"module":*
614*4882a593Smuzhiyun    The top-level depot location or directory to fetch. The value of this
615*4882a593Smuzhiyun    parameter can also point to a single file within the depot, in which case
616*4882a593Smuzhiyun    the local file path will include the module path.
617*4882a593Smuzhiyun- *"remotepath":*
618*4882a593Smuzhiyun    When used with the value "``keep``", the fetcher will mirror the full depot
619*4882a593Smuzhiyun    paths locally for the specified location, even in combination with the
620*4882a593Smuzhiyun    ``module`` parameter.
621*4882a593Smuzhiyun
622*4882a593SmuzhiyunHere is an example use of the the ``module`` parameter::
623*4882a593Smuzhiyun
624*4882a593Smuzhiyun   SRC_URI = "p4://user:passwd@example-depot/main;module=source/..."
625*4882a593Smuzhiyun
626*4882a593SmuzhiyunIn this case, the content of the top-level directory ``source/`` will be fetched
627*4882a593Smuzhiyunto ``${P4DIR}``, including the directory itself.  The top-level directory will
628*4882a593Smuzhiyunbe accesible at ``${P4DIR}/source/``.
629*4882a593Smuzhiyun
630*4882a593SmuzhiyunHere is an example use of the the ``remotepath`` parameter::
631*4882a593Smuzhiyun
632*4882a593Smuzhiyun   SRC_URI = "p4://user:passwd@example-depot/main;module=source/...;remotepath=keep"
633*4882a593Smuzhiyun
634*4882a593SmuzhiyunIn this case, the content of the top-level directory ``source/`` will be fetched
635*4882a593Smuzhiyunto ``${P4DIR}``, but the complete depot paths will be mirrored locally. The
636*4882a593Smuzhiyuntop-level directory will be accessible at
637*4882a593Smuzhiyun``${P4DIR}/example-depot/main/source/``.
638*4882a593Smuzhiyun
639*4882a593Smuzhiyun.. _repo-fetcher:
640*4882a593Smuzhiyun
641*4882a593SmuzhiyunRepo Fetcher (``repo://``)
642*4882a593Smuzhiyun--------------------------
643*4882a593Smuzhiyun
644*4882a593SmuzhiyunThis fetcher submodule fetches code from ``google-repo`` source control
645*4882a593Smuzhiyunsystem. The fetcher works by initiating and syncing sources of the
646*4882a593Smuzhiyunrepository into :term:`REPODIR`, which is usually
647*4882a593Smuzhiyun``${DL_DIR}/repo``.
648*4882a593Smuzhiyun
649*4882a593SmuzhiyunThis fetcher supports the following parameters:
650*4882a593Smuzhiyun
651*4882a593Smuzhiyun-  *"protocol":* Protocol to fetch the repository manifest (default:
652*4882a593Smuzhiyun   git).
653*4882a593Smuzhiyun
654*4882a593Smuzhiyun-  *"branch":* Branch or tag of repository to get (default: master).
655*4882a593Smuzhiyun
656*4882a593Smuzhiyun-  *"manifest":* Name of the manifest file (default: ``default.xml``).
657*4882a593Smuzhiyun
658*4882a593SmuzhiyunHere are some example URLs::
659*4882a593Smuzhiyun
660*4882a593Smuzhiyun   SRC_URI = "repo://REPOROOT;protocol=git;branch=some_branch;manifest=my_manifest.xml"
661*4882a593Smuzhiyun   SRC_URI = "repo://REPOROOT;protocol=file;branch=some_branch;manifest=my_manifest.xml"
662*4882a593Smuzhiyun
663*4882a593Smuzhiyun.. _az-fetcher:
664*4882a593Smuzhiyun
665*4882a593SmuzhiyunAz Fetcher (``az://``)
666*4882a593Smuzhiyun--------------------------
667*4882a593Smuzhiyun
668*4882a593SmuzhiyunThis submodule fetches data from an
669*4882a593Smuzhiyun`Azure Storage account <https://docs.microsoft.com/en-us/azure/storage/>`__ ,
670*4882a593Smuzhiyunit inherits its functionality from the HTTP wget fetcher, but modifies its
671*4882a593Smuzhiyunbehavior to accomodate the usage of a
672*4882a593Smuzhiyun`Shared Access Signature (SAS) <https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview>`__
673*4882a593Smuzhiyunfor non-public data.
674*4882a593Smuzhiyun
675*4882a593SmuzhiyunSuch functionality is set by the variable:
676*4882a593Smuzhiyun
677*4882a593Smuzhiyun-  :term:`AZ_SAS`: The Azure Storage Shared Access Signature provides secure
678*4882a593Smuzhiyun   delegate access to resources, if this variable is set, the Az Fetcher will
679*4882a593Smuzhiyun   use it when fetching artifacts from the cloud.
680*4882a593Smuzhiyun
681*4882a593SmuzhiyunYou can specify the AZ_SAS variable as shown below::
682*4882a593Smuzhiyun
683*4882a593Smuzhiyun   AZ_SAS = "se=2021-01-01&sp=r&sv=2018-11-09&sr=c&skoid=<skoid>&sig=<signature>"
684*4882a593Smuzhiyun
685*4882a593SmuzhiyunHere is an example URL::
686*4882a593Smuzhiyun
687*4882a593Smuzhiyun   SRC_URI = "az://<azure-storage-account>.blob.core.windows.net/<foo_container>/<bar_file>"
688*4882a593Smuzhiyun
689*4882a593SmuzhiyunIt can also be used when setting mirrors definitions using the :term:`PREMIRRORS` variable.
690*4882a593Smuzhiyun
691*4882a593Smuzhiyun.. _crate-fetcher:
692*4882a593Smuzhiyun
693*4882a593SmuzhiyunCrate Fetcher (``crate://``)
694*4882a593Smuzhiyun----------------------------
695*4882a593Smuzhiyun
696*4882a593SmuzhiyunThis submodule fetches code for
697*4882a593Smuzhiyun`Rust language "crates" <https://doc.rust-lang.org/reference/glossary.html?highlight=crate#crate>`__
698*4882a593Smuzhiyuncorresponding to Rust libraries and programs to compile. Such crates are typically shared
699*4882a593Smuzhiyunon https://crates.io/ but this fetcher supports other crate registries too.
700*4882a593Smuzhiyun
701*4882a593SmuzhiyunThe format for the :term:`SRC_URI` setting must be::
702*4882a593Smuzhiyun
703*4882a593Smuzhiyun   SRC_URI = "crate://REGISTRY/NAME/VERSION"
704*4882a593Smuzhiyun
705*4882a593SmuzhiyunHere is an example URL::
706*4882a593Smuzhiyun
707*4882a593Smuzhiyun   SRC_URI = "crate://crates.io/glob/0.2.11"
708*4882a593Smuzhiyun
709*4882a593Smuzhiyun.. _npm-fetcher:
710*4882a593Smuzhiyun
711*4882a593SmuzhiyunNPM Fetcher (``npm://``)
712*4882a593Smuzhiyun------------------------
713*4882a593Smuzhiyun
714*4882a593SmuzhiyunThis submodule fetches source code from an
715*4882a593Smuzhiyun`NPM <https://en.wikipedia.org/wiki/Npm_(software)>`__
716*4882a593SmuzhiyunJavascript package registry.
717*4882a593Smuzhiyun
718*4882a593SmuzhiyunThe format for the :term:`SRC_URI` setting must be::
719*4882a593Smuzhiyun
720*4882a593Smuzhiyun   SRC_URI = "npm://some.registry.url;ParameterA=xxx;ParameterB=xxx;..."
721*4882a593Smuzhiyun
722*4882a593SmuzhiyunThis fetcher supports the following parameters:
723*4882a593Smuzhiyun
724*4882a593Smuzhiyun-  *"package":* The NPM package name. This is a mandatory parameter.
725*4882a593Smuzhiyun
726*4882a593Smuzhiyun-  *"version":* The NPM package version. This is a mandatory parameter.
727*4882a593Smuzhiyun
728*4882a593Smuzhiyun-  *"downloadfilename":* Specifies the filename used when storing the downloaded file.
729*4882a593Smuzhiyun
730*4882a593Smuzhiyun-  *"destsuffix":* Specifies the directory to use to unpack the package (default: ``npm``).
731*4882a593Smuzhiyun
732*4882a593SmuzhiyunNote that NPM fetcher only fetches the package source itself. The dependencies
733*4882a593Smuzhiyuncan be fetched through the `npmsw-fetcher`_.
734*4882a593Smuzhiyun
735*4882a593SmuzhiyunHere is an example URL with both fetchers::
736*4882a593Smuzhiyun
737*4882a593Smuzhiyun   SRC_URI = " \
738*4882a593Smuzhiyun       npm://registry.npmjs.org/;package=cute-files;version=${PV} \
739*4882a593Smuzhiyun       npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json \
740*4882a593Smuzhiyun       "
741*4882a593Smuzhiyun
742*4882a593SmuzhiyunSee :yocto_docs:`Creating Node Package Manager (NPM) Packages
743*4882a593Smuzhiyun</dev-manual/common-tasks.html#creating-node-package-manager-npm-packages>`
744*4882a593Smuzhiyunin the Yocto Project manual for details about using
745*4882a593Smuzhiyun:yocto_docs:`devtool <https://docs.yoctoproject.org/ref-manual/devtool-reference.html>`
746*4882a593Smuzhiyunto automatically create a recipe from an NPM URL.
747*4882a593Smuzhiyun
748*4882a593Smuzhiyun.. _npmsw-fetcher:
749*4882a593Smuzhiyun
750*4882a593SmuzhiyunNPM shrinkwrap Fetcher (``npmsw://``)
751*4882a593Smuzhiyun-------------------------------------
752*4882a593Smuzhiyun
753*4882a593SmuzhiyunThis submodule fetches source code from an
754*4882a593Smuzhiyun`NPM shrinkwrap <https://docs.npmjs.com/cli/v8/commands/npm-shrinkwrap>`__
755*4882a593Smuzhiyundescription file, which lists the dependencies
756*4882a593Smuzhiyunof an NPM package while locking their versions.
757*4882a593Smuzhiyun
758*4882a593SmuzhiyunThe format for the :term:`SRC_URI` setting must be::
759*4882a593Smuzhiyun
760*4882a593Smuzhiyun   SRC_URI = "npmsw://some.registry.url;ParameterA=xxx;ParameterB=xxx;..."
761*4882a593Smuzhiyun
762*4882a593SmuzhiyunThis fetcher supports the following parameters:
763*4882a593Smuzhiyun
764*4882a593Smuzhiyun-  *"dev":* Set this parameter to ``1`` to install "devDependencies".
765*4882a593Smuzhiyun
766*4882a593Smuzhiyun-  *"destsuffix":* Specifies the directory to use to unpack the dependencies
767*4882a593Smuzhiyun   (``${S}`` by default).
768*4882a593Smuzhiyun
769*4882a593SmuzhiyunNote that the shrinkwrap file can also be provided by the recipe for
770*4882a593Smuzhiyunthe package which has such dependencies, for example::
771*4882a593Smuzhiyun
772*4882a593Smuzhiyun   SRC_URI = " \
773*4882a593Smuzhiyun       npm://registry.npmjs.org/;package=cute-files;version=${PV} \
774*4882a593Smuzhiyun       npmsw://${THISDIR}/${BPN}/npm-shrinkwrap.json \
775*4882a593Smuzhiyun       "
776*4882a593Smuzhiyun
777*4882a593SmuzhiyunSuch a file can automatically be generated using
778*4882a593Smuzhiyun:yocto_docs:`devtool <https://docs.yoctoproject.org/ref-manual/devtool-reference.html>`
779*4882a593Smuzhiyunas described in the :yocto_docs:`Creating Node Package Manager (NPM) Packages
780*4882a593Smuzhiyun</dev-manual/common-tasks.html#creating-node-package-manager-npm-packages>`
781*4882a593Smuzhiyunsection of the Yocto Project.
782*4882a593Smuzhiyun
783*4882a593SmuzhiyunOther Fetchers
784*4882a593Smuzhiyun--------------
785*4882a593Smuzhiyun
786*4882a593SmuzhiyunFetch submodules also exist for the following:
787*4882a593Smuzhiyun
788*4882a593Smuzhiyun-  Bazaar (``bzr://``)
789*4882a593Smuzhiyun
790*4882a593Smuzhiyun-  Mercurial (``hg://``)
791*4882a593Smuzhiyun
792*4882a593Smuzhiyun-  OSC (``osc://``)
793*4882a593Smuzhiyun
794*4882a593Smuzhiyun-  Secure FTP (``sftp://``)
795*4882a593Smuzhiyun
796*4882a593Smuzhiyun-  Secure Shell (``ssh://``)
797*4882a593Smuzhiyun
798*4882a593Smuzhiyun-  Trees using Git Annex (``gitannex://``)
799*4882a593Smuzhiyun
800*4882a593SmuzhiyunNo documentation currently exists for these lesser used fetcher
801*4882a593Smuzhiyunsubmodules. However, you might find the code helpful and readable.
802*4882a593Smuzhiyun
803*4882a593SmuzhiyunAuto Revisions
804*4882a593Smuzhiyun==============
805*4882a593Smuzhiyun
806*4882a593SmuzhiyunWe need to document ``AUTOREV`` and :term:`SRCREV_FORMAT` here.
807