shrinkwrap-tool 2026.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. shrinkwrap_tool-2026.2.1/PKG-INFO +63 -0
  2. shrinkwrap_tool-2026.2.1/README.md +30 -0
  3. shrinkwrap_tool-2026.2.1/license.rst +41 -0
  4. shrinkwrap_tool-2026.2.1/pyproject.toml +65 -0
  5. shrinkwrap_tool-2026.2.1/setup.cfg +4 -0
  6. shrinkwrap_tool-2026.2.1/src/shrinkwrap/__init__.py +1 -0
  7. shrinkwrap_tool-2026.2.1/src/shrinkwrap/__main__.py +4 -0
  8. shrinkwrap_tool-2026.2.1/src/shrinkwrap/commands/__init__.py +0 -0
  9. shrinkwrap_tool-2026.2.1/src/shrinkwrap/commands/build.py +91 -0
  10. shrinkwrap_tool-2026.2.1/src/shrinkwrap/commands/buildall.py +180 -0
  11. shrinkwrap_tool-2026.2.1/src/shrinkwrap/commands/clean.py +161 -0
  12. shrinkwrap_tool-2026.2.1/src/shrinkwrap/commands/inspect.py +235 -0
  13. shrinkwrap_tool-2026.2.1/src/shrinkwrap/commands/process.py +106 -0
  14. shrinkwrap_tool-2026.2.1/src/shrinkwrap/commands/run.py +311 -0
  15. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/FVP_Base_RevC-2xAEMvA-base.yaml +98 -0
  16. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/FVP_Base_RevC-2xAEMvA-rme.yaml +42 -0
  17. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.0.yaml +22 -0
  18. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.1.yaml +26 -0
  19. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.2.yaml +28 -0
  20. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.3.yaml +25 -0
  21. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.4.yaml +26 -0
  22. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.5.yaml +29 -0
  23. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.6.yaml +28 -0
  24. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.7.yaml +24 -0
  25. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.8.yaml +31 -0
  26. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v8.9.yaml +32 -0
  27. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v9.0.yaml +29 -0
  28. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v9.1.yaml +25 -0
  29. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v9.2.yaml +29 -0
  30. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v9.3.yaml +23 -0
  31. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v9.4.yaml +21 -0
  32. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/arch/v9.5.yaml +20 -0
  33. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/bootwrapper.yaml +76 -0
  34. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/buildroot-cca.yaml +113 -0
  35. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/buildroot.yaml +54 -0
  36. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/cca-3world.yaml +215 -0
  37. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/cca-4world.yaml +57 -0
  38. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/cca-edk2.yaml +58 -0
  39. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/debug/rmm.yaml +15 -0
  40. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/debug/tfa.yaml +18 -0
  41. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/debug/tftf.yaml +17 -0
  42. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/dt-base.yaml +115 -0
  43. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/edk2-base.yaml +59 -0
  44. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/ffa-hafnium-optee.yaml +45 -0
  45. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/ffa-optee.yaml +30 -0
  46. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/ffa-tftf.yaml +26 -0
  47. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/hafnium-base.yaml +51 -0
  48. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/kvm-unit-tests.yaml +32 -0
  49. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/kvmtool-base.yaml +33 -0
  50. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/linux-base.yaml +80 -0
  51. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/ns-edk2-base.yaml +83 -0
  52. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/ns-edk2-optee.yaml +41 -0
  53. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/ns-edk2.yaml +49 -0
  54. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/ns-preload.yaml +98 -0
  55. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/optee-base.yaml +37 -0
  56. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/rfa-base.yaml +49 -0
  57. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/rfa.yaml +47 -0
  58. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/rmm-base.yaml +24 -0
  59. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/rust.yaml +31 -0
  60. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/test/cca.yaml +47 -0
  61. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/tfa-base.yaml +45 -0
  62. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/tfa-rme.yaml +36 -0
  63. shrinkwrap_tool-2026.2.1/src/shrinkwrap/config/tftf-base.yaml +32 -0
  64. shrinkwrap_tool-2026.2.1/src/shrinkwrap/shrinkwrap_main.py +133 -0
  65. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/__init__.py +0 -0
  66. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/clivars.py +16 -0
  67. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/config.py +1166 -0
  68. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/graph.py +263 -0
  69. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/label.py +153 -0
  70. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/logger.py +160 -0
  71. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/process.py +230 -0
  72. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/runtime.py +192 -0
  73. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/ssh_agent.py +98 -0
  74. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/tty.py +46 -0
  75. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/vars.py +14 -0
  76. shrinkwrap_tool-2026.2.1/src/shrinkwrap/utils/workspace.py +59 -0
  77. shrinkwrap_tool-2026.2.1/src/shrinkwrap_tool.egg-info/PKG-INFO +63 -0
  78. shrinkwrap_tool-2026.2.1/src/shrinkwrap_tool.egg-info/SOURCES.txt +81 -0
  79. shrinkwrap_tool-2026.2.1/src/shrinkwrap_tool.egg-info/dependency_links.txt +1 -0
  80. shrinkwrap_tool-2026.2.1/src/shrinkwrap_tool.egg-info/entry_points.txt +2 -0
  81. shrinkwrap_tool-2026.2.1/src/shrinkwrap_tool.egg-info/requires.txt +27 -0
  82. shrinkwrap_tool-2026.2.1/src/shrinkwrap_tool.egg-info/top_level.txt +1 -0
  83. shrinkwrap_tool-2026.2.1/test/test.py +525 -0
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: shrinkwrap-tool
3
+ Version: 2026.2.1
4
+ Summary: Shrinkwrap tool for building and running Arm FVPs
5
+ Author-email: Ryan Roberts <ryan.roberts@arm.com>, Saul Romero D <saul.romerodominguez@arm.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://git.gitlab.arm.com/tooling/shrinkwrap
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+ License-File: license.rst
13
+ Requires-Dist: PyYAML>=6.0.3
14
+ Requires-Dist: tuxmake>=1.34.0
15
+ Requires-Dist: termcolor<3.0,>=2.4.0; python_version < "3.10"
16
+ Requires-Dist: termcolor>=3.2.0; python_version >= "3.10"
17
+ Requires-Dist: graphlib-backport; python_version < "3.9"
18
+ Provides-Extra: dev
19
+ Requires-Dist: cffi>=2.0.0; extra == "dev"
20
+ Requires-Dist: cryptography>=46.0.3; extra == "dev"
21
+ Requires-Dist: cmake>=3.31.6; extra == "dev"
22
+ Requires-Dist: pycparser>=2.23; extra == "dev"
23
+ Requires-Dist: fdt>=0.3.3; extra == "dev"
24
+ Requires-Dist: pyelftools>=0.32; extra == "dev"
25
+ Requires-Dist: build; extra == "dev"
26
+ Requires-Dist: twine; extra == "dev"
27
+ Requires-Dist: pytest; extra == "dev"
28
+ Provides-Extra: docs
29
+ Requires-Dist: Sphinx<10,>=8.2; extra == "docs"
30
+ Requires-Dist: sphinx-rtd-theme<4,>=3.1.0; extra == "docs"
31
+ Requires-Dist: sphinx-copybutton>=0.5.2; extra == "docs"
32
+ Dynamic: license-file
33
+
34
+ # Shrinkwrap
35
+
36
+ Shrinkwrap is a tool to simplify the process of building and running firmware on
37
+ Arm Fixed Virtual Platforms (FVP). Users simply invoke the tool to build the
38
+ required config, then pass their own kernel and rootfs to the tool to boot the
39
+ full system on FVP.
40
+
41
+ - Documentation is available at: [ReadTheDocs](https://shrinkwrap.docs.arm.com)
42
+ - Source Code is available at: [GitLab](https://gitlab.arm.com/tooling/shrinkwrap)
43
+ - Shrinkwrap Container Images are available at: [DockerHub](https://hub.docker.com/u/shrinkwraptool)
44
+
45
+ The documentation (linked above) contains a
46
+ [QuickStart](https://shrinkwrap.docs.arm.com/en/latest/userguide/quickstart.html)
47
+ section, which details how to install and use the tool. However, if you are in a
48
+ hurry, here are the minimal steps:
49
+
50
+ > **NOTE:** This assumes you have Python >=3.9.0 and docker installed. If this
51
+ > is not the case, please refer to the documentation.
52
+
53
+ ```
54
+ sudo apt-get install git netcat-openbsd python3 python3-pip telnet
55
+ python3 -m venv .venv
56
+ source .venv/bin/activate
57
+ python -m pip install --upgrade pip
58
+ python -m pip install shrinkwrap
59
+ ```
60
+
61
+ ```
62
+ shrinkwrap --help
63
+ ```
@@ -0,0 +1,30 @@
1
+ # Shrinkwrap
2
+
3
+ Shrinkwrap is a tool to simplify the process of building and running firmware on
4
+ Arm Fixed Virtual Platforms (FVP). Users simply invoke the tool to build the
5
+ required config, then pass their own kernel and rootfs to the tool to boot the
6
+ full system on FVP.
7
+
8
+ - Documentation is available at: [ReadTheDocs](https://shrinkwrap.docs.arm.com)
9
+ - Source Code is available at: [GitLab](https://gitlab.arm.com/tooling/shrinkwrap)
10
+ - Shrinkwrap Container Images are available at: [DockerHub](https://hub.docker.com/u/shrinkwraptool)
11
+
12
+ The documentation (linked above) contains a
13
+ [QuickStart](https://shrinkwrap.docs.arm.com/en/latest/userguide/quickstart.html)
14
+ section, which details how to install and use the tool. However, if you are in a
15
+ hurry, here are the minimal steps:
16
+
17
+ > **NOTE:** This assumes you have Python >=3.9.0 and docker installed. If this
18
+ > is not the case, please refer to the documentation.
19
+
20
+ ```
21
+ sudo apt-get install git netcat-openbsd python3 python3-pip telnet
22
+ python3 -m venv .venv
23
+ source .venv/bin/activate
24
+ python -m pip install --upgrade pip
25
+ python -m pip install shrinkwrap
26
+ ```
27
+
28
+ ```
29
+ shrinkwrap --help
30
+ ```
@@ -0,0 +1,41 @@
1
+ #######
2
+ License
3
+ #######
4
+
5
+ The software is provided under the MIT license (below).
6
+
7
+ .. code-block:: none
8
+
9
+ Copyright (c) 2022 Arm Limited
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to
13
+ deal in the Software without restriction, including without limitation the
14
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15
+ sell copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice (including the next
19
+ paragraph) shall be included in all copies or substantial portions of the
20
+ Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28
+ IN THE SOFTWARE.
29
+
30
+ ****************
31
+ SPDX Identifiers
32
+ ****************
33
+
34
+ Individual files contain the following tag instead of the full license text.
35
+
36
+ .. code-block:: none
37
+
38
+ SPDX-License-Identifier: MIT
39
+
40
+ This enables machine processing of license information based on the SPDX
41
+ License Identifiers that are here available: http://spdx.org/licenses/
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "shrinkwrap-tool"
7
+ version = "2026.02.1"
8
+ authors = [
9
+ { name="Ryan Roberts", email="ryan.roberts@arm.com" },
10
+ { name="Saul Romero D", email="saul.romerodominguez@arm.com" }
11
+ ]
12
+
13
+ description = "Shrinkwrap tool for building and running Arm FVPs"
14
+ readme = "README.md"
15
+ requires-python = ">=3.8"
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Operating System :: OS Independent",
19
+ ]
20
+ license = "MIT"
21
+ license-files = ["license*"]
22
+
23
+ dependencies = [
24
+ "PyYAML>=6.0.3",
25
+ "tuxmake>=1.34.0",
26
+ # termcolor 3.x requires Python >= 3.10
27
+ "termcolor>=2.4.0,<3.0; python_version < '3.10'",
28
+ "termcolor>=3.2.0; python_version >= '3.10'",
29
+ "graphlib-backport; python_version < '3.9'",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "cffi>=2.0.0",
35
+ "cryptography>=46.0.3",
36
+ "cmake>=3.31.6",
37
+ "pycparser>=2.23",
38
+ "fdt>=0.3.3",
39
+ "pyelftools>=0.32",
40
+ "build",
41
+ "twine",
42
+ "pytest",
43
+ ]
44
+
45
+ docs = [
46
+ "Sphinx>=8.2,<10",
47
+ "sphinx-rtd-theme>=3.1.0,<4",
48
+ "sphinx-copybutton>=0.5.2",
49
+ ]
50
+
51
+ [project.urls]
52
+ Homepage = "https://git.gitlab.arm.com/tooling/shrinkwrap"
53
+
54
+ [project.scripts]
55
+ shrinkwrap = "shrinkwrap.shrinkwrap_main:main"
56
+
57
+ [tool.setuptools]
58
+ package-dir = {"" = "src"}
59
+ include-package-data = true
60
+
61
+ [tool.setuptools.package-data]
62
+ shrinkwrap = ["config/**/*.yaml"]
63
+
64
+ [tool.setuptools.packages.find]
65
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "2026.3.0.dev0"
@@ -0,0 +1,4 @@
1
+ from .shrinkwrap_entry import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,91 @@
1
+ # Copyright (c) 2022, Arm Limited.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import os
5
+ import shrinkwrap.commands.buildall as buildall
6
+ import shrinkwrap.utils.vars as vars
7
+
8
+
9
+ cmd_name = os.path.splitext(os.path.basename(__file__))[0]
10
+
11
+
12
+ def add_parser(parser, formatter):
13
+ """
14
+ Part of the command interface expected by shrinkwrap.py. Adds the
15
+ subcommand to the parser, along with all options and documentation.
16
+ Returns the subcommand name.
17
+ """
18
+ cmdp = parser.add_parser(cmd_name,
19
+ formatter_class=formatter,
20
+ help="""Builds a specified config and packages it ready
21
+ to run.""",
22
+ epilog="""Custom config store(s) can be defined at at
23
+ <SHRINKWRAP_CONFIG> as a colon-separated list of
24
+ directories. Building is done at <SHRINKWRAP_BUILD> and
25
+ output is saved to <SHRINKWRAP_PACKAGE>. The package
26
+ includes all FW binaries, a manifest and a build.sh script
27
+ containing all the commands that were executed per config.
28
+ Any pre-existing config package directory is first deleted.
29
+ Shrinkwrap will always search its default config store even
30
+ if <SHRINKWRAP_CONFIG> is not defined. <SHRINKWRAP_BUILD>
31
+ and <SHRINKWRAP_PACKAGE> default to '~/.shrinkwrap/build'
32
+ and '~/.shrinkwrap/package'. The user can override them by
33
+ setting the environment variables.""")
34
+
35
+ cmdp.add_argument('config',
36
+ metavar='config',
37
+ help="""Config to build. If the config exists relative to the
38
+ current directory that config is used. Else if the config
39
+ exists relative to the config store then it is used.""")
40
+
41
+ cmdp.add_argument('-b', '--btvar',
42
+ metavar='key=value', required=False, default=[],
43
+ action='append',
44
+ help="""Override value for a single build-time variable defined
45
+ by the config. Specify option multiple times for multiple
46
+ variables. Overrides for variables that have a default
47
+ specified by the config are optional.""")
48
+
49
+ cmdp.add_argument('-s', '--no-sync',
50
+ metavar='component', required=False, default=[],
51
+ action='append',
52
+ help="""Optionally specify any components whose git repos should
53
+ not be synced. For all other components, Shrinkwrap ensures
54
+ that all repos are clean and checked out at the correct
55
+ revision. Option can be specified multiple times.""")
56
+
57
+ cmdp.add_argument('--no-sync-all',
58
+ required=False, default=False, action='store_true',
59
+ help="""Do not sync repos for any component, as if --no-sync was
60
+ specified for every component in the config.""")
61
+
62
+ cmdp.add_argument('--force-sync',
63
+ metavar='component', required=False, default=[], action='append',
64
+ help="""Synchronize the repo of the given component even if the local
65
+ source directory contains unsaved changes. YOUR CHANGES WILL BE
66
+ LOST! In addition, download updates from remote branches.""")
67
+
68
+ cmdp.add_argument('--force-sync-all',
69
+ required=False, default=False, action='store_true',
70
+ help="""Synchronize all components even if the local source directories
71
+ contain unsaved changes. YOUR CHANGES WILL BE LOST! In addition,
72
+ download all remote branch updates. Note that this will override
73
+ any 'sync: false' config option.""")
74
+
75
+ buildall.add_common_args(cmdp)
76
+
77
+ return cmd_name
78
+
79
+
80
+ def dispatch(args):
81
+ """
82
+ Part of the command interface expected by shrinkwrap.py. Called to
83
+ execute the subcommand, with the arguments the user passed on the
84
+ command line. The arguments comply with those requested in add_parser().
85
+ """
86
+ btvars = vars.parse(args.btvar, type='bt')
87
+ if args.no_sync_all:
88
+ args.no_sync = True
89
+ if args.force_sync_all:
90
+ args.force_sync = True
91
+ buildall.build([args.config], [btvars], args.no_sync, args.force_sync, args)
@@ -0,0 +1,180 @@
1
+ # Copyright (c) 2022, Arm Limited.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import os
5
+ import yaml
6
+ import shrinkwrap.utils.config as config
7
+ import shrinkwrap.utils.graph as ugraph
8
+ import shrinkwrap.utils.runtime as runtime
9
+ import shrinkwrap.utils.workspace as workspace
10
+
11
+
12
+ cmd_name = os.path.splitext(os.path.basename(__file__))[0]
13
+
14
+
15
+ def dflt_jobs():
16
+ return min(os.cpu_count() // 2, 32)
17
+
18
+
19
+ def add_parser(parser, formatter):
20
+ """
21
+ Part of the command interface expected by shrinkwrap.py. Adds the
22
+ subcommand to the parser, along with all options and documentation.
23
+ Returns the subcommand name.
24
+ """
25
+ cmdp = parser.add_parser(cmd_name,
26
+ formatter_class=formatter,
27
+ help="""Builds either all concrete standard configs or an
28
+ explicitly specified set of configs and packages them ready
29
+ to run.""",
30
+ epilog="""Custom config store(s) can be defined at at
31
+ <SHRINKWRAP_CONFIG> as a colon-separated list of
32
+ directories. Building is done at <SHRINKWRAP_BUILD> and
33
+ output is saved to <SHRINKWRAP_PACKAGE>. The package
34
+ includes all FW binaries, a manifest and a build.sh script
35
+ containing all the commands that were executed per config.
36
+ Any pre-existing config package directory is first deleted.
37
+ Shrinkwrap will always search its default config store even
38
+ if <SHRINKWRAP_CONFIG> is not defined. <SHRINKWRAP_BUILD>
39
+ and <SHRINKWRAP_PACKAGE> default to '~/.shrinkwrap/build'
40
+ and '~/.shrinkwrap/package'. The user can override them by
41
+ setting the environment variables.""")
42
+
43
+ cmdp.add_argument('configs',
44
+ metavar='yamlfile',
45
+ help="""A yaml file containing all the configs to be built. The
46
+ top level dictionary contains a 'configs' key, whose value
47
+ is a list of dictionaries, each with a 'config' key, whose
48
+ value is a config filename.""")
49
+
50
+ add_common_args(cmdp)
51
+
52
+ return cmd_name
53
+
54
+
55
+ def add_common_args(cmdp):
56
+ """
57
+ Common args shared between build and buildmulti.
58
+ """
59
+ cmdp.add_argument('-o', '--overlay',
60
+ metavar='cfgfile', required=False, default=[],
61
+ action='append',
62
+ help="""Optional config file overlay to override run-time and
63
+ build-time settings. Only entries within the "build",
64
+ "buildex" and "run" sections are used. Applied to all
65
+ configs being built. Can be specified multiple times;
66
+ left-most overlay is the first overlay applied.""")
67
+
68
+ cmdp.add_argument('-t', '--tasks',
69
+ required=False, default=dflt_jobs(), metavar='count', type=int,
70
+ help="""Maximum number of "high-level" tasks that will be
71
+ performed in parallel by Shrinkwrap. Tasks include syncing
72
+ git repositories, building components and copying
73
+ artifacts. Default={}""".format(dflt_jobs()))
74
+
75
+ cmdp.add_argument('-j', '--jobs',
76
+ required=False, default=dflt_jobs(), metavar='count', type=int,
77
+ help="""Maximum number of low-level jobs that will be
78
+ performed in parallel by each component build task.
79
+ Default={}""".format(dflt_jobs()))
80
+
81
+ cmdp.add_argument('-v', '--verbose',
82
+ required=False, default=False, action='store_true',
83
+ help="""If specified, the output from all executed commands will
84
+ be displayed. It is advisable to set tasks to 1 when
85
+ this option is selected.""")
86
+
87
+ cmdp.add_argument('-n', '--dry-run',
88
+ required=False, default=False, action='store_true',
89
+ help="""If specified, <SHRINKWRAP_BUILD> and
90
+ <SHRINKWRAP_PACKAGE> will not be touched and none of the
91
+ build commands will be executed. Instead the set of
92
+ commands that would have been executed are output to stdout
93
+ as a bash script.""")
94
+
95
+ cmdp.add_argument('-c', '--no-color',
96
+ required=False, default=False, action='store_true',
97
+ help="""If specified, logs will not be colorized.""")
98
+
99
+
100
+ def dispatch(args):
101
+ """
102
+ Part of the command interface expected by shrinkwrap.py. Called to
103
+ execute the subcommand, with the arguments the user passed on the
104
+ command line. The arguments comply with those requested in add_parser().
105
+ """
106
+ with open(args.configs) as file:
107
+ cfgs = yaml.safe_load(file)
108
+
109
+ configs = [c['config'] for c in cfgs['configs']]
110
+ btvarss = [c['btvars'] for c in cfgs['configs']]
111
+ build(configs, btvarss, [], [], args)
112
+
113
+
114
+ def build(configs, btvarss, nosync, force_sync, args):
115
+ """
116
+ Concurrently builds a list of configs. Intended to be called as a common
117
+ handler for the build and buildmulti commands.
118
+ """
119
+ clivars = {'jobs': args.jobs}
120
+ configs = config.load_resolveb_all(configs, args.overlay, clivars, btvarss)
121
+ graph = config.build_graph(configs, args.verbose, nosync, force_sync)
122
+
123
+ if args.dry_run:
124
+ script = ugraph.make_script(graph)
125
+ print(script)
126
+ else:
127
+ if args.verbose:
128
+ workspace.dump()
129
+
130
+ # Run under a runtime environment, which may just run commands
131
+ # natively on the host or may execute commands in a container,
132
+ # depending on what the user specified.
133
+ with runtime.Runtime(name=args.runtime, image=config.get_image(configs, args),
134
+ ssh_agent_keys=args.ssh_agent_keys) as rt:
135
+ def add_volume(path, levels_up=0):
136
+ while levels_up:
137
+ path = os.path.dirname(path)
138
+ levels_up -= 1
139
+ os.makedirs(path, exist_ok=True)
140
+ rt.add_volume(path)
141
+
142
+ add_volume(workspace.build)
143
+ add_volume(workspace.package)
144
+ for c in workspace.configs():
145
+ add_volume(c)
146
+
147
+ for conf in configs:
148
+ for comp in conf['build'].values():
149
+ add_volume(comp['sourcedir'], 1)
150
+ add_volume(comp['builddir'])
151
+
152
+ for btvar in conf['buildex']['btvars'].values():
153
+ if btvar['type'] == 'path':
154
+ rt.add_volume(btvar['value'])
155
+
156
+ if workspace.project_cache:
157
+ add_volume(workspace.project_cache)
158
+
159
+ rt.start()
160
+
161
+ ugraph.execute(graph,
162
+ args.tasks,
163
+ args.verbose,
164
+ not args.no_color)
165
+
166
+ for c in configs:
167
+ # Dump the config.
168
+ cfg_name = os.path.join(workspace.package,
169
+ f'{c["name"]}.yaml')
170
+ with open(cfg_name, 'w') as cfg:
171
+ config.dump(c, cfg)
172
+
173
+ # Dump the script to build the config.
174
+ graph = config.build_graph([c], args.verbose, nosync, force_sync)
175
+ script = ugraph.make_script(graph)
176
+ build_name = os.path.join(workspace.package,
177
+ c['name'],
178
+ 'build.sh')
179
+ with open(build_name, 'w') as build:
180
+ build.write(script)
@@ -0,0 +1,161 @@
1
+ # Copyright (c) 2022, Arm Limited.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ import os
5
+ import shrinkwrap.utils.config as config
6
+ import shrinkwrap.utils.graph as ugraph
7
+ import shrinkwrap.utils.runtime as runtime
8
+ import shrinkwrap.utils.workspace as workspace
9
+
10
+
11
+ cmd_name = os.path.splitext(os.path.basename(__file__))[0]
12
+
13
+
14
+ def dflt_jobs():
15
+ return min(os.cpu_count() // 2, 32)
16
+
17
+
18
+ def add_parser(parser, formatter):
19
+ """
20
+ Part of the command interface expected by shrinkwrap.py. Adds the
21
+ subcommand to the parser, along with all options and documentation.
22
+ Returns the subcommand name.
23
+ """
24
+ cmdp = parser.add_parser(cmd_name,
25
+ formatter_class=formatter,
26
+ help="""Cleans either all concrete standard configs or an
27
+ explicitly specified set of configs, ready to be rebuilt
28
+ from scratch.""")
29
+
30
+ cmdp.add_argument('configs',
31
+ metavar='config', nargs='*',
32
+ help="""0 or more configs to clean. If a config exists relative
33
+ to the current directory that config is used. Else if a
34
+ config exists relative to the config store then it is used.
35
+ If no configs are provided, all concrete configs in the
36
+ config store are cleaned.""")
37
+
38
+ cmdp.add_argument('-o', '--overlay',
39
+ metavar='cfgfile', required=False, default=[],
40
+ action='append',
41
+ help="""Optional config file overlay to override run-time and
42
+ build-time settings. Only entries within the "build",
43
+ "buildex" and "run" sections are used. Applied to all
44
+ configs being built. Can be specified multiple times;
45
+ left-most overlay is the first overlay applied.""")
46
+
47
+ cmdp.add_argument('-t', '--tasks',
48
+ required=False, default=dflt_jobs(), metavar='count', type=int,
49
+ help="""Maximum number of "high-level" tasks that will be
50
+ performed in parallel by Shrinkwrap. Tasks include cleaning
51
+ components. Default={}""".format(dflt_jobs()))
52
+
53
+ cmdp.add_argument('-j', '--jobs',
54
+ required=False, default=dflt_jobs(), metavar='count', type=int,
55
+ help="""Maximum number of low-level jobs that will be
56
+ performed in parallel by each component clean task.
57
+ Default={}""".format(dflt_jobs()))
58
+
59
+ cmdp.add_argument('-v', '--verbose',
60
+ required=False, default=False, action='store_true',
61
+ help="""If specified, the output from all executed commands will
62
+ be displayed. It is advisable to set tasks to 1 when
63
+ this option is selected.""")
64
+
65
+ cmdp.add_argument('-n', '--dry-run',
66
+ required=False, default=False, action='store_true',
67
+ help="""If specified, none of the clean commands will be
68
+ executed. Instead the set of commands that would have been
69
+ executed are output to stdout as a bash script.""")
70
+
71
+ cmdp.add_argument('-c', '--no-color',
72
+ required=False, default=False, action='store_true',
73
+ help="""If specified, logs will not be colorized.""")
74
+
75
+ cmdp.add_argument('-f', '--filter',
76
+ metavar='[config.]component', required=False, default=[],
77
+ action='append',
78
+ help="""Optionally specify the components to clean. Option can
79
+ be specified multiple times to clean multiple components.
80
+ If not specified, all components are cleaned. If 'config.'
81
+ is omitted, component is cleaned for all configs being
82
+ cleaned (component must exist in all configs being
83
+ cleaned).""")
84
+
85
+ return cmd_name
86
+
87
+
88
+ def dispatch(args):
89
+ """
90
+ Part of the command interface expected by shrinkwrap.py. Called to
91
+ execute the subcommand, with the arguments the user passed on the
92
+ command line. The arguments comply with those requested in add_parser().
93
+ """
94
+ clivars = {'jobs': args.jobs}
95
+ configs = config.load_resolveb_all(args.configs, args.overlay, clivars)
96
+ if len(args.configs) == 0:
97
+ configs = [c for c in configs if c['concrete']]
98
+ for conf in configs:
99
+ conf['graph'] = _filter(conf['name'],
100
+ conf['graph'],
101
+ args.filter)
102
+
103
+ graph = config.clean_graph(configs, args.verbose)
104
+
105
+ if args.dry_run:
106
+ script = ugraph.make_script(graph)
107
+ print(script)
108
+ else:
109
+ if args.verbose:
110
+ workspace.dump()
111
+
112
+ # Run under a runtime environment, which may just run commands
113
+ # natively on the host or may execute commands in a container,
114
+ # depending on what the user specified.
115
+ with runtime.Runtime(name=args.runtime, image=config.get_image(configs, args),
116
+ ssh_agent_keys=args.ssh_agent_keys) as rt:
117
+ def add_volume(path, levels_up=0):
118
+ while levels_up:
119
+ path = os.path.dirname(path)
120
+ levels_up -= 1
121
+ os.makedirs(path, exist_ok=True)
122
+ rt.add_volume(path)
123
+
124
+ add_volume(workspace.build)
125
+ add_volume(workspace.package)
126
+
127
+ for conf in configs:
128
+ for comp in conf['build'].values():
129
+ add_volume(comp['sourcedir'], 1)
130
+ add_volume(comp['builddir'], 1)
131
+
132
+ rt.start()
133
+
134
+ ugraph.execute(graph,
135
+ args.tasks,
136
+ args.verbose,
137
+ not args.no_color)
138
+
139
+
140
+ def _filter(name, graph, args):
141
+ components = []
142
+ pruned = {}
143
+
144
+ for arg in args:
145
+ try:
146
+ conf, comp = arg.split('.', maxsplit=1)
147
+ if conf == name:
148
+ components.append(comp)
149
+ except ValueError:
150
+ components.append(arg)
151
+
152
+ if len(components) == 0:
153
+ return graph
154
+
155
+ for c in components:
156
+ if c not in graph:
157
+ raise Exception(f'Bad filter: {c} not a '
158
+ f'component of {name}')
159
+ pruned[c] = []
160
+
161
+ return pruned