blob: 40b245b6d30843f1991a497591042fb81763a0c5 [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
77 http://git.yoctoproject.org/git/poky;protocol=git
78 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
444 Specifying passwords directly in ``git://`` urls is not supported.
Patrick Williams213cb262021-08-07 19:21:33 -0500445 There are several reasons: :term:`SRC_URI` is often written out to logs and
Andrew Geissler3b8a17c2021-04-15 15:55:55 -0500446 other places, and that could easily leak passwords; it is also all too
447 easy to share metadata without removing passwords. SSH keys, ``~/.netrc``
448 and ``~/.ssh/config`` files can be used as alternatives.
449
450
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500451.. _gitsm-fetcher:
452
453Git Submodule Fetcher (``gitsm://``)
454------------------------------------
455
456This fetcher submodule inherits from the :ref:`Git
457fetcher<bitbake-user-manual/bitbake-user-manual-fetching:git fetcher
458(\`\`git://\`\`)>` and extends that fetcher's behavior by fetching a
459repository's submodules. :term:`SRC_URI` is passed to the Git fetcher as
460described in the :ref:`bitbake-user-manual/bitbake-user-manual-fetching:git
461fetcher (\`\`git://\`\`)` section.
462
463.. note::
464
465 You must clean a recipe when switching between '``git://``' and
466 '``gitsm://``' URLs.
467
468 The Git Submodules fetcher is not a complete fetcher implementation.
469 The fetcher has known issues where it does not use the normal source
470 mirroring infrastructure properly. Further, the submodule sources it
471 fetches are not visible to the licensing and source archiving
472 infrastructures.
473
474.. _clearcase-fetcher:
475
476ClearCase Fetcher (``ccrc://``)
477-------------------------------
478
479This fetcher submodule fetches code from a
480`ClearCase <http://en.wikipedia.org/wiki/Rational_ClearCase>`__
481repository.
482
483To use this fetcher, make sure your recipe has proper
484:term:`SRC_URI`, :term:`SRCREV`, and
Andrew Geisslerc926e172021-05-07 16:11:35 -0500485:term:`PV` settings. Here is an example::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500486
487 SRC_URI = "ccrc://cc.example.org/ccrc;vob=/example_vob;module=/example_module"
488 SRCREV = "EXAMPLE_CLEARCASE_TAG"
489 PV = "${@d.getVar("SRCREV", False).replace("/", "+")}"
490
491The fetcher uses the ``rcleartool`` or
492``cleartool`` remote client, depending on which one is available.
493
Patrick Williams213cb262021-08-07 19:21:33 -0500494Following are options for the :term:`SRC_URI` statement:
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500495
496- *vob*: The name, which must include the prepending "/" character,
497 of the ClearCase VOB. This option is required.
498
499- *module*: The module, which must include the prepending "/"
500 character, in the selected VOB.
501
502 .. note::
503
504 The module and vob options are combined to create the load rule in the
505 view config spec. As an example, consider the vob and module values from
506 the SRC_URI statement at the start of this section. Combining those values
Andrew Geisslerc926e172021-05-07 16:11:35 -0500507 results in the following::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500508
509 load /example_vob/example_module
510
511- *proto*: The protocol, which can be either ``http`` or ``https``.
512
513By default, the fetcher creates a configuration specification. If you
514want this specification written to an area other than the default, use
515the ``CCASE_CUSTOM_CONFIG_SPEC`` variable in your recipe to define where
516the specification is written.
517
518.. note::
519
520 the SRCREV loses its functionality if you specify this variable. However,
521 SRCREV is still used to label the archive after a fetch even though it does
522 not define what is fetched.
523
524Here are a couple of other behaviors worth mentioning:
525
526- When using ``cleartool``, the login of ``cleartool`` is handled by
527 the system. The login require no special steps.
528
529- In order to use ``rcleartool`` with authenticated users, an
530 "rcleartool login" is necessary before using the fetcher.
531
532.. _perforce-fetcher:
533
534Perforce Fetcher (``p4://``)
535----------------------------
536
537This fetcher submodule fetches code from the
538`Perforce <https://www.perforce.com/>`__ source control system. The
539executable used is specified by ``FETCHCMD_p4``, which defaults to "p4".
540The fetcher's temporary working directory is set by
541:term:`P4DIR`, which defaults to "DL_DIR/p4".
542The fetcher does not make use of a perforce client, instead it
543relies on ``p4 files`` to retrieve a list of
544files and ``p4 print`` to transfer the content
545of those files locally.
546
547To use this fetcher, make sure your recipe has proper
548:term:`SRC_URI`, :term:`SRCREV`, and
549:term:`PV` values. The p4 executable is able to use the
550config file defined by your system's ``P4CONFIG`` environment variable
551in order to define the Perforce server URL and port, username, and
552password if you do not wish to keep those values in a recipe itself. If
553you choose not to use ``P4CONFIG``, or to explicitly set variables that
554``P4CONFIG`` can contain, you can specify the ``P4PORT`` value, which is
555the server's URL and port number, and you can specify a username and
Patrick Williams213cb262021-08-07 19:21:33 -0500556password directly in your recipe within :term:`SRC_URI`.
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500557
558Here is an example that relies on ``P4CONFIG`` to specify the server URL
Andrew Geisslerc926e172021-05-07 16:11:35 -0500559and port, username, and password, and fetches the Head Revision::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500560
561 SRC_URI = "p4://example-depot/main/source/..."
562 SRCREV = "${AUTOREV}"
563 PV = "p4-${SRCPV}"
564 S = "${WORKDIR}/p4"
565
566Here is an example that specifies the server URL and port, username, and
Andrew Geisslerc926e172021-05-07 16:11:35 -0500567password, and fetches a Revision based on a Label::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500568
569 P4PORT = "tcp:p4server.example.net:1666"
570 SRC_URI = "p4://user:passwd@example-depot/main/source/..."
571 SRCREV = "release-1.0"
572 PV = "p4-${SRCPV}"
573 S = "${WORKDIR}/p4"
574
575.. note::
576
577 You should always set S to "${WORKDIR}/p4" in your recipe.
578
579By default, the fetcher strips the depot location from the local file paths. In
580the above example, the content of ``example-depot/main/source/`` will be placed
581in ``${WORKDIR}/p4``. For situations where preserving parts of the remote depot
582paths locally is desirable, the fetcher supports two parameters:
583
584- *"module":*
585 The top-level depot location or directory to fetch. The value of this
586 parameter can also point to a single file within the depot, in which case
587 the local file path will include the module path.
588- *"remotepath":*
589 When used with the value "``keep``", the fetcher will mirror the full depot
590 paths locally for the specified location, even in combination with the
591 ``module`` parameter.
592
Andrew Geisslerc926e172021-05-07 16:11:35 -0500593Here is an example use of the the ``module`` parameter::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500594
595 SRC_URI = "p4://user:passwd@example-depot/main;module=source/..."
596
597In this case, the content of the top-level directory ``source/`` will be fetched
598to ``${P4DIR}``, including the directory itself. The top-level directory will
599be accesible at ``${P4DIR}/source/``.
600
Andrew Geisslerc926e172021-05-07 16:11:35 -0500601Here is an example use of the the ``remotepath`` parameter::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500602
603 SRC_URI = "p4://user:passwd@example-depot/main;module=source/...;remotepath=keep"
604
605In this case, the content of the top-level directory ``source/`` will be fetched
606to ``${P4DIR}``, but the complete depot paths will be mirrored locally. The
607top-level directory will be accessible at
608``${P4DIR}/example-depot/main/source/``.
609
610.. _repo-fetcher:
611
612Repo Fetcher (``repo://``)
613--------------------------
614
615This fetcher submodule fetches code from ``google-repo`` source control
616system. The fetcher works by initiating and syncing sources of the
617repository into :term:`REPODIR`, which is usually
618``${DL_DIR}/repo``.
619
620This fetcher supports the following parameters:
621
622- *"protocol":* Protocol to fetch the repository manifest (default:
623 git).
624
625- *"branch":* Branch or tag of repository to get (default: master).
626
627- *"manifest":* Name of the manifest file (default: ``default.xml``).
628
Andrew Geisslerc926e172021-05-07 16:11:35 -0500629Here are some example URLs::
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500630
631 SRC_URI = "repo://REPOROOT;protocol=git;branch=some_branch;manifest=my_manifest.xml"
632 SRC_URI = "repo://REPOROOT;protocol=file;branch=some_branch;manifest=my_manifest.xml"
633
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500634.. _az-fetcher:
635
636Az Fetcher (``az://``)
637--------------------------
638
639This submodule fetches data from an
640`Azure Storage account <https://docs.microsoft.com/en-us/azure/storage/>`__ ,
641it inherits its functionality from the HTTP wget fetcher, but modifies its
642behavior to accomodate the usage of a
643`Shared Access Signature (SAS) <https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview>`__
644for non-public data.
645
646Such functionality is set by the variable:
647
648- :term:`AZ_SAS`: The Azure Storage Shared Access Signature provides secure
649 delegate access to resources, if this variable is set, the Az Fetcher will
650 use it when fetching artifacts from the cloud.
651
Andrew Geisslerc926e172021-05-07 16:11:35 -0500652You can specify the AZ_SAS variable as shown below::
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500653
654 AZ_SAS = "se=2021-01-01&sp=r&sv=2018-11-09&sr=c&skoid=<skoid>&sig=<signature>"
655
Andrew Geisslerc926e172021-05-07 16:11:35 -0500656Here is an example URL::
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500657
658 SRC_URI = "az://<azure-storage-account>.blob.core.windows.net/<foo_container>/<bar_file>"
659
660It can also be used when setting mirrors definitions using the :term:`PREMIRRORS` variable.
661
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500662Other Fetchers
663--------------
664
665Fetch submodules also exist for the following:
666
667- Bazaar (``bzr://``)
668
669- Mercurial (``hg://``)
670
671- npm (``npm://``)
672
673- OSC (``osc://``)
674
675- Secure FTP (``sftp://``)
676
677- Secure Shell (``ssh://``)
678
679- Trees using Git Annex (``gitannex://``)
680
681No documentation currently exists for these lesser used fetcher
682submodules. However, you might find the code helpful and readable.
683
684Auto Revisions
685==============
686
Patrick Williams213cb262021-08-07 19:21:33 -0500687We need to document ``AUTOREV`` and :term:`SRCREV_FORMAT` here.