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 | |
| 77 | http://git.yoctoproject.org/git/poky;protocol=git |
| 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 ?= "\ |
| 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 | |
| 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 | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 170 | - *subdir:* Unpacks the specific URL to the specified subdirectory |
| 171 | within the root directory. |
| 172 | |
| 173 | The 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 | |
| 177 | As mentioned, the Git fetcher has its own unpack method that is |
| 178 | optimized to work with Git trees. Basically, this method works by |
| 179 | cloning the tree into the final directory. The process is completed |
| 180 | using references so that there is only one central copy of the Git |
| 181 | metadata needed. |
| 182 | |
| 183 | .. _bb-fetchers: |
| 184 | |
| 185 | Fetchers |
| 186 | ======== |
| 187 | |
| 188 | As mentioned earlier, the URL prefix determines which fetcher submodule |
| 189 | BitBake uses. Each submodule can support different URL parameters, which |
| 190 | are described in the following sections. |
| 191 | |
| 192 | .. _local-file-fetcher: |
| 193 | |
| 194 | Local file fetcher (``file://``) |
| 195 | -------------------------------- |
| 196 | |
| 197 | This submodule handles URLs that begin with ``file://``. The filename |
| 198 | you specify within the URL can be either an absolute or relative path to |
| 199 | a 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 |
| 202 | assumed that it is available in :term:`DL_DIR` by the |
| 203 | time the ``download()`` method is called. |
| 204 | |
| 205 | If you specify a directory, the entire directory is unpacked. |
| 206 | |
| 207 | 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] | 208 | absolute:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 209 | |
| 210 | SRC_URI = "file://relativefile.patch" |
| 211 | SRC_URI = "file:///Users/ich/very_important_software" |
| 212 | |
| 213 | .. _http-ftp-fetcher: |
| 214 | |
| 215 | HTTP/FTP wget fetcher (``http://``, ``ftp://``, ``https://``) |
| 216 | ------------------------------------------------------------- |
| 217 | |
| 218 | This fetcher obtains files from web and FTP servers. Internally, the |
| 219 | fetcher uses the wget utility. |
| 220 | |
| 221 | The executable and parameters used are specified by the |
| 222 | ``FETCHCMD_wget`` variable, which defaults to sensible values. The |
| 223 | fetcher supports a parameter "downloadfilename" that allows the name of |
| 224 | the downloaded file to be specified. Specifying the name of the |
| 225 | downloaded file is useful for avoiding collisions in |
| 226 | :term:`DL_DIR` when dealing with multiple files that |
| 227 | have the same name. |
| 228 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 229 | Some example URLs are as follows:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 230 | |
| 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 239 | for example:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 240 | |
| 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 245 | characters:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 246 | |
| 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 253 | specify the name of the downloaded file as well:: |
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;downloadfilename=myfile.bz2" |
| 256 | |
| 257 | |
| 258 | .. _cvs-fetcher: |
| 259 | |
| 260 | CVS fetcher (``(cvs://``) |
| 261 | ------------------------- |
| 262 | |
| 263 | This submodule handles checking out files from the CVS version control |
| 264 | system. 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 | |
| 282 | As well as the standard username and password URL syntax, you can also |
| 283 | configure the fetcher with various URL parameters: |
| 284 | |
| 285 | The 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 322 | Some example URLs are as follows:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 323 | |
| 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 | |
| 329 | Subversion (SVN) Fetcher (``svn://``) |
| 330 | ------------------------------------- |
| 331 | |
| 332 | This fetcher submodule fetches code from the Subversion source control |
| 333 | system. The executable used is specified by ``FETCHCMD_svn``, which |
| 334 | defaults to "svn". The fetcher's temporary working directory is set by |
| 335 | :term:`SVNDIR`, which is usually ``DL_DIR/svn``. |
| 336 | |
| 337 | The 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 Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 351 | - *"scmdata":* Causes the ".svn" directories to be available during |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 352 | 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 364 | Following are three examples using svn:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 365 | |
| 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 | |
| 372 | Git Fetcher (``git://``) |
| 373 | ------------------------ |
| 374 | |
| 375 | This fetcher submodule fetches code from the Git source control system. |
| 376 | The fetcher works by creating a bare clone of the remote into |
| 377 | :term:`GITDIR`, which is usually ``DL_DIR/git2``. This |
| 378 | bare clone is then cloned into the work directory during the unpack |
| 379 | stage when a specific tree is checked out. This is done using alternates |
| 380 | and by reference to minimize the amount of duplicate data on the disk |
| 381 | and make the unpack process fast. The executable used can be set with |
| 382 | ``FETCHCMD_git``. |
| 383 | |
| 384 | This 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 437 | Here are some example URLs:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 438 | |
| 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 Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 442 | .. note:: |
| 443 | |
| 444 | Specifying passwords directly in ``git://`` urls is not supported. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 445 | 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] | 446 | 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 Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 451 | .. _gitsm-fetcher: |
| 452 | |
| 453 | Git Submodule Fetcher (``gitsm://``) |
| 454 | ------------------------------------ |
| 455 | |
| 456 | This fetcher submodule inherits from the :ref:`Git |
| 457 | fetcher<bitbake-user-manual/bitbake-user-manual-fetching:git fetcher |
| 458 | (\`\`git://\`\`)>` and extends that fetcher's behavior by fetching a |
| 459 | repository's submodules. :term:`SRC_URI` is passed to the Git fetcher as |
| 460 | described in the :ref:`bitbake-user-manual/bitbake-user-manual-fetching:git |
| 461 | fetcher (\`\`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 | |
| 476 | ClearCase Fetcher (``ccrc://``) |
| 477 | ------------------------------- |
| 478 | |
| 479 | This fetcher submodule fetches code from a |
| 480 | `ClearCase <http://en.wikipedia.org/wiki/Rational_ClearCase>`__ |
| 481 | repository. |
| 482 | |
| 483 | To use this fetcher, make sure your recipe has proper |
| 484 | :term:`SRC_URI`, :term:`SRCREV`, and |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 485 | :term:`PV` settings. Here is an example:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 486 | |
| 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 | |
| 491 | The fetcher uses the ``rcleartool`` or |
| 492 | ``cleartool`` remote client, depending on which one is available. |
| 493 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 494 | Following are options for the :term:`SRC_URI` statement: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 495 | |
| 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 507 | results in the following:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 508 | |
| 509 | load /example_vob/example_module |
| 510 | |
| 511 | - *proto*: The protocol, which can be either ``http`` or ``https``. |
| 512 | |
| 513 | By default, the fetcher creates a configuration specification. If you |
| 514 | want this specification written to an area other than the default, use |
| 515 | the ``CCASE_CUSTOM_CONFIG_SPEC`` variable in your recipe to define where |
| 516 | the 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 | |
| 524 | Here 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 | |
| 534 | Perforce Fetcher (``p4://``) |
| 535 | ---------------------------- |
| 536 | |
| 537 | This fetcher submodule fetches code from the |
| 538 | `Perforce <https://www.perforce.com/>`__ source control system. The |
| 539 | executable used is specified by ``FETCHCMD_p4``, which defaults to "p4". |
| 540 | The fetcher's temporary working directory is set by |
| 541 | :term:`P4DIR`, which defaults to "DL_DIR/p4". |
| 542 | The fetcher does not make use of a perforce client, instead it |
| 543 | relies on ``p4 files`` to retrieve a list of |
| 544 | files and ``p4 print`` to transfer the content |
| 545 | of those files locally. |
| 546 | |
| 547 | To 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 |
| 550 | config file defined by your system's ``P4CONFIG`` environment variable |
| 551 | in order to define the Perforce server URL and port, username, and |
| 552 | password if you do not wish to keep those values in a recipe itself. If |
| 553 | you choose not to use ``P4CONFIG``, or to explicitly set variables that |
| 554 | ``P4CONFIG`` can contain, you can specify the ``P4PORT`` value, which is |
| 555 | 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] | 556 | password directly in your recipe within :term:`SRC_URI`. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 557 | |
| 558 | 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] | 559 | and port, username, and password, and fetches the Head Revision:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 560 | |
| 561 | SRC_URI = "p4://example-depot/main/source/..." |
| 562 | SRCREV = "${AUTOREV}" |
| 563 | PV = "p4-${SRCPV}" |
| 564 | S = "${WORKDIR}/p4" |
| 565 | |
| 566 | 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] | 567 | password, and fetches a Revision based on a Label:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 568 | |
| 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 | |
| 579 | By default, the fetcher strips the depot location from the local file paths. In |
| 580 | the above example, the content of ``example-depot/main/source/`` will be placed |
| 581 | in ``${WORKDIR}/p4``. For situations where preserving parts of the remote depot |
| 582 | paths 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 593 | Here is an example use of the the ``module`` parameter:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 594 | |
| 595 | SRC_URI = "p4://user:passwd@example-depot/main;module=source/..." |
| 596 | |
| 597 | In this case, the content of the top-level directory ``source/`` will be fetched |
| 598 | to ``${P4DIR}``, including the directory itself. The top-level directory will |
| 599 | be accesible at ``${P4DIR}/source/``. |
| 600 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 601 | Here is an example use of the the ``remotepath`` parameter:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 602 | |
| 603 | SRC_URI = "p4://user:passwd@example-depot/main;module=source/...;remotepath=keep" |
| 604 | |
| 605 | In this case, the content of the top-level directory ``source/`` will be fetched |
| 606 | to ``${P4DIR}``, but the complete depot paths will be mirrored locally. The |
| 607 | top-level directory will be accessible at |
| 608 | ``${P4DIR}/example-depot/main/source/``. |
| 609 | |
| 610 | .. _repo-fetcher: |
| 611 | |
| 612 | Repo Fetcher (``repo://``) |
| 613 | -------------------------- |
| 614 | |
| 615 | This fetcher submodule fetches code from ``google-repo`` source control |
| 616 | system. The fetcher works by initiating and syncing sources of the |
| 617 | repository into :term:`REPODIR`, which is usually |
| 618 | ``${DL_DIR}/repo``. |
| 619 | |
| 620 | This 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 629 | Here are some example URLs:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 630 | |
| 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 Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 634 | .. _az-fetcher: |
| 635 | |
| 636 | Az Fetcher (``az://``) |
| 637 | -------------------------- |
| 638 | |
| 639 | This submodule fetches data from an |
| 640 | `Azure Storage account <https://docs.microsoft.com/en-us/azure/storage/>`__ , |
| 641 | it inherits its functionality from the HTTP wget fetcher, but modifies its |
| 642 | behavior to accomodate the usage of a |
| 643 | `Shared Access Signature (SAS) <https://docs.microsoft.com/en-us/azure/storage/common/storage-sas-overview>`__ |
| 644 | for non-public data. |
| 645 | |
| 646 | Such 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 Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 652 | You can specify the AZ_SAS variable as shown below:: |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 653 | |
| 654 | AZ_SAS = "se=2021-01-01&sp=r&sv=2018-11-09&sr=c&skoid=<skoid>&sig=<signature>" |
| 655 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 656 | Here is an example URL:: |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 657 | |
| 658 | SRC_URI = "az://<azure-storage-account>.blob.core.windows.net/<foo_container>/<bar_file>" |
| 659 | |
| 660 | It can also be used when setting mirrors definitions using the :term:`PREMIRRORS` variable. |
| 661 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 662 | Other Fetchers |
| 663 | -------------- |
| 664 | |
| 665 | Fetch 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 | |
| 681 | No documentation currently exists for these lesser used fetcher |
| 682 | submodules. However, you might find the code helpful and readable. |
| 683 | |
| 684 | Auto Revisions |
| 685 | ============== |
| 686 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 687 | We need to document ``AUTOREV`` and :term:`SRCREV_FORMAT` here. |