b62ed1823c
When using the package-installs element there can be some encoding problems if the package installation emits unparsable output [1]. However in this case we just want to forward the output to the console which normally can handle this correctly. In order to fix this switch off universal_newlines processing such that we just operate on bytes. Further we have to decode the lines without setting the locale and ignoring errors. This is required because print encodes without setting the locale and thus we need to filter/modify the stream such that it doesn't crash. [1] Traceback: 2018-03-01 09:58:00.515 | Traceback (most recent call last): 2018-03-01 09:58:00.515 | File "/usr/local/bin/package-installs-v2", line 137, in <module> 2018-03-01 09:58:00.515 | main() 2018-03-01 09:58:00.515 | File "/usr/local/bin/package-installs-v2", line 130, in main 2018-03-01 09:58:00.515 | process_output(install_args, follow=True) 2018-03-01 09:58:00.515 | for line in iter(proc.stdout.readline, ''): 2018-03-01 09:58:00.515 | File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode 2018-03-01 09:58:00.515 | return codecs.ascii_decode(input, self.errors)[0] 2018-03-01 09:58:00.515 | UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 34: ordinal not in range(128) Change-Id: Ie4af9b4523459a630cfb98d09093bfe9ef7aa61e |
||
---|---|---|
.. | ||
bin | ||
extra-data.d | ||
install.d | ||
post-install.d | ||
pre-install.d | ||
element-deps | ||
README.rst |
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
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
python-dev:
dib_python_version: 2
python3-dev:
dib_python_version: 3
example package-installs.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)
dib_python_version: (2 or 3 depending on DIB_PYTHON_VERSION, see dib-python)
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.