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