Merge "Move generation of dib_[environment|args] to manifest element"

This commit is contained in:
Jenkins 2017-02-07 20:23:06 +00:00 committed by Gerrit Code Review
commit 740c0a85df
5 changed files with 39 additions and 53 deletions

View File

@ -323,10 +323,6 @@ then one branch of a git repository or to get source for a local cache. See
Debugging elements Debugging elements
------------------ ------------------
The build-time environment and command line arguments are captured by the
:doc:`../elements/base/README` element and written to ``/etc/dib_environment``
and ``/etc/dib_arguments`` inside the image.
Export ``break`` to drop to a shell during the image build. Break points can be Export ``break`` to drop to a shell during the image build. Break points can be
set either before or after any of the hook points by exporting set either before or after any of the hook points by exporting
"break=[before|after]-hook-name". Multiple break points can be specified as a "break=[before|after]-hook-name". Multiple break points can be specified as a
@ -339,6 +335,12 @@ comma-delimited string. Some examples:
* ``break=after-error`` will break after an error during an in target hookpoint. * ``break=after-error`` will break after an error during an in target hookpoint.
The :doc:`../elements/manifests/README` element will make a range of
manifest information generated by other elements available for
inspection inside and outside the built image. Environment and
command line arguments are captured as described in the documentation
and can be useful for debugging.
Images are built such that the Linux kernel is instructed not to switch into Images are built such that the Linux kernel is instructed not to switch into
graphical consoles (i.e. it will not activate KMS). This maximises graphical consoles (i.e. it will not activate KMS). This maximises
compatibility with remote console interception hardware, such as HP's iLO. compatibility with remote console interception hardware, such as HP's iLO.

View File

@ -1,13 +0,0 @@
#!/bin/bash
# Store the build-time environment and command line arguments
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
[ -n "$TMP_HOOKS_PATH" ] || die "Temp hook path not set"
echo "$DIB_ENV" > $TMP_HOOKS_PATH/dib_environment
echo "$DIB_ARGS" > $TMP_HOOKS_PATH/dib_arguments

View File

@ -1,16 +0,0 @@
#!/bin/bash
# Store build-time environment and command line arguments
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
if [ -e "/tmp/in_target.d/dib_environment" ]; then
cp /tmp/in_target.d/dib_environment /etc/
fi
if [ -e "/tmp/in_target.d/dib_arguments" ]; then
cp /tmp/in_target.d/dib_arguments /etc/
fi

View File

@ -1,13 +1,25 @@
========= =========
manifests manifests
========= =========
Copy any manifests generated into the build area post-image creation
This element should be a dependency of any element that writes a manifest An framework for saving manifest information generated during the
into the `DIB_MANIFEST_IMAGE_DIR`, which defaults to `/etc/dib-manifests`. build for later inspection. Manifests are kept in the final image and
This is created in extra-data.d rather than pre-install.d to allow the also copied to the build area post-image creation.
source-repositories element to make use of it
The manifests are copied to `DIB_MANIFEST_SAVE_DIR`, which defaults to Elements that wish to save any form of manifest should depend on this
`${IMAGE_NAME}.d/`, resulting in the manifests being available as element and can save their data to into the ``DIB_MANIFEST_IMAGE_DIR`` (
`${IMAGE_NAME}.d/dib-manifests` by default which defaults to ``/etc/dib-manifests``). Note this is created in
``extra-data.d`` rather than ``pre-install.d`` to allow the
``source-repositories`` element to make use of it
The manifests are copied to ``DIB_MANIFEST_SAVE_DIR``, which defaults
to ``${IMAGE_NAME}.d/``, resulting in the manifests being available as
``${IMAGE_NAME}.d/dib-manifests`` by default after the build.
Extra status
------------
This element will also add the files ``dib_environment`` and
``dib_arguments`` to the manifest recording the ``diskimage-builder``
specific environment (``DIB_*`` variables) and command-line arguments
respectively.

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# Copyright 2014 Hewlett-Packard Development Company, L.P. # Copyright 2014 Hewlett-Packard Development Company, L.P.
# Copyright 2017 Andreas Florath (andreas@florath.net)
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain # not use this file except in compliance with the License. You may obtain
@ -21,15 +22,15 @@ fi
set -eu set -eu
set -o pipefail set -o pipefail
if [ -d $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR} ]; then MANIFEST_IMAGE_PATH=${TMP_MOUNT_PATH}/${DIB_MANIFEST_IMAGE_DIR}
# Move the dib_environment and dib_arguments files into the manifests dir
if [ -e $TMP_MOUNT_PATH/etc/dib_arguments ]; then # Double check: directory must be created in extra-data.d/20-manifest-dir
sudo mv $TMP_MOUNT_PATH/etc/dib_arguments $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR} [ -d ${MANIFEST_IMAGE_PATH} ] || {
fi echo "Error: MANIFEST_IMAGE_PATH [${MANIFEST_IMAGE_PATH}] does not exist";
if [ -e $TMP_MOUNT_PATH/etc/dib_environment ]; then exit 1; }
sudo mv $TMP_MOUNT_PATH/etc/dib_environment $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR}
fi echo "$DIB_ENV" | sudo dd of=${MANIFEST_IMAGE_PATH}/dib_environment # dib-lint: safe_sudo
mkdir -p ${DIB_MANIFEST_SAVE_DIR} echo "$DIB_ARGS" | sudo dd of=${MANIFEST_IMAGE_PATH}/dib_arguments # dib-lint: safe_sudo
cp --no-preserve=ownership -rv $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR} \
${DIB_MANIFEST_SAVE_DIR} mkdir -p ${DIB_MANIFEST_SAVE_DIR}
fi cp --no-preserve=ownership -rv ${MANIFEST_IMAGE_PATH} ${DIB_MANIFEST_SAVE_DIR}