blob: 4396830a2f583a19227965ca1edef765fd29ecca [file] [log] [blame]
Andrew Geisslerc9f78652020-09-18 14:11:35 -05001.. SPDX-License-Identifier: CC-BY-2.5
2
3=====================
4File Download Support
5=====================
6
7|
8
9BitBake's fetch module is a standalone piece of library code that deals
10with the intricacies of downloading source code and files from remote
11systems. Fetching source code is one of the cornerstones of building
12software. As such, this module forms an important part of BitBake.
13
14The current fetch module is called "fetch2" and refers to the fact that
15it is the second major version of the API. The original version is
16obsolete and has been removed from the codebase. Thus, in all cases,
17"fetch" refers to "fetch2" in this manual.
18
19The Download (Fetch)
20====================
21
22BitBake takes several steps when fetching source code or files. The
23fetcher codebase deals with two distinct processes in order: obtaining
24the files from somewhere (cached or otherwise) and then unpacking those
25files into a specific location and perhaps in a specific way. Getting
26and unpacking the files is often optionally followed by patching.
27Patching, however, is not covered by this module.
28
29The code to execute the first part of this process, a fetch, looks
Andrew Geisslerc926e172021-05-07 16:11:35 -050030something like the following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -050031
32 src_uri = (d.getVar('SRC_URI') or "").split()
33 fetcher = bb.fetch2.Fetch(src_uri, d)
34 fetcher.download()
35
36This code sets up an instance of the fetch class. The instance uses a
37space-separated list of URLs from the :term:`SRC_URI`
38variable and then calls the ``download`` method to download the files.
39
Andrew Geisslerc926e172021-05-07 16:11:35 -050040The instantiation of the fetch class is usually followed by::
Andrew Geisslerc9f78652020-09-18 14:11:35 -050041
42 rootdir = l.getVar('WORKDIR')
43 fetcher.unpack(rootdir)
44
45This code unpacks the downloaded files to the specified by ``WORKDIR``.
46
47.. note::
48
49 For convenience, the naming in these examples matches the variables
50 used by OpenEmbedded. If you want to see the above code in action,
51 examine the OpenEmbedded class file ``base.bbclass``
52 .
53
Patrick Williams213cb262021-08-07 19:21:33 -050054The :term:`SRC_URI` and ``WORKDIR`` variables are not hardcoded into the
Andrew Geisslerc9f78652020-09-18 14:11:35 -050055fetcher, since those fetcher methods can be (and are) called with
56different variable names. In OpenEmbedded for example, the shared state
57(sstate) code uses the fetch module to fetch the sstate files.
58
59When the ``download()`` method is called, BitBake tries to resolve the
60URLs by looking for source files in a specific search order:
61
62- *Pre-mirror Sites:* BitBake first uses pre-mirrors to try and find
63 source files. These locations are defined using the
64 :term:`PREMIRRORS` variable.
65
66- *Source URI:* If pre-mirrors fail, BitBake uses the original URL (e.g
Patrick Williams213cb262021-08-07 19:21:33 -050067 from :term:`SRC_URI`).
Andrew Geisslerc9f78652020-09-18 14:11:35 -050068
69- *Mirror Sites:* If fetch failures occur, BitBake next uses mirror
70 locations as defined by the :term:`MIRRORS` variable.
71
72For each URL passed to the fetcher, the fetcher calls the submodule that
73handles that particular URL type. This behavior can be the source of
Patrick Williams213cb262021-08-07 19:21:33 -050074some confusion when you are providing URLs for the :term:`SRC_URI` variable.
Andrew Geisslerc926e172021-05-07 16:11:35 -050075Consider the following two URLs::
Andrew Geisslerc9f78652020-09-18 14:11:35 -050076
Andrew Geisslereff27472021-10-29 15:35:00 -050077 https://git.yoctoproject.org/git/poky;protocol=git
Andrew Geisslerc9f78652020-09-18 14:11:35 -050078 git://git.yoctoproject.org/git/poky;protocol=http
79
80In the former case, the URL is passed to the ``wget`` fetcher, which does not
81understand "git". Therefore, the latter case is the correct form since the Git
82fetcher does know how to use HTTP as a transport.
83
Andrew Geisslerc926e172021-05-07 16:11:35 -050084Here are some examples that show commonly used mirror definitions::
Andrew Geisslerc9f78652020-09-18 14:11:35 -050085
86 PREMIRRORS ?= "\
87 bzr://.*/.\* http://somemirror.org/sources/ \\n \
88 cvs://.*/.\* http://somemirror.org/sources/ \\n \
89 git://.*/.\* http://somemirror.org/sources/ \\n \
90 hg://.*/.\* http://somemirror.org/sources/ \\n \
91 osc://.*/.\* http://somemirror.org/sources/ \\n \
92 p4://.*/.\* http://somemirror.org/sources/ \\n \
93 svn://.*/.\* http://somemirror.org/sources/ \\n"
94
95 MIRRORS =+ "\
96 ftp://.*/.\* http://somemirror.org/sources/ \\n \
97 http://.*/.\* http://somemirror.org/sources/ \\n \
98 https://.*/.\* http://somemirror.org/sources/ \\n"
99
100It is useful to note that BitBake
101supports cross-URLs. It is possible to mirror a Git repository on an
102HTTP server as a tarball. This is what the ``git://`` mapping in the
103previous example does.
104
105Since network accesses are slow, BitBake maintains a cache of files
106downloaded from the network. Any source files that are not local (i.e.
107downloaded from the Internet) are placed into the download directory,
108which is specified by the :term:`DL_DIR` variable.
109
110File integrity is of key importance for reproducing builds. For
111non-local archive downloads, the fetcher code can verify SHA-256 and MD5
112checksums to ensure the archives have been downloaded correctly. You can
Patrick Williams213cb262021-08-07 19:21:33 -0500113specify these checksums by using the :term:`SRC_URI` variable with the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500114appropriate varflags as follows::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500115
116 SRC_URI[md5sum] = "value"
117 SRC_URI[sha256sum] = "value"
118
119You can also specify the checksums as
Patrick Williams213cb262021-08-07 19:21:33 -0500120parameters on the :term:`SRC_URI` as shown below::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500121
122 SRC_URI = "http://example.com/foobar.tar.bz2;md5sum=4a8e0f237e961fd7785d19d07fdb994d"
123
124If multiple URIs exist, you can specify the checksums either directly as
125in the previous example, or you can name the URLs. The following syntax
Andrew Geisslerc926e172021-05-07 16:11:35 -0500126shows how you name the URIs::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500127
128 SRC_URI = "http://example.com/foobar.tar.bz2;name=foo"
129 SRC_URI[foo.md5sum] = 4a8e0f237e961fd7785d19d07fdb994d
130
131After a file has been downloaded and
Patrick Williams213cb262021-08-07 19:21:33 -0500132has had its checksum checked, a ".done" stamp is placed in :term:`DL_DIR`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500133BitBake uses this stamp during subsequent builds to avoid downloading or
134comparing a checksum for the file again.
135
136.. note::
137
138 It is assumed that local storage is safe from data corruption. If
139 this were not the case, there would be bigger issues to worry about.
140
141If :term:`BB_STRICT_CHECKSUM` is set, any
142download without a checksum triggers an error message. The
143:term:`BB_NO_NETWORK` variable can be used to
144make any attempted network access a fatal error, which is useful for
145checking that mirrors are complete as well as other things.
146
Patrick Williams0ca19cc2021-08-16 14:03:13 -0500147If :term:`BB_CHECK_SSL_CERTS` is set to ``0`` then SSL certificate checking will
148be disabled. This variable defaults to ``1`` so SSL certificates are normally
149checked.
150
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500151.. _bb-the-unpack:
152
153The Unpack
154==========
155
156The unpack process usually immediately follows the download. For all
157URLs except Git URLs, BitBake uses the common ``unpack`` method.
158
159A number of parameters exist that you can specify within the URL to
160govern the behavior of the unpack stage:
161
162- *unpack:* Controls whether the URL components are unpacked. If set to
163 "1", which is the default, the components are unpacked. If set to
164 "0", the unpack stage leaves the file alone. This parameter is useful
165 when you want an archive to be copied in and not be unpacked.
166
167- *dos:* Applies to ``.zip`` and ``.jar`` files and specifies whether
168 to use DOS line ending conversion on text files.
169
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500170- *subdir:* Unpacks the specific URL to the specified subdirectory
171 within the root directory.
172
173The unpack call automatically decompresses and extracts files with ".Z",
174".z", ".gz", ".xz", ".zip", ".jar", ".ipk", ".rpm". ".srpm", ".deb" and
175".bz2" extensions as well as various combinations of tarball extensions.
176
177As mentioned, the Git fetcher has its own unpack method that is
178optimized to work with Git trees. Basically, this method works by
179cloning the tree into the final directory. The process is completed
180using references so that there is only one central copy of the Git
181metadata needed.
182
183.. _bb-fetchers:
184
185Fetchers
186========
187
188As mentioned earlier, the URL prefix determines which fetcher submodule
189BitBake uses. Each submodule can support different URL parameters, which
190are described in the following sections.
191
192.. _local-file-fetcher:
193
194Local file fetcher (``file://``)
195--------------------------------
196
197This submodule handles URLs that begin with ``file://``. The filename
198you specify within the URL can be either an absolute or relative path to
199a file. If the filename is relative, the contents of the
200:term:`FILESPATH` variable is used in the same way
201``PATH`` is used to find executables. If the file cannot be found, it is
202assumed that it is available in :term:`DL_DIR` by the
203time the ``download()`` method is called.
204
205If you specify a directory, the entire directory is unpacked.
206
207Here are a couple of example URLs, the first relative and the second
Andrew Geisslerc926e172021-05-07 16:11:35 -0500208absolute::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500209
210 SRC_URI = "file://relativefile.patch"
211 SRC_URI = "file:///Users/ich/very_important_software"
212
213.. _http-ftp-fetcher:
214
215HTTP/FTP wget fetcher (``http://``, ``ftp://``, ``https://``)
216-------------------------------------------------------------
217
218This fetcher obtains files from web and FTP servers. Internally, the
219fetcher uses the wget utility.
220
221The executable and parameters used are specified by the
222``FETCHCMD_wget`` variable, which defaults to sensible values. The
223fetcher supports a parameter "downloadfilename" that allows the name of
224the downloaded file to be specified. Specifying the name of the
225downloaded file is useful for avoiding collisions in
226:term:`DL_DIR` when dealing with multiple files that
227have the same name.
228
Andrew Geisslerc926e172021-05-07 16:11:35 -0500229Some example URLs are as follows::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500230
231 SRC_URI = "http://oe.handhelds.org/not_there.aac"
232 SRC_URI = "ftp://oe.handhelds.org/not_there_as_well.aac"
233 SRC_URI = "ftp://you@oe.handhelds.org/home/you/secret.plan"
234
235.. note::
236
237 Because URL parameters are delimited by semi-colons, this can
238 introduce ambiguity when parsing URLs that also contain semi-colons,
Andrew Geisslerc926e172021-05-07 16:11:35 -0500239 for example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500240
241 SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git;a=snapshot;h=a5dd47"
242
243
244 Such URLs should should be modified by replacing semi-colons with '&'
Andrew Geisslerc926e172021-05-07 16:11:35 -0500245 characters::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500246
247 SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git&a=snapshot&h=a5dd47"
248
249
250 In most cases this should work. Treating semi-colons and '&' in
251 queries identically is recommended by the World Wide Web Consortium
252 (W3C). Note that due to the nature of the URL, you may have to
Andrew Geisslerc926e172021-05-07 16:11:35 -0500253 specify the name of the downloaded file as well::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500254
255 SRC_URI = "http://abc123.org/git/?p=gcc/gcc.git&a=snapshot&h=a5dd47;downloadfilename=myfile.bz2"
256
257
258.. _cvs-fetcher:
259
260CVS fetcher (``(cvs://``)
261-------------------------
262
263This submodule handles checking out files from the CVS version control
264system. You can configure it using a number of different variables:
265
266- :term:`FETCHCMD_cvs <FETCHCMD>`: The name of the executable to use when running
267 the ``cvs`` command. This name is usually "cvs".
268
269- :term:`SRCDATE`: The date to use when fetching the CVS source code. A
270 special value of "now" causes the checkout to be updated on every
271 build.
272
273- :term:`CVSDIR`: Specifies where a temporary
274 checkout is saved. The location is often ``DL_DIR/cvs``.
275
276- CVS_PROXY_HOST: The name to use as a "proxy=" parameter to the
277 ``cvs`` command.
278
279- CVS_PROXY_PORT: The port number to use as a "proxyport="
280 parameter to the ``cvs`` command.
281
282As well as the standard username and password URL syntax, you can also
283configure the fetcher with various URL parameters:
284
285The supported parameters are as follows:
286
287- *"method":* The protocol over which to communicate with the CVS
288 server. By default, this protocol is "pserver". If "method" is set to
289 "ext", BitBake examines the "rsh" parameter and sets ``CVS_RSH``. You
290 can use "dir" for local directories.
291
292- *"module":* Specifies the module to check out. You must supply this
293 parameter.
294
295- *"tag":* Describes which CVS TAG should be used for the checkout. By
296 default, the TAG is empty.
297
298- *"date":* Specifies a date. If no "date" is specified, the
299 :term:`SRCDATE` of the configuration is used to
300 checkout a specific date. The special value of "now" causes the
301 checkout to be updated on every build.
302
303- *"localdir":* Used to rename the module. Effectively, you are
304 renaming the output directory to which the module is unpacked. You
305 are forcing the module into a special directory relative to
306 :term:`CVSDIR`.
307
308- *"rsh":* Used in conjunction with the "method" parameter.
309
310- *"scmdata":* Causes the CVS metadata to be maintained in the tarball
311 the fetcher creates when set to "keep". The tarball is expanded into
312 the work directory. By default, the CVS metadata is removed.
313
314- *"fullpath":* Controls whether the resulting checkout is at the
315 module level, which is the default, or is at deeper paths.
316
317- *"norecurse":* Causes the fetcher to only checkout the specified
318 directory with no recurse into any subdirectories.
319
320- *"port":* The port to which the CVS server connects.
321
Andrew Geisslerc926e172021-05-07 16:11:35 -0500322Some example URLs are as follows::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500323
324 SRC_URI = "cvs://CVSROOT;module=mymodule;tag=some-version;method=ext"
325 SRC_URI = "cvs://CVSROOT;module=mymodule;date=20060126;localdir=usethat"
326
327.. _svn-fetcher:
328
329Subversion (SVN) Fetcher (``svn://``)
330-------------------------------------
331
332This fetcher submodule fetches code from the Subversion source control
333system. The executable used is specified by ``FETCHCMD_svn``, which
334defaults to "svn". The fetcher's temporary working directory is set by
335:term:`SVNDIR`, which is usually ``DL_DIR/svn``.
336
337The supported parameters are as follows:
338
339- *"module":* The name of the svn module to checkout. You must provide
340 this parameter. You can think of this parameter as the top-level
341 directory of the repository data you want.
342
343- *"path_spec":* A specific directory in which to checkout the
344 specified svn module.
345
346- *"protocol":* The protocol to use, which defaults to "svn". If
347 "protocol" is set to "svn+ssh", the "ssh" parameter is also used.
348
349- *"rev":* The revision of the source code to checkout.
350
Andrew Geisslerf0343792020-11-18 10:42:21 -0600351- *"scmdata":* Causes the ".svn" directories to be available during
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500352 compile-time when set to "keep". By default, these directories are
353 removed.
354
355- *"ssh":* An optional parameter used when "protocol" is set to
356 "svn+ssh". You can use this parameter to specify the ssh program used
357 by svn.
358
359- *"transportuser":* When required, sets the username for the
360 transport. By default, this parameter is empty. The transport
361 username is different than the username used in the main URL, which
362 is passed to the subversion command.
363
Andrew Geisslerc926e172021-05-07 16:11:35 -0500364Following are three examples using svn::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500365
366 SRC_URI = "svn://myrepos/proj1;module=vip;protocol=http;rev=667"
367 SRC_URI = "svn://myrepos/proj1;module=opie;protocol=svn+ssh"
368 SRC_URI = "svn://myrepos/proj1;module=trunk;protocol=http;path_spec=${MY_DIR}/proj1"
369
370.. _git-fetcher:
371
372Git Fetcher (``git://``)
373------------------------
374
375This fetcher submodule fetches code from the Git source control system.
376The fetcher works by creating a bare clone of the remote into
377:term:`GITDIR`, which is usually ``DL_DIR/git2``. This
378bare clone is then cloned into the work directory during the unpack
379stage when a specific tree is checked out. This is done using alternates
380and by reference to minimize the amount of duplicate data on the disk
381and make the unpack process fast. The executable used can be set with
382``FETCHCMD_git``.
383
384This fetcher supports the following parameters:
385
386- *"protocol":* The protocol used to fetch the files. The default is
387 "git" when a hostname is set. If a hostname is not set, the Git
388 protocol is "file". You can also use "http", "https", "ssh" and
389 "rsync".
390
391- *"nocheckout":* Tells the fetcher to not checkout source code when
392 unpacking when set to "1". Set this option for the URL where there is
393 a custom routine to checkout code. The default is "0".
394
395- *"rebaseable":* Indicates that the upstream Git repository can be
396 rebased. You should set this parameter to "1" if revisions can become
397 detached from branches. In this case, the source mirror tarball is
398 done per revision, which has a loss of efficiency. Rebasing the
399 upstream Git repository could cause the current revision to disappear
400 from the upstream repository. This option reminds the fetcher to
401 preserve the local cache carefully for future use. The default value
402 for this parameter is "0".
403
404- *"nobranch":* Tells the fetcher to not check the SHA validation for
405 the branch when set to "1". The default is "0". Set this option for
406 the recipe that refers to the commit that is valid for a tag instead
407 of the branch.
408
409- *"bareclone":* Tells the fetcher to clone a bare clone into the
410 destination directory without checking out a working tree. Only the
411 raw Git metadata is provided. This parameter implies the "nocheckout"
412 parameter as well.
413
414- *"branch":* The branch(es) of the Git tree to clone. If unset, this
415 is assumed to be "master". The number of branch parameters much match
416 the number of name parameters.
417
418- *"rev":* The revision to use for the checkout. The default is
419 "master".
420
421- *"tag":* Specifies a tag to use for the checkout. To correctly
422 resolve tags, BitBake must access the network. For that reason, tags
423 are often not used. As far as Git is concerned, the "tag" parameter
424 behaves effectively the same as the "rev" parameter.
425
426- *"subpath":* Limits the checkout to a specific subpath of the tree.
427 By default, the whole tree is checked out.
428
429- *"destsuffix":* The name of the path in which to place the checkout.
430 By default, the path is ``git/``.
431
432- *"usehead":* Enables local ``git://`` URLs to use the current branch
433 HEAD as the revision for use with ``AUTOREV``. The "usehead"
434 parameter implies no branch and only works when the transfer protocol
435 is ``file://``.
436
Andrew Geisslerc926e172021-05-07 16:11:35 -0500437Here are some example URLs::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500438
439 SRC_URI = "git://git.oe.handhelds.org/git/vip.git;tag=version-1"
440 SRC_URI = "git://git.oe.handhelds.org/git/vip.git;protocol=http"
441
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500442.. note::
443
Andrew Geissler5199d832021-09-24 16:47:35 -0500444 When using ``git`` as the fetcher of the main source code of your software,
445 ``S`` should be set accordingly::
446
447 S = "${WORKDIR}/git"
448
449.. note::
450
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500451 Specifying passwords directly in ``git://`` urls is not supported.
Patrick Williams213cb262021-08-07 19:21:33 -0500452 There are several reasons: :term:`SRC_URI` is often written out to logs and
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500453 other places, and that could easily leak passwords; it is also all too
454 easy to share metadata without removing passwords. SSH keys, ``~/.netrc``
455 and ``~/.ssh/config`` files can be used as alternatives.
456
457
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500458.. _gitsm-fetcher:
459
460Git Submodule Fetcher (``gitsm://``)
461------------------------------------
462
463This fetcher submodule inherits from the :ref:`Git
464fetcher<bitbake-user-manual/bitbake-user-manual-fetching:git fetcher
465(\`\`git://\`\`)>` and extends that fetcher's behavior by fetching a
466repository's submodules. :term:`SRC_URI` is passed to the Git fetcher as
467described in the :ref:`bitbake-user-manual/bitbake-user-manual-fetching:git
468fetcher (\`\`git://\`\`)` section.
469
470.. note::
471
472 You must clean a recipe when switching between '``git://``' and
473 '``gitsm://``' URLs.
474
475 The Git Submodules fetcher is not a complete fetcher implementation.
476 The fetcher has known issues where it does not use the normal source
477 mirroring infrastructure properly. Further, the submodule sources it
478 fetches are not visible to the licensing and source archiving
479 infrastructures.
480
481.. _clearcase-fetcher:
482
483ClearCase Fetcher (``ccrc://``)
484-------------------------------
485
486This fetcher submodule fetches code from a
487`ClearCase <http://en.wikipedia.org/wiki/Rational_ClearCase>`__
488repository.
489
490To use this fetcher, make sure your recipe has proper
491:term:`SRC_URI`, :term:`SRCREV`, and
Andrew Geisslerc926e172021-05-07 16:11:35 -0500492:term:`PV` settings. Here is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500493
494 SRC_URI = "ccrc://cc.example.org/ccrc;vob=/example_vob;module=/example_module"
495 SRCREV = "EXAMPLE_CLEARCASE_TAG"
496 PV = "${@d.getVar("SRCREV", False).replace("/", "+")}"
497
498The fetcher uses the ``rcleartool`` or
499``cleartool`` remote client, depending on which one is available.
500
Patrick Williams213cb262021-08-07 19:21:33 -0500501Following are options for the :term:`SRC_URI` statement:
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500502
503- *vob*: The name, which must include the prepending "/" character,
504 of the ClearCase VOB. This option is required.
505
506- *module*: The module, which must include the prepending "/"
507 character, in the selected VOB.
508
509 .. note::
510
511 The module and vob options are combined to create the load rule in the
512 view config spec. As an example, consider the vob and module values from
513 the SRC_URI statement at the start of this section. Combining those values
Andrew Geisslerc926e172021-05-07 16:11:35 -0500514 results in the following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500515
516 load /example_vob/example_module
517
518- *proto*: The protocol, which can be either ``http`` or ``https``.
519
520By default, the fetcher creates a configuration specification. If you
521want this specification written to an area other than the default, use
522the ``CCASE_CUSTOM_CONFIG_SPEC`` variable in your recipe to define where
523the specification is written.
524
525.. note::
526
527 the SRCREV loses its functionality if you specify this variable. However,
528 SRCREV is still used to label the archive after a fetch even though it does
529 not define what is fetched.
530
531Here are a couple of other behaviors worth mentioning:
532
533- When using ``cleartool``, the login of ``cleartool`` is handled by
534 the system. The login require no special steps.
535
536- In order to use ``rcleartool`` with authenticated users, an
537 "rcleartool login" is necessary before using the fetcher.
538
539.. _perforce-fetcher:
540
541Perforce Fetcher (``p4://``)
542----------------------------
543
544This fetcher submodule fetches code from the
545`Perforce <https://www.perforce.com/>`__ source control system. The
546executable used is specified by ``FETCHCMD_p4``, which defaults to "p4".
547The fetcher's temporary working directory is set by
548:term:`P4DIR`, which defaults to "DL_DIR/p4".
549The fetcher does not make use of a perforce client, instead it
550relies on ``p4 files`` to retrieve a list of
551files and ``p4 print`` to transfer the content
552of those files locally.
553
554To use this fetcher, make sure your recipe has proper
555:term:`SRC_URI`, :term:`SRCREV`, and
556:term:`PV` values. The p4 executable is able to use the
557config file defined by your system's ``P4CONFIG`` environment variable
558in order to define the Perforce server URL and port, username, and
559password if you do not wish to keep those values in a recipe itself. If
560you choose not to use ``P4CONFIG``, or to explicitly set variables that
561``P4CONFIG`` can contain, you can specify the ``P4PORT`` value, which is
562the server's URL and port number, and you can specify a username and
Patrick Williams213cb262021-08-07 19:21:33 -0500563password directly in your recipe within :term:`SRC_URI`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500564
565Here is an example that relies on ``P4CONFIG`` to specify the server URL
Andrew Geisslerc926e172021-05-07 16:11:35 -0500566and port, username, and password, and fetches the Head Revision::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500567
568 SRC_URI = "p4://example-depot/main/source/..."
569 SRCREV = "${AUTOREV}"
570 PV = "p4-${SRCPV}"
571 S = "${WORKDIR}/p4"
572
573Here is an example that specifies the server URL and port, username, and
Andrew Geisslerc926e172021-05-07 16:11:35 -0500574password, and fetches a Revision based on a Label::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500575
576 P4PORT = "tcp:p4server.example.net:1666"
577 SRC_URI = "p4://user:passwd@example-depot/main/source/..."
578 SRCREV = "release-1.0"
579 PV = "p4-${SRCPV}"
580 S = "${WORKDIR}/p4"
581
582.. note::
583
584 You should always set S to "${WORKDIR}/p4" in your recipe.
585
586By default, the fetcher strips the depot location from the local file paths. In
587the above example, the content of ``example-depot/main/source/`` will be placed
588in ``${WORKDIR}/p4``. For situations where preserving parts of the remote depot
589paths locally is desirable, the fetcher supports two parameters:
590
591- *"module":*
592 The top-level depot location or directory to fetch. The value of this
593 parameter can also point to a single file within the depot, in which case
594 the local file path will include the module path.
595- *"remotepath":*
596 When used with the value "``keep``", the fetcher will mirror the full depot
597 paths locally for the specified location, even in combination with the
598 ``module`` parameter.
599
Andrew Geisslerc926e172021-05-07 16:11:35 -0500600Here is an example use of the the ``module`` parameter::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500601
602 SRC_URI = "p4://user:passwd@example-depot/main;module=source/..."
603
604In this case, the content of the top-level directory ``source/`` will be fetched
605to ``${P4DIR}``, including the directory itself. The top-level directory will
606be accesible at ``${P4DIR}/source/``.
607
Andrew Geisslerc926e172021-05-07 16:11:35 -0500608Here is an example use of the the ``remotepath`` parameter::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500609
610 SRC_URI = "p4://user:passwd@example-depot/main;module=source/...;remotepath=keep"
611
612In this case, the content of the top-level directory ``source/`` will be fetched
613to ``${P4DIR}``, but the complete depot paths will be mirrored locally. The
614top-level directory will be accessible at
615``${P4DIR}/example-depot/main/source/``.
616
617.. _repo-fetcher:
618
619Repo Fetcher (``repo://``)
620--------------------------
621
622This fetcher submodule fetches code from ``google-repo`` source control
623system. The fetcher works by initiating and syncing sources of the
624repository into :term:`REPODIR`, which is usually
625``${DL_DIR}/repo``.
626
627This fetcher supports the following parameters:
628
629- *"protocol":* Protocol to fetch the repository manifest (default:
630 git).
631
632- *"branch":* Branch or tag of repository to get (default: master).
633
634- *"manifest":* Name of the manifest file (default: ``default.xml``).
635
Andrew Geisslerc926e172021-05-07 16:11:35 -0500636Here are some example URLs::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500637
638 SRC_URI = "repo://REPOROOT;protocol=git;branch=some_branch;manifest=my_manifest.xml"
639 SRC_URI = "repo://REPOROOT;protocol=file;branch=some_branch;manifest=my_manifest.xml"
640
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500641.. _az-fetcher:
642
643Az Fetcher (``az://``)
644--------------------------
645
646This submodule fetches data from an
647`Azure Storage account <https://docs.microsoft.com/en-us/azure/storage/>`__ ,
648it inherits its functionality from the HTTP wget fetcher, but modifies its
649behavior to accomodate the usage of a
650`Shared Access Signature (SAS) <https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview>`__
651for non-public data.
652
653Such functionality is set by the variable:
654
655- :term:`AZ_SAS`: The Azure Storage Shared Access Signature provides secure
656 delegate access to resources, if this variable is set, the Az Fetcher will
657 use it when fetching artifacts from the cloud.
658
Andrew Geisslerc926e172021-05-07 16:11:35 -0500659You can specify the AZ_SAS variable as shown below::
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500660
661 AZ_SAS = "se=2021-01-01&sp=r&sv=2018-11-09&sr=c&skoid=<skoid>&sig=<signature>"
662
Andrew Geisslerc926e172021-05-07 16:11:35 -0500663Here is an example URL::
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500664
665 SRC_URI = "az://<azure-storage-account>.blob.core.windows.net/<foo_container>/<bar_file>"
666
667It can also be used when setting mirrors definitions using the :term:`PREMIRRORS` variable.
668
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500669Other Fetchers
670--------------
671
672Fetch submodules also exist for the following:
673
674- Bazaar (``bzr://``)
675
676- Mercurial (``hg://``)
677
678- npm (``npm://``)
679
680- OSC (``osc://``)
681
682- Secure FTP (``sftp://``)
683
684- Secure Shell (``ssh://``)
685
686- Trees using Git Annex (``gitannex://``)
687
688No documentation currently exists for these lesser used fetcher
689submodules. However, you might find the code helpful and readable.
690
691Auto Revisions
692==============
693
Patrick Williams213cb262021-08-07 19:21:33 -0500694We need to document ``AUTOREV`` and :term:`SRCREV_FORMAT` here.