efficiently-fetching-sources.rst 2.6 KB

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