TRS recipes
TRS levarage various layers and recipes to build firmware, root filesystem and various images. These can be found after doing a build according to the build instructions in this TRS documentation.
Helper scripts
Recipe finder
The script below comes from scripts/list_recipies.py
in the TRS
documentation. This script will find the packages that are being compiled and
the belong bb-file for it. To run this script you first need to generate the a
file called task-depends.dot
. You generate that by doing:
$ bitbake -e <image-name>
For Trusted Substrate with QEMU for example this can be achieved by running
$ kas shell ci/qemuarm64-secureboot.yml
$ bitbake -e ts-firmware
Once that has completed you should be able to find .../build/task-depends.dot
.
With that available, go the folder where list_recipies.py
is located and run
the script:
$ ./list_recipies.py -f <full-path-to>/task-depends.dot
If you’re searching for a certain package, you can use the -p
parameter.
$ ./list_recipies.py -f <full-path-to>/task-depends.dot -p op-tee
If you also want to see the content of the specified package you can use the
-d
parameter.
$ ./list_recipies.py -f <full-path-to>/task-depends.dot -p op-tee -d
1#!/usr/bin/env python
2
3from argparse import ArgumentParser
4import os
5
6
7def get_parser():
8 """ Takes care of script argument parsing. """
9 parser = ArgumentParser(description='Script used to find the location of '
10 'recipes in Yocto builds')
11
12 parser.add_argument('-d', '--dump', required=False, action="store_true",
13 help='Dump contents of the found recipe(s)')
14
15 parser.add_argument('-p', '--package', required=False, action="store",
16 help='Query for a single package')
17
18 parser.add_argument('-f', '--file', required=False, action="store",
19 default="task-depends.dot",
20 help='File generated by bitbake -g <image-name>')
21
22 return parser
23
24
25def dump_recipe_content(recipe):
26 with open(recipe, encoding='utf-8') as f:
27 data = f.readlines()
28 print("-" * 80)
29 for line in data:
30 line.strip()
31 print(" {}".format(line))
32 print("-" * 80)
33
34
35def parse_dependencies(filename, search=None, dump=None):
36 tasks = None
37 with open(filename, encoding='utf-8') as f:
38 tasks = f.readlines()
39
40 print("{}{}".format("Package".ljust(40), "recipe"))
41 print("{}{}".format("=======".ljust(40), "======="))
42 for task in tasks:
43 task = task.strip()
44 if "do_compile" in task and "label" in task:
45 data = task.split()
46
47 package = data[0].replace('\"', '')
48 package = package.replace('.do_compile', '')
49
50 recipe = data[2].split(':')[-1]
51 recipe = recipe.split('\\n')[-1]
52 recipe = recipe.replace('"]', '')
53 tmp = recipe.split('/')
54 count = 0
55 for j in tmp:
56 if j == "..":
57 break
58 count += 1
59 del tmp[count-1:count+1]
60 recipe = '/'.join(tmp)
61 if search is None:
62 print("{}{}".format(package.ljust(40), recipe))
63 elif search in package:
64 print("{}{}".format(package.ljust(40), recipe))
65 if dump:
66 dump_recipe_content(recipe)
67
68
69def main():
70 args = get_parser().parse_args()
71 parse_dependencies(args.file, args.package, args.dump)
72
73
74if __name__ == '__main__':
75 main()