Pular para conteúdo

Prática 04 - Práticas com bitbake


Note

Diretório de trabalho: ~/treinamento/yp/poky/build-qemu


Para criar a sua camada, executar o comando bitbake-layers, abaixo o comando para listar as camadas atuais adicionadas no projeto:

Executar no HOST
bitbake-layers show-layers

Saída esperada:

NOTE: Starting bitbake server...
layer                 path                                                                    priority
========================================================================================================
core                  /home/b2open/treinamento/yp/poky/meta                                   5
yocto                 /home/b2open/treinamento/yp/poky/meta-poky                              5
yoctobsp              /home/b2open/treinamento/yp/poky/meta-yocto-bsp                         5


Criando a camada meta-treinamento

Utilizando o comando bitbake-layers com o parametro create-layer criamos uma cada própria para customizações:

Executar no HOST
bitbake-layers create-layer ../meta-treinamento

Saída do comando:

NOTE: Starting bitbake server...
Add your new layer with 'bitbake-layers add-layer ../meta-treinamento'


Analisando a camada criada:

Executar no HOST
tree ../meta-treinamento/

Saída esperada:

../meta-treinamento/
├── conf
   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
    └── example
        └── example_0.1.bb

3 directories, 4 files
bitbake-layers create-layer ../meta-treinamento


Ao criar uma nova camada o próprio bitbake adiciona a instrução para incluir sua camada ao projeto atual de build, com o comando abaixo:

Executar no HOST
bitbake-layers add-layer ../meta-treinamento

Saída esperada:

NOTE: Starting bitbake server...


Listando novamente as camadas adicionadas ao projeto:

Executar no HOST
bitbake-layers show-layers

Saída esperada:

NOTE: Starting bitbake server...
layer                 path                                                                    priority
========================================================================================================
core                  /home/b2open/treinamento/yp/poky/meta                                   5
yocto                 /home/b2open/treinamento/yp/poky/meta-poky                              5
yoctobsp              /home/b2open/treinamento/yp/poky/meta-yocto-bsp                         5
meta-treinamento      /home/b2open/treinamento/yp/poky/meta-treinamento                       6


Práticas com bitbake e receitas

Pesquisando por um receita e respectivamente a sua camada:

Executar no HOST
bitbake-layers show-recipes minicom

Saída espeada:

NOTE: Starting bitbake server...
Loading cache: 100% |####################################################################| Time: 0:00:00
Loaded 1878 entries from dependency cache.
=== Matching recipes: ===
minicom:
  meta                 2.9


Repita o exercicio acima para os programas htop, python3, java e sqlite3.


Listando tarefas de uma receita

Utilizando o parametro listtasks pode-se listar e visualizar todas as tarefas que a receita utilizada, as padrões e as customizadas:

Executar no HOST
bitbake -c listasks minicom

Olhe que interessante, o comando listasks não existe, o bitbake identificou e no erro mostrou qual seria o parametro correto:

ERROR: Task do_listasks does not exist for target minicom (/home/b2open/treinamento/yp/poky/meta/recipes-extended/minicom/minicom_2.9.bb:do_listasks). Close matches:                                                          | ETA:  0:00:00
  do_listtasks
ERROR: Command execution failed: 1

Executando novamente com o parametro correto:

Executar no HOST
bitbake -c listtasks minicom

Saída esperada:

NOTE: No setscene tasks
NOTE: Executing Tasks
do_build                              Default task for a recipe - depends on all other normal tasks required to 'build' a recipe
do_build_without_rm_work              
do_checkuri                           Validates the SRC_URI value
do_clean                              Removes all output files for a target
do_cleanall                           Removes all output files, shared state cache, and downloaded source files for a target
do_cleansstate                        Removes all output files and shared state cache for a target
do_collect_spdx_deps                  
do_compile                            Compiles the source in the compilation directory
do_configure                          Configures the source by enabling and disabling any build-time and configuration options for the software being built
do_create_runtime_spdx                
do_create_runtime_spdx_setscene        (setscene version)
do_create_spdx                        
do_create_spdx_setscene                (setscene version)
do_deploy_source_date_epoch           
do_deploy_source_date_epoch_setscene   (setscene version)
do_devshell                           Starts a shell with the environment set up for development/debugging
do_fetch                              Fetches the source code
do_install                            Copies files from the compilation directory to a holding area
do_listtasks                          Lists all defined tasks for a target
do_package                            Analyzes the content of the holding area and splits it into subsets based on available packages and files
do_package_qa                         Runs QA checks on packaged files
do_package_qa_setscene                Runs QA checks on packaged files (setscene version)
do_package_setscene                   Analyzes the content of the holding area and splits it into subsets based on available packages and files (setscene version)
do_package_write_rpm                  Creates the actual RPM packages and places them in the Package Feed area
do_package_write_rpm_setscene         Creates the actual RPM packages and places them in the Package Feed area (setscene version)
do_packagedata                        Creates package metadata used by the build system to generate the final packages
do_packagedata_setscene               Creates package metadata used by the build system to generate the final packages (setscene version)
do_patch                              Locates patch files and applies them to the source code
do_populate_lic                       Writes license information for the recipe that is collected later when the image is constructed
do_populate_lic_setscene              Writes license information for the recipe that is collected later when the image is constructed (setscene version)
do_populate_sysroot                   Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes
do_populate_sysroot_setscene          Copies a subset of files installed by do_install into the sysroot in order to make them available to other recipes (setscene version)
do_prepare_recipe_sysroot             
do_pydevshell                         Starts an interactive Python shell for development/debugging
do_recipe_qa                          
do_recipe_qa_setscene                  (setscene version)
do_rm_work                            Removes work files after the build system has finished with them
do_rm_work_all                        Top-level task for removing work files after the build system has finished with them
do_unpack                             Unpacks the source code into a working directory


