toaster-manual-setup-and-use.rst 22 KB

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