setup-and-use.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. .. Set default pygment highlighting to 'shell' for this document
  3. .. highlight:: shell
  4. ****************************
  5. Setting Up and Using Toaster
  6. ****************************
  7. Starting Toaster for Local Development
  8. ======================================
  9. Once you have set up the Yocto Project and installed the Toaster system
  10. dependencies as described in the ":ref:`toaster-manual/start:Preparing to Use
  11. Toaster`" chapter, you are ready to start
  12. Toaster.
  13. Navigate to the root of your
  14. :term:`Source Directory` (e.g. ``poky``)::
  15. $ cd poky
  16. Once in that directory, source the build environment script::
  17. $ source oe-init-build-env
  18. Next, from the :term:`Build Directory` (e.g. ``poky/build``), start Toaster
  19. using this command::
  20. $ source toaster start
  21. You can now run your builds from the command line, or with Toaster
  22. as explained in section
  23. ":ref:`toaster-manual/setup-and-use:using the toaster web interface`".
  24. To access the Toaster web interface, open your favorite browser and
  25. enter the following::
  26. http://127.0.0.1:8000
  27. Setting a Different Port
  28. ========================
  29. By default, Toaster starts on port 8000. You can use the ``WEBPORT``
  30. parameter to set a different port. For example, the following command
  31. sets the port to "8400"::
  32. $ source toaster start webport=8400
  33. Setting Up Toaster Without a Web Server
  34. =======================================
  35. You can start a Toaster environment without starting its web server.
  36. This is useful for the following:
  37. - Capturing a command-line build's statistics into the Toaster database
  38. for examination later.
  39. - Capturing a command-line build's statistics when the Toaster server
  40. is already running.
  41. - Having one instance of the Toaster web server track and capture
  42. multiple command-line builds, where each build is started in its own
  43. "noweb" Toaster environment.
  44. The following commands show how to start a Toaster environment without
  45. starting its web server, perform BitBake operations, and then shut down
  46. the Toaster environment. Once the build is complete, you can close the
  47. Toaster environment. Before closing the environment, however, you should
  48. allow a few minutes to ensure the complete transfer of its BitBake build
  49. statistics to the Toaster database. If you have a separate Toaster web
  50. server instance running, you can watch this command-line build's
  51. progress and examine the results as soon as they are posted::
  52. $ source toaster start noweb
  53. $ bitbake target
  54. $ source toaster stop
  55. Setting Up Toaster Without a Build Server
  56. =========================================
  57. You can start a Toaster environment with the "New Projects" feature
  58. disabled. Doing so is useful for the following:
  59. - Sharing your build results over the web server while blocking others
  60. from starting builds on your host.
  61. - Allowing only local command-line builds to be captured into the
  62. Toaster database.
  63. Use the following command to set up Toaster without a build server::
  64. $ source toaster start nobuild webport=port
  65. Setting up External Access
  66. ==========================
  67. By default, Toaster binds to the loop back address (i.e. ``localhost``),
  68. which does not allow access from external hosts. To allow external
  69. access, use the ``WEBPORT`` parameter to open an address that connects
  70. to the network, specifically the IP address that your NIC uses to
  71. connect to the network. You can also bind to all IP addresses the
  72. computer supports by using the shortcut "0.0.0.0:port".
  73. The following example binds to all IP addresses on the host::
  74. $ source toaster start webport=0.0.0.0:8400
  75. This example binds to a specific IP address on the host's NIC::
  76. $ source toaster start webport=192.168.1.1:8400
  77. The Directory for Cloning Layers
  78. ================================
  79. Toaster creates a ``_toaster_clones`` directory inside your Source
  80. Directory (i.e. ``poky``) to clone any layers needed for your builds.
  81. Alternatively, if you would like all of your Toaster related files and
  82. directories to be in a particular location other than the default, you
  83. can set the ``TOASTER_DIR`` environment variable, which takes precedence
  84. over your current working directory. Setting this environment variable
  85. causes Toaster to create and use ``$TOASTER_DIR./_toaster_clones``.
  86. The Build Directory
  87. ===================
  88. Toaster creates a :term:`Build Directory` within your Source Directory (e.g.
  89. ``poky``) to execute the builds.
  90. Alternatively, if you would like all of your Toaster related files and
  91. directories to be in a particular location, you can set the
  92. ``TOASTER_DIR`` environment variable, which takes precedence over your
  93. current working directory. Setting this environment variable causes
  94. Toaster to use ``$TOASTER_DIR/build`` as the :term:`Build Directory`.
  95. Creating a Django Superuser
  96. ===========================
  97. Toaster is built on the `Django
  98. framework <https://www.djangoproject.com/>`__. Django provides an
  99. administration interface you can use to edit Toaster configuration
  100. parameters.
  101. To access the Django administration interface, you must create a
  102. superuser by following these steps:
  103. #. If you used ``pip3``, which is recommended, to set up the Toaster
  104. system dependencies, you need be sure the local user path is in your
  105. ``PATH`` list. To append the pip3 local user path, use the following
  106. command::
  107. $ export PATH=$PATH:$HOME/.local/bin
  108. #. From the directory containing the Toaster database, which by default
  109. is the :term:`Build Directory`, invoke the ``createsuperuser`` command from
  110. ``manage.py``::
  111. $ cd poky/build
  112. $ ../bitbake/lib/toaster/manage.py createsuperuser
  113. #. Django prompts you for the username, which you need to provide.
  114. #. Django prompts you for an email address, which is optional.
  115. #. Django prompts you for a password, which you must provide.
  116. #. Django prompts you to re-enter your password for verification.
  117. After completing these steps, the following confirmation message
  118. appears::
  119. Superuser created successfully.
  120. Creating a superuser allows you to access the Django administration
  121. interface through a browser. The URL for this interface is the same as
  122. the URL used for the Toaster instance with "/admin" on the end. For
  123. example, if you are running Toaster locally, use the following URL::
  124. http://127.0.0.1:8000/admin
  125. You can use the Django administration interface to set Toaster configuration
  126. parameters such as the :term:`Build Directory`, layer sources, default variable
  127. values, and BitBake versions.
  128. Setting Up a Production Instance of Toaster
  129. ===========================================
  130. You can use a production instance of Toaster to share the Toaster
  131. instance with remote users, multiple users, or both. The production
  132. instance is also the setup that can handle heavier loads on the web
  133. service. Use the instructions in the following sections to set up
  134. Toaster to run builds through the Toaster web interface.
  135. Requirements
  136. ------------
  137. Be sure you meet the following requirements:
  138. .. note::
  139. You must comply with all Apache, ``mod-wsgi``, and Mysql requirements.
  140. - Have all the build requirements as described in the ":ref:`toaster-manual/start:Preparing to
  141. Use Toaster`" chapter.
  142. - Have an Apache webserver.
  143. - Have ``mod-wsgi`` for the Apache webserver.
  144. - Use the Mysql database server.
  145. - If you are using Ubuntu, run the following::
  146. $ sudo apt install apache2 libapache2-mod-wsgi-py3 mysql-server python3-pip libmysqlclient-dev
  147. - If you are using Fedora or a RedHat distribution, run the
  148. following::
  149. $ sudo dnf install httpd python3-mod_wsgi python3-pip mariadb-server mariadb-devel python3-devel
  150. - If you are using openSUSE, run the following::
  151. $ sudo zypper install apache2 apache2-mod_wsgi-python3 python3-pip mariadb mariadb-client python3-devel
  152. Installation
  153. ------------
  154. Perform the following steps to install Toaster:
  155. #. Create toaster user and set its home directory to
  156. ``/var/www/toaster``::
  157. $ sudo /usr/sbin/useradd toaster -md /var/www/toaster -s /bin/false
  158. $ sudo su - toaster -s /bin/bash
  159. #. Checkout a copy of ``poky`` into the web server directory. You will
  160. be using ``/var/www/toaster``::
  161. $ git clone git://git.yoctoproject.org/poky
  162. $ git checkout &DISTRO_NAME_NO_CAP;
  163. #. Install Toaster dependencies using the ``--user`` flag which keeps the
  164. Python packages isolated from your system-provided packages::
  165. $ cd /var/www/toaster/
  166. $ pip3 install --user -r ./poky/bitbake/toaster-requirements.txt
  167. $ pip3 install --user mysqlclient
  168. .. note::
  169. Isolating these packages is not required but is recommended.
  170. Alternatively, you can use your operating system's package
  171. manager to install the packages.
  172. #. Configure Toaster by editing
  173. ``/var/www/toaster/poky/bitbake/lib/toaster/toastermain/settings.py``
  174. as follows:
  175. - Edit the
  176. `DATABASES <https://docs.djangoproject.com/en/2.2/ref/settings/#databases>`__
  177. settings:
  178. .. code-block:: python
  179. DATABASES = {
  180. 'default': {
  181. 'ENGINE': 'django.db.backends.mysql',
  182. 'NAME': 'toaster_data',
  183. 'USER': 'toaster',
  184. 'PASSWORD': 'yourpasswordhere',
  185. 'HOST': 'localhost',
  186. 'PORT': '3306',
  187. }
  188. }
  189. - Edit the
  190. `SECRET_KEY <https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-SECRET_KEY>`__:
  191. .. code-block:: python
  192. SECRET_KEY = 'your_secret_key'
  193. - Edit the
  194. `STATIC_ROOT <https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-STATIC_ROOT>`__:
  195. .. code-block:: python
  196. STATIC_ROOT = '/var/www/toaster/static_files/'
  197. #. Add the database and user to the ``mysql`` server defined earlier::
  198. $ mysql -u root -p
  199. mysql> CREATE DATABASE toaster_data;
  200. mysql> CREATE USER 'toaster'@'localhost' identified by 'yourpasswordhere';
  201. mysql> GRANT all on toaster_data.\* to 'toaster'@'localhost';
  202. mysql> quit
  203. #. Get Toaster to create the database schema, default data, and gather
  204. the statically-served files::
  205. $ cd /var/www/toaster/poky/
  206. $ ./bitbake/lib/toaster/manage.py migrate
  207. $ TOASTER_DIR=`pwd\` TEMPLATECONF='poky' \
  208. ./bitbake/lib/toaster/manage.py checksettings
  209. $ ./bitbake/lib/toaster/manage.py collectstatic
  210. In the previous
  211. example, from the ``poky`` directory, the ``migrate`` command
  212. ensures the database schema changes have propagated correctly (i.e.
  213. migrations). The next line sets the Toaster root directory
  214. ``TOASTER_DIR`` and the location of the Toaster configuration file
  215. ``TOASTER_CONF``, which is relative to ``TOASTER_DIR``. The
  216. :term:`TEMPLATECONF` value reflects the contents of
  217. ``poky/.templateconf``, and by default, should include the string
  218. "poky". For more information on the Toaster configuration file, see
  219. the ":ref:`toaster-manual/reference:Configuring Toaster`" section.
  220. This line also runs the ``checksettings`` command, which configures
  221. the location of the Toaster :term:`Build Directory`. The Toaster
  222. root directory ``TOASTER_DIR`` determines where the Toaster build
  223. directory is created on the file system. In the example above,
  224. ``TOASTER_DIR`` is set as follows::
  225. /var/www/toaster/poky
  226. This setting causes the Toaster :term:`Build Directory` to be::
  227. /var/www/toaster/poky/build
  228. Finally, the ``collectstatic`` command is a Django framework command
  229. that collects all the statically served files into a designated
  230. directory to be served up by the Apache web server as defined by
  231. ``STATIC_ROOT``.
  232. #. Test and/or use the Mysql integration with Toaster's Django web
  233. server. At this point, you can start up the normal Toaster Django
  234. web server with the Toaster database in Mysql. You can use this web
  235. server to confirm that the database migration and data population
  236. from the Layer Index is complete.
  237. To start the default Toaster Django web server with the Toaster
  238. database now in Mysql, use the standard start commands::
  239. $ source oe-init-build-env
  240. $ source toaster start
  241. Additionally, if Django is sufficient for your requirements, you can use
  242. it for your release system and migrate later to Apache as your
  243. requirements change.
  244. #. Add an Apache configuration file for Toaster to your Apache web
  245. server's configuration directory. If you are using Ubuntu or Debian,
  246. put the file here::
  247. /etc/apache2/conf-available/toaster.conf
  248. If you are using Fedora or RedHat, put it here::
  249. /etc/httpd/conf.d/toaster.conf
  250. If you are using openSUSE, put it here::
  251. /etc/apache2/conf.d/toaster.conf
  252. Here is a sample Apache configuration for Toaster you can follow:
  253. .. code-block:: apache
  254. Alias /static /var/www/toaster/static_files
  255. <Directory /var/www/toaster/static_files>
  256. <IfModule mod_access_compat.c>
  257. Order allow,deny
  258. Allow from all
  259. </IfModule>
  260. <IfModule !mod_access_compat.c>
  261. Require all granted
  262. </IfModule>
  263. </Directory>
  264. <Directory /var/www/toaster/poky/bitbake/lib/toaster/toastermain>
  265. <Files "wsgi.py">
  266. Require all granted
  267. </Files>
  268. </Directory>
  269. WSGIDaemonProcess toaster_wsgi python-path=/var/www/toaster/poky/bitbake/lib/toaster:/var/www/toaster/.local/lib/python3.4/site-packages
  270. WSGIScriptAlias / "/var/www/toaster/poky/bitbake/lib/toaster/toastermain/wsgi.py"
  271. <Location />
  272. WSGIProcessGroup toaster_wsgi
  273. </Location>
  274. If you are using Ubuntu or Debian, you will need to enable the config and
  275. module for Apache::
  276. $ sudo a2enmod wsgi
  277. $ sudo a2enconf toaster
  278. $ chmod +x bitbake/lib/toaster/toastermain/wsgi.py
  279. Finally, restart Apache to make sure all new configuration is loaded. For Ubuntu,
  280. Debian, and openSUSE use::
  281. $ sudo service apache2 restart
  282. For Fedora and RedHat use::
  283. $ sudo service httpd restart
  284. #. Prepare the systemd service to run Toaster builds. Here is a sample
  285. configuration file for the service:
  286. .. code-block:: ini
  287. [Unit]
  288. Description=Toaster runbuilds
  289. [Service]
  290. Type=forking User=toaster
  291. ExecStart=/usr/bin/screen -d -m -S runbuilds /var/www/toaster/poky/bitbake/lib/toaster/runbuilds-service.sh start
  292. ExecStop=/usr/bin/screen -S runbuilds -X quit
  293. WorkingDirectory=/var/www/toaster/poky
  294. [Install]
  295. WantedBy=multi-user.target
  296. Prepare the ``runbuilds-service.sh`` script that you need to place in the
  297. ``/var/www/toaster/poky/bitbake/lib/toaster/`` directory by setting
  298. up executable permissions::
  299. #!/bin/bash
  300. #export http_proxy=http://proxy.host.com:8080
  301. #export https_proxy=http://proxy.host.com:8080
  302. #export GIT_PROXY_COMMAND=$HOME/bin/gitproxy
  303. cd poky/
  304. source ./oe-init-build-env build
  305. source ../bitbake/bin/toaster $1 noweb
  306. [ "$1" == 'start' ] && /bin/bash
  307. #. Run the service::
  308. $ sudo service runbuilds start
  309. Since the service is running in a detached screen session, you can
  310. attach to it using this command::
  311. $ sudo su - toaster
  312. $ screen -rS runbuilds
  313. You can detach from the service again using "Ctrl-a" followed by "d" key
  314. combination.
  315. You can now open up a browser and start using Toaster.
  316. Using the Toaster Web Interface
  317. ===============================
  318. The Toaster web interface allows you to do the following:
  319. - Browse published layers in the :oe_layerindex:`OpenEmbedded Layer Index <>`
  320. that are available for your selected version of the build system.
  321. - Import your own layers for building.
  322. - Add and remove layers from your configuration.
  323. - Set configuration variables.
  324. - Select a target or multiple targets to build.
  325. - Start your builds.
  326. - See what was built (recipes and packages) and what packages were
  327. installed into your final image.
  328. - Browse the directory structure of your image.
  329. - See the value of all variables in your build configuration, and which
  330. files set each value.
  331. - Examine error, warning and trace messages to aid in debugging.
  332. - See information about the BitBake tasks executed and reused during
  333. your build, including those that used shared state.
  334. - See dependency relationships between recipes, packages and tasks.
  335. - See performance information such as build time, task time, CPU usage,
  336. and disk I/O.
  337. Toaster Web Interface Videos
  338. ----------------------------
  339. Here are several videos that show how to use the Toaster GUI:
  340. - *Build Configuration:* This
  341. `video <https://www.youtube.com/watch?v=qYgDZ8YzV6w>`__ overviews and
  342. demonstrates build configuration for Toaster.
  343. - *Build Custom Layers:* This
  344. `video <https://www.youtube.com/watch?v=QJzaE_XjX5c>`__ shows you how
  345. to build custom layers that are used with Toaster.
  346. - *Toaster Homepage and Table Controls:* This
  347. `video <https://www.youtube.com/watch?v=QEARDnrR1Xw>`__ goes over the
  348. Toaster entry page, and provides an overview of the data manipulation
  349. capabilities of Toaster, which include search, sorting and filtering
  350. by different criteria.
  351. - *Build Dashboard:* This
  352. `video <https://www.youtube.com/watch?v=KKqHYcnp2gE>`__ shows you the
  353. build dashboard, a page providing an overview of the information
  354. available for a selected build.
  355. - *Image Information:* This
  356. `video <https://www.youtube.com/watch?v=XqYGFsmA0Rw>`__ walks through
  357. the information Toaster provides about images: packages installed and
  358. root file system.
  359. - *Configuration:* This
  360. `video <https://www.youtube.com/watch?v=UW-j-T2TzIg>`__ provides
  361. Toaster build configuration information.
  362. - *Tasks:* This `video <https://www.youtube.com/watch?v=D4-9vGSxQtw>`__
  363. shows the information Toaster provides about the tasks run by the
  364. build system.
  365. - *Recipes and Packages Built:* This
  366. `video <https://www.youtube.com/watch?v=x-6dx4huNnw>`__ shows the
  367. information Toaster provides about recipes and packages built.
  368. - *Performance Data:* This
  369. `video <https://www.youtube.com/watch?v=qWGMrJoqusQ>`__ shows the
  370. build performance data provided by Toaster.
  371. Additional Information About the Local Yocto Project Release
  372. ------------------------------------------------------------
  373. This section only applies if you have set up Toaster for local
  374. development, as explained in the
  375. ":ref:`toaster-manual/setup-and-use:starting toaster for local development`"
  376. section.
  377. When you create a project in Toaster, you will be asked to provide a
  378. name and to select a Yocto Project release. One of the release options
  379. you will find is called "Local Yocto Project".
  380. .. image:: figures/new-project.png
  381. :align: center
  382. :scale: 75%
  383. When you select the "Local Yocto Project" release, Toaster will run your
  384. builds using the local Yocto Project clone you have in your computer:
  385. the same clone you are using to run Toaster. Unless you manually update
  386. this clone, your builds will always use the same Git revision.
  387. If you select any of the other release options, Toaster will fetch the
  388. tip of your selected release from the upstream :yocto_git:`Yocto Project
  389. repository <>` every time you run a build.
  390. Fetching this tip effectively means that if your selected release is
  391. updated upstream, the Git revision you are using for your builds will
  392. change. If you are doing development locally, you might not want this
  393. change to happen. In that case, the "Local Yocto Project" release might
  394. be the right choice.
  395. However, the "Local Yocto Project" release will not provide you with any
  396. compatible layers, other than the three core layers that come with the
  397. Yocto Project:
  398. - :oe_layer:`openembedded-core </openembedded-core>`
  399. - :oe_layer:`meta-poky </meta-poky>`
  400. - :oe_layer:`meta-yocto-bsp </meta-yocto-bsp>`
  401. .. image:: figures/compatible-layers.png
  402. :align: center
  403. :scale: 75%
  404. If you want to build any other layers, you will need to manually import
  405. them into your Toaster project, using the "Import layer" page.
  406. .. image:: figures/import-layer.png
  407. :align: center
  408. :scale: 75%
  409. Building a Specific Recipe Given Multiple Versions
  410. --------------------------------------------------
  411. Occasionally, a layer might provide more than one version of the same
  412. recipe. For example, the ``openembedded-core`` layer provides two
  413. versions of the ``bash`` recipe (i.e. 3.2.48 and 4.3.30-r0) and two
  414. versions of the ``which`` recipe (i.e. 2.21 and 2.18). The following
  415. figure shows this exact scenario:
  416. .. image:: figures/bash-oecore.png
  417. :align: center
  418. :scale: 75%
  419. By default, the OpenEmbedded build system builds one of the two recipes.
  420. For the ``bash`` case, version 4.3.30-r0 is built by default.
  421. Unfortunately, Toaster as it exists, is not able to override the default
  422. recipe version. If you would like to build bash 3.2.48, you need to set
  423. the
  424. :term:`PREFERRED_VERSION`
  425. variable. You can do so from Toaster, using the "Add variable" form,
  426. which is available in the "BitBake variables" page of the project
  427. configuration section as shown in the following screen:
  428. .. image:: figures/add-variable.png
  429. :align: center
  430. :scale: 75%
  431. To specify ``bash`` 3.2.48 as the version to build, enter
  432. "PREFERRED_VERSION_bash" in the "Variable" field, and "3.2.48" in the
  433. "Value" field. Next, click the "Add variable" button:
  434. .. image:: figures/set-variable.png
  435. :align: center
  436. :scale: 75%
  437. After clicking the "Add variable" button, the settings for
  438. :term:`PREFERRED_VERSION` are added to the bottom of the BitBake variables
  439. list. With these settings, the OpenEmbedded build system builds the
  440. desired version of the recipe rather than the default version:
  441. .. image:: figures/variable-added.png
  442. :align: center
  443. :scale: 75%