hashequivserver.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. Setting up a Hash Equivalence Server
  3. ************************************
  4. A :ref:`overview-manual/concepts:Hash Equivalence` server can help reduce build
  5. times by using the mechanism described in the :ref:`overview-manual/concepts:Hash Equivalence`
  6. section of the Yocto Project Overview and Concepts Manual.
  7. This document will guide you through the steps required to set up the reference
  8. Hash Equivalence server provided by the :oe_git:`bitbake-hashserv
  9. </bitbake/tree/bin/bitbake-hashserv>` script in :term:`BitBake`.
  10. This guide will explain how to setup a local Hash Equivalence server and does
  11. not explain how to setup the surrounding infrastructure to secure this server.
  12. Hash Equivalence Server Setup
  13. =============================
  14. From this point onwards, the commands displayed below are assumed to be run from
  15. the :term:`BitBake` repository, which can be found :oe_git:`here </bitbake>`.
  16. To start a basic Hash Equivalence server, one could simply run::
  17. ./bin/bitbake-hashserv
  18. This will take all of the default options of the script, which are already
  19. sufficient to start a local server.
  20. Run ``./bin/bitbake-hashserv --help`` to see what options the script can take.
  21. Some of the important ones are:
  22. - ``--database`` controls the location of the hash server database (default:
  23. ``./hashserver.db``).
  24. - ``--bind`` controls the bind address of the server (default:
  25. ``unix://./hashserver.sock``).
  26. You can specify three types of addresses:
  27. - ``unix://PATH``: will bind to a Unix socket at ``PATH``.
  28. - ``wss://ADDRESS:PORT``: will bind to a Websocket at ``ADDRESS:PORT``.
  29. - ``ADDRESS:PORT``: will bind to a raw TCP socket at ``ADDRESS:PORT``.
  30. - ``--log`` can be used to control the logging level of the server (e.g.
  31. ``INFO`` will print information about clients connection to the server).
  32. - ``--upstream`` can be used to specify an upstream server to pull hashes from.
  33. This has no default value, meaning no upstream server is used.
  34. - ``--db-username`` and ``--db-password`` can be used to control the access to
  35. the database.
  36. - ``--read-only`` will disable hash reports from clients.
  37. These variables can also be set from the environment from where it is being run.
  38. Run ``./bin/bitbake-hashserv --help`` to get the variable names that you can
  39. export.
  40. .. warning::
  41. The shared Hash Equivalence server needs to be maintained together with the
  42. :ref:`Shared State <overview-manual/concepts:Shared State>` cache. Otherwise,
  43. the server could report Shared State hashes that only exist on specific
  44. clients.
  45. We therefore recommend that one Hash Equivalence server be set up to
  46. correspond with a given Shared State cache, and to start this server
  47. in *read-only mode* (``--read-only`` option), so that it doesn't store
  48. equivalences for Shared State caches that are local to clients.
  49. If there is no pre-existing Shared State Cache, the server should allow
  50. hashes to be reported (no ``--read-only`` option) to create the initial
  51. Hash Equivalence database.
  52. Yocto Project Build Setup
  53. =========================
  54. To use the server started in the previous section, set the following variables
  55. in a :term:`configuration file`::
  56. BB_HASHSERVE = "<bind address>"
  57. BB_SIGNATURE_HANDLER = "OEEquivHash"
  58. The ``<bind address>`` value should be replaced to point to the server started
  59. in the previous section.
  60. See the documentation of :term:`BB_SIGNATURE_HANDLER` for more details on this
  61. variable.
  62. You can optionally specify an upstream server with :term:`BB_HASHSERVE_UPSTREAM`
  63. variable. For example::
  64. BB_HASHSERVE_UPSTREAM = "wss://hashserv.yoctoproject.org/ws"
  65. This will make the local server pull hashes from the upstream server. The
  66. :term:`BB_HASHSERVE_UPSTREAM` only works when a server is running
  67. (:term:`BB_HASHSERVE` is set).
  68. To output debugging information on what is happening with Hash Equivalence when
  69. builds are started, you can configure :term:`BitBake` logging as follows from a
  70. :term:`configuration file`::
  71. BB_LOGCONFIG = "hashequiv.json"
  72. With ``hashequiv.json`` containing the following content:
  73. .. code-block:: json
  74. {
  75. "version": 1,
  76. "loggers": {
  77. "BitBake.SigGen.HashEquiv": {
  78. "level": "VERBOSE",
  79. "handlers": ["BitBake.verbconsole"]
  80. },
  81. "BitBake.RunQueue.HashEquiv": {
  82. "level": "VERBOSE",
  83. "handlers": ["BitBake.verbconsole"]
  84. }
  85. }
  86. }
  87. This will make Hash Equivalence related changes be printed on the console, such
  88. as::
  89. NOTE: Task <recipe.bb>:do_<task> unihash changed to dc0da29c62a2d78d8d853fbb9c173778fe7d6fa4a68c67494b17afffe8ca1894