Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK |
| 2 | |
| 3 | Efficiently Fetching Source Files During a Build |
| 4 | ************************************************ |
| 5 | |
| 6 | The OpenEmbedded build system works with source files located through |
| 7 | the :term:`SRC_URI` variable. When |
| 8 | you build something using BitBake, a big part of the operation is |
| 9 | locating and downloading all the source tarballs. For images, |
| 10 | downloading all the source for various packages can take a significant |
| 11 | amount of time. |
| 12 | |
| 13 | This section shows you how you can use mirrors to speed up fetching |
| 14 | source files and how you can pre-fetch files all of which leads to more |
| 15 | efficient use of resources and time. |
| 16 | |
| 17 | Setting up Effective Mirrors |
| 18 | ============================ |
| 19 | |
| 20 | A good deal that goes into a Yocto Project build is simply downloading |
| 21 | all of the source tarballs. Maybe you have been working with another |
| 22 | build system for which you have built up a |
| 23 | sizable directory of source tarballs. Or, perhaps someone else has such |
| 24 | a directory for which you have read access. If so, you can save time by |
| 25 | adding statements to your configuration file so that the build process |
| 26 | checks local directories first for existing tarballs before checking the |
| 27 | Internet. |
| 28 | |
| 29 | Here is an efficient way to set it up in your ``local.conf`` file:: |
| 30 | |
| 31 | SOURCE_MIRROR_URL ?= "file:///home/you/your-download-dir/" |
| 32 | INHERIT += "own-mirrors" |
| 33 | BB_GENERATE_MIRROR_TARBALLS = "1" |
| 34 | # BB_NO_NETWORK = "1" |
| 35 | |
| 36 | In the previous example, the |
| 37 | :term:`BB_GENERATE_MIRROR_TARBALLS` |
| 38 | variable causes the OpenEmbedded build system to generate tarballs of |
| 39 | the Git repositories and store them in the |
| 40 | :term:`DL_DIR` directory. Due to |
| 41 | performance reasons, generating and storing these tarballs is not the |
| 42 | build system's default behavior. |
| 43 | |
| 44 | You can also use the |
| 45 | :term:`PREMIRRORS` variable. For |
| 46 | an example, see the variable's glossary entry in the Yocto Project |
| 47 | Reference Manual. |
| 48 | |
| 49 | Getting Source Files and Suppressing the Build |
| 50 | ============================================== |
| 51 | |
| 52 | Another technique you can use to ready yourself for a successive string |
| 53 | of build operations, is to pre-fetch all the source files without |
| 54 | actually starting a build. This technique lets you work through any |
| 55 | download issues and ultimately gathers all the source files into your |
| 56 | download directory :ref:`structure-build-downloads`, |
| 57 | which is located with :term:`DL_DIR`. |
| 58 | |
| 59 | Use the following BitBake command form to fetch all the necessary |
| 60 | sources without starting the build:: |
| 61 | |
| 62 | $ bitbake target --runall=fetch |
| 63 | |
| 64 | This |
| 65 | variation of the BitBake command guarantees that you have all the |
| 66 | sources for that BitBake target should you disconnect from the Internet |
| 67 | and want to do the build later offline. |
| 68 | |