Processando e Construindo um software baseado em uma receita

Exemplo a receita do software minicom.

Executar no HOST
bitbake minicom


Visualizando o conteúdo do diretório de trabalho da receita minicom:

Executar no HOST
ls -l tmp/work/core2-64-poky-linux/minicom/2.9/

Saída esperada:

total 104
drwxr-xr-x  8 b2open b2open  4096 May 25 15:55 build
-rw-r--r--  1 b2open b2open    65 May 25 15:55 configure.sstate
-rw-r--r--  1 b2open b2open  3834 May 25 15:55 debugsources.list
drwxr-xr-x  3 b2open b2open  4096 May 25 15:55 deploy-rpms
drwxr-xr-x  2 b2open b2open  4096 May 25 15:55 deploy-source-date-epoch
drwxr-xr-x  3 b2open b2open  4096 May 25 15:55 image
drwxr-xr-x  3 b2open b2open  4096 May 25 15:55 license-destdir
drwxr-xr-x 10 b2open b2open  4096 May 25 15:55 minicom-2.9
-rw-r--r--  1 b2open b2open  6889 May 25 15:55 minicom.spec
drwxr-xr-x  3 b2open b2open  4096 May 25 15:55 package
drwxr-xr-x  9 b2open b2open  4096 May 25 15:55 packages-split
drwxr-xr-x  7 b2open b2open  4096 May 25 15:55 pkgdata
drwxr-xr-x  7 b2open b2open  4096 May 25 15:55 pkgdata-pdata-input
drwxr-xr-x  7 b2open b2open  4096 May 25 15:55 pkgdata-sysroot
drwxr-xr-x  2 b2open b2open  4096 May 25 15:55 pseudo
drwxr-xr-x  5 b2open b2open  4096 May 25 15:55 recipe-sysroot
drwxr-xr-x  9 b2open b2open  4096 May 25 15:55 recipe-sysroot-native
drwxr-xr-x  2 b2open b2open  4096 May 25 15:55 source-date-epoch
drwxr-xr-x  5 b2open b2open  4096 May 25 15:55 spdx
drwxr-xr-x  4 b2open b2open  4096 May 25 15:55 sysroot-destdir
drwxr-xr-x  2 b2open b2open 20480 May 25 15:55 temp


Limpando o SSTATE do pacote minicom:

Executar no HOST
bitbake -c cleansstate minicom

Visualizando o diretório após -c cleansstate:

Executar no HOST
ls -l tmp/work/core2-64-poky-linux/minicom/2.9/

Saída esperada:

total 4
drwxr-xr-x 2 b2open b2open 4096 Jun 25 15:58 temp

Executando o comando bitbake mas especificando para executar até o comando compile:

Executar no HOST
bitbake -c compile minicom


Visualizando os arquivos de log das tarefas do_configure e do_compile:

Executar no HOST
cat tmp/work/core2-64-poky-linux/minicom/2.9/temp/log.do_configure
Executar no HOST
cat tmp/work/core2-64-poky-linux/minicom/2.9/temp/log.do_compile


Exibindo as variáveis ambiente do setup:

Executar no HOST
bitbake -e


Exibindo as variáveis ambiente da receita:

Executar no HOST
bitbake -e minicom | grep ^PACKAGES

Saída esperada:

PACKAGES="minicom-src minicom-dbg minicom-staticdev minicom-dev minicom-doc minicom-locale  minicom"
PACKAGESPLITFUNCS="                 package_do_split_locales                 populate_packages"
PACKAGES_DYNAMIC="^minicom-locale-.*"