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