97c01e48ed
Currently we have all our elements and library files in a top-level directory and install them into <root>/share/diskimage-builder/[elements|lib] (where root is either / or the root of a virtualenv). The problem with this is that editable/development installs (pip -e) do *not* install data_files. Thus we have no canonical location to look for elements -- leading to the various odd things we do such as a whole bunch of guessing at the top of disk-image-create and having a special test-loader in tests/test_elements.py so we can run python unit tests on those elements that have it. data_files is really the wrong thing to use for what are essentially assets of the program. data_files install works well for things like config-files, init.d files or dropping documentation files. By moving the elements under the diskimage_builder package, we always know where they are relative to where we import from. In fact, pkg_resources has an api for this which we wrap in the new diskimage_builder/paths.py helper [1]. We use this helper to find the correct path in the couple of places we need to find the base-elements dir, and for the paths to import the library shell functions. Elements such as svc-map and pkg-map include python unit-tests, which we do not need tests/test_elements.py to special-case load any more. They just get found automatically by the normal subunit loader. I have a follow-on change (I69ca3d26fede0506a6353c077c69f735c8d84d28) to move disk-image-create to a regular python entry-point. Unfortunately, this has to move to work with setuptools. You'd think a symlink under diskimage_builder/[elements|lib] would work, but it doesn't. [1] this API handles stuff like getting files out of .zip archive modules, which we don't do. Essentially for us it's returning __file__. Change-Id: I5e3e3c97f385b1a4ff2031a161a55b231895df5b
73 lines
2.3 KiB
ReStructuredText
73 lines
2.3 KiB
ReStructuredText
================
|
|
package-installs
|
|
================
|
|
|
|
The package-installs element allows for a declarative method of installing and
|
|
uninstalling packages for an image build. This is done by creating a
|
|
package-installs.yaml or package-installs.json file in the element directory.
|
|
|
|
In order to work on Gentoo hosts you will need to manually install
|
|
`dev-python/pyyaml`.
|
|
|
|
example ``package-installs.yaml``
|
|
|
|
.. code-block:: YAML
|
|
|
|
libxml2:
|
|
grub2:
|
|
phase: pre-install.d
|
|
networkmanager:
|
|
uninstall: True
|
|
os-collect-config:
|
|
installtype: source
|
|
linux-image-amd64:
|
|
arch: amd64
|
|
dmidecode:
|
|
not-arch: ppc64, ppc64le
|
|
lshw:
|
|
arch: ppc64, ppc64le
|
|
|
|
example package-installs.json
|
|
|
|
.. code-block:: json
|
|
|
|
{
|
|
"libxml2": null,
|
|
"grub2": {"phase": "pre-install.d"},
|
|
"networkmanager": {"uninstall": true}
|
|
"os-collect-config": {"installtype": "source"}
|
|
}
|
|
|
|
|
|
Setting phase, uninstall, or installtype properties for a package overrides
|
|
the following default values::
|
|
|
|
phase: install.d
|
|
uninstall: False
|
|
installtype: * (Install package for all installtypes)
|
|
arch: * (Install package for all architectures)
|
|
|
|
Setting the installtype property causes the package only to be installed if
|
|
the specified installtype would be used for the element. See the
|
|
diskimage-builder docs for more information on installtypes.
|
|
|
|
The ``arch`` property is a comma-separated list of architectures to
|
|
install for. The ``not-arch`` is a comma-separated list of
|
|
architectures the package should be excluded from. Either ``arch`` or
|
|
``not-arch`` can be given for one package - not both. See
|
|
documentation about the ARCH variable for more information.
|
|
|
|
DEPRECATED: Adding a file under your elements pre-install.d, install.d, or
|
|
post-install.d directories called package-installs-<element-name> will cause
|
|
the list of packages in that file to be installed at the beginning of the
|
|
respective phase. If the package name in the file starts with a "-", then
|
|
that package will be removed at the end of the install.d phase.
|
|
|
|
Using post-install.d for cleanup
|
|
================================
|
|
|
|
Package removal is done in post-install.d at level 95. If you a
|
|
running cleanup functions before this, you need to be careful not
|
|
to clean out any temporary files relied upon by this element.
|
|
For this reason, generally post-install cleanup functions should
|
|
occupy the higher levels between 96 and 99.
|