Add support for build-only packages

Sometimes an element needs packages installed so that it can
perform tasks but those package are not appropriate for the
final image content. Add a "build-only" flag to package-install-squash
which will cause package to be installed at the beginning of the
phase and then uninstalled at the end of the phase.

Change-Id: Ie01b795991710c93f6b669c8f14b57eb4412c1d5
This commit is contained in:
Monty Taylor 2020-03-18 14:39:17 -05:00
parent 64d2ea26e7
commit c113703050
2 changed files with 13 additions and 3 deletions

View File

@ -30,6 +30,8 @@ example ``package-installs.yaml``
dib_python_version: 2 dib_python_version: 2
python3-dev: python3-dev:
dib_python_version: 3 dib_python_version: 3
libssl-dev:
build-only: True
package-a: package-a:
when: DIB_USE_PACKAGE_A = 1 when: DIB_USE_PACKAGE_A = 1
package-b: package-b:
@ -60,6 +62,11 @@ Setting the installtype property causes the package only to be installed if
the specified installtype would be used for the element. See the the specified installtype would be used for the element. See the
diskimage-builder docs for more information on installtypes. diskimage-builder docs for more information on installtypes.
Setting ``build-only`` will cause the package to be added both to the
list of packages to be installed and to the list of packages to be
uninstalled. This allows expressing build-time dependencies that should
not end up in the final image.
The ``arch`` property is a comma-separated list of architectures to The ``arch`` property is a comma-separated list of architectures to
install for. The ``not-arch`` is a comma-separated list of install for. The ``not-arch`` is a comma-separated list of
architectures the package should be excluded from. Either ``arch`` or architectures the package should be excluded from. Either ``arch`` or

View File

@ -113,9 +113,11 @@ def collect_data(data, objs, element_name):
if not params: if not params:
params = {} params = {}
phase = params.get('phase', 'install.d') phase = params.get('phase', 'install.d')
install = "install" installs = ["install"]
if 'uninstall' in params: if 'uninstall' in params:
install = "uninstall" installs = ["uninstall"]
if 'build-only' in params:
installs = ["install", "uninstall"]
# Filter out incorrect installtypes # Filter out incorrect installtypes
installtype = params.get('installtype', None) installtype = params.get('installtype', None)
@ -136,6 +138,7 @@ def collect_data(data, objs, element_name):
continue continue
if valid_installtype and valid_arch and valid_dib_python_version: if valid_installtype and valid_arch and valid_dib_python_version:
for install in installs:
data[phase][install].append((pkg_name, element_name)) data[phase][install].append((pkg_name, element_name))
return data return data