Merge "Standardise manifest creation and retrieval"

This commit is contained in:
Jenkins 2014-04-11 22:10:52 +00:00 committed by Gerrit Code Review
commit b1a4eda4ee
8 changed files with 66 additions and 16 deletions

View File

@ -0,0 +1 @@
manifests

View File

@ -17,17 +17,15 @@
# #
set -eux set -eux
MANIFEST_DIR=/etc/dib-manifests
mkdir -p ${MANIFEST_DIR}
DPKG_MANIFEST_NAME=dib-manifest-dpkg-$(basename ${IMAGE_NAME}) DPKG_MANIFEST_NAME=dib-manifest-dpkg-$(basename ${IMAGE_NAME})
# Write the json preamble # Write the json preamble
echo '{"packages": [' > ${MANIFEST_DIR}/${DPKG_MANIFEST_NAME} echo '{"packages": [' > ${DIB_MANIFEST_IMAGE_DIR}/${DPKG_MANIFEST_NAME}
# Write a json-format output for the packages installed # Write a json-format output for the packages installed
format='{"package": "${binary:Package}","arch": "${Architecture}","version": "${Version}","status": "${db:Status-Abbrev}"},' format='{"package": "${binary:Package}","arch": "${Architecture}","version": "${Version}","status": "${db:Status-Abbrev}"},'
# Use the configurable dpkg --show output as a manifest # Use the configurable dpkg --show output as a manifest
dpkg-query --show --showformat="${format}" | tee -a ${MANIFEST_DIR}/${DPKG_MANIFEST_NAME} dpkg-query --show --showformat="${format}" | tee -a ${DIB_MANIFEST_IMAGE_DIR}/${DPKG_MANIFEST_NAME}
# Finish off the json structure and make it easier for human inspection # Finish off the json structure and make it easier for human inspection
sed -i -e 's/,$/\n]}/g' -e 's/\(},\)/ \1\n/g' ${MANIFEST_DIR}/${DPKG_MANIFEST_NAME} sed -i -e 's/,$/\n]}/g' -e 's/\(},\)/ \1\n/g' ${DIB_MANIFEST_IMAGE_DIR}/${DPKG_MANIFEST_NAME}

View File

@ -0,0 +1,10 @@
Copy any manifests generated into the build area post-image creation
This element should be a dependency of any element that writes a manifest
into the `DIB_MANIFEST_IMAGE_DIR`, which defaults to `/etc/dib-manifests`.
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

View File

@ -0,0 +1,27 @@
#!/bin/bash
#
# Copyright 2014 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# 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
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
set -eux
if [ -d $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR} ]; then
# Move the dib_environment and dib_arguments files into the manifests dir
sudo mv $TMP_MOUNT_PATH/etc/dib_arguments $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR}
sudo mv $TMP_MOUNT_PATH/etc/dib_environment $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR}
mkdir -p ${DIB_MANIFEST_SAVE_DIR}
cp --no-preserve=ownership -rv $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR} \
${DIB_MANIFEST_SAVE_DIR}
fi

View File

@ -0,0 +1,21 @@
#!/bin/bash
#
# Copyright 2014 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# 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
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
set -eu
export DIB_MANIFEST_IMAGE_DIR=${DIB_MANIFEST_IMAGE_DIR:-/etc/dib-manifests}
export DIB_MANIFEST_SAVE_DIR=${DIB_MANIFEST_SAVE_DIR:-${IMAGE_NAME}.d/}

View File

@ -17,11 +17,4 @@
# #
set -eux set -eux
MANIFEST_DIR=/etc/dib-manifests sudo mkdir -p $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR}
DPKG_MANIFEST_NAME=dib-manifest-dpkg-$(basename ${IMAGE_NAME})
if [ -f $TMP_MOUNT_PATH/${MANIFEST_DIR}/${DPKG_MANIFEST_NAME} ]; then
mkdir -p ${IMAGE_NAME}-manifests
cp --no-preserve=ownership -v $TMP_MOUNT_PATH/${MANIFEST_DIR}/${DPKG_MANIFEST_NAME} \
${IMAGE_NAME}-manifests/
fi

View File

@ -1 +1,2 @@
cache-url cache-url
manifests

View File

@ -166,7 +166,7 @@ OLD_CACHE_BASE=~/.cache/image-create/repository-sources
make_new_cache $OLD_CACHE_BASE $CACHE_BASE make_new_cache $OLD_CACHE_BASE $CACHE_BASE
mkdir -p $CACHE_BASE mkdir -p $CACHE_BASE
# Use the IMAGE_NAME from the calling script, and make it unique with the temporary path # Use the IMAGE_NAME from the calling script, and make it unique with the temporary path
GIT_MANIFEST_NAME=dib-git-manifest-$(basename ${IMAGE_NAME}) GIT_MANIFEST_NAME=dib-manifest-git-$(basename ${IMAGE_NAME})
GIT_MANIFEST_CACHE_NAME=${GIT_MANIFEST_NAME}_$(dirname ${TMP_MOUNT_PATH##*.}) GIT_MANIFEST_CACHE_NAME=${GIT_MANIFEST_NAME}_$(dirname ${TMP_MOUNT_PATH##*.})
GIT_MANIFEST=$CACHE_BASE/${GIT_MANIFEST_CACHE_NAME} GIT_MANIFEST=$CACHE_BASE/${GIT_MANIFEST_CACHE_NAME}
rm -f $GIT_MANIFEST rm -f $GIT_MANIFEST
@ -178,6 +178,5 @@ done
# Copy the manifest into the image if it exists (there may be no git repositories used) # Copy the manifest into the image if it exists (there may be no git repositories used)
if [ -e "$GIT_MANIFEST" ] ; then if [ -e "$GIT_MANIFEST" ] ; then
sudo cp $GIT_MANIFEST $TMP_MOUNT_PATH/etc/$GIT_MANIFEST_NAME sudo cp $GIT_MANIFEST $TMP_MOUNT_PATH/${DIB_MANIFEST_IMAGE_DIR}/$GIT_MANIFEST_NAME
sudo mv $GIT_MANIFEST $(dirname ${IMAGE_NAME})/$GIT_MANIFEST_NAME
fi fi