aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>2018-01-08 17:57:56 +0100
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>2018-01-08 22:51:29 +0000
commit17b63ba2c2f40b5b8995280d5f2cb4e696246402 (patch)
tree5c5ec7fe58275953dcf2c453a3c62d8e21631ccc
parent3741eea37e45fb30c6bf8925da776af6f6888dce (diff)
lib.sh: base image: Prevent using incomplete img
In case the previous deploy attempt already copied the base image as the VCP image in order to perform offline operations and failed, leaving an incomplete image in place, current code might try to use it instead of building it from scratch. Use the hash-agnostic link names as checkpoints for successful image handling. Change-Id: I1e99e515e18ba1dec534c520811c127b2b528afe Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com> (cherry picked from commit 5878c5c0c2ca8c78e9a5124452eefe8290ab63cd)
-rw-r--r--mcp/scripts/lib.sh8
1 files changed, 4 insertions, 4 deletions
diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh
index c34b76246..29c27d9e9 100644
--- a/mcp/scripts/lib.sh
+++ b/mcp/scripts/lib.sh
@@ -264,7 +264,7 @@ function prepare_vms {
echo "[INFO] Lookup cache / build patched base image for fingerprint: ${_h}"
_tmp="${image%.*}.${_h}.img"
- if [ -f "$(readlink -f "${image_dir}/${_tmp}")" ]; then
+ if [ "${image_dir}/${_tmp}" -ef "${image_dir}/${image}" ]; then
echo "[INFO] Patched base image found"
else
rm -f "${image_dir}/${image%.*}"*
@@ -279,8 +279,8 @@ function prepare_vms {
echo "[INFO] No patching required, using vanilla base image"
ln -sf "${image_dir}/${_o}" "${image_dir}/${_tmp}"
fi
+ ln -sf "${image_dir}/${_tmp}" "${image_dir}/${image}"
fi
- ln -sf "${image_dir}/${_tmp}" "${image_dir}/${image}"
envsubst < user-data.template > user-data.sh # CWD should be <mcp/scripts>
@@ -296,7 +296,7 @@ function prepare_vms {
if [[ ! "${repos_pkgs_str}" =~ \^{3}$ ]] && [ -n "${repos_pkgs[*]:4}" ]; then
echo "[INFO] Lookup cache / build patched VCP image for md5sum: ${_h}"
_tmp="${vcp_image%.*}.${_h}.img"
- if [ -f "$(readlink -f "${image_dir}/${_tmp}")" ]; then
+ if [ "${image_dir}/${_tmp}" -ef "${image_dir}/${vcp_image}" ]; then
echo "[INFO] Patched VCP image found"
else
echo "[INFO] Patching VCP image ..."
@@ -305,8 +305,8 @@ function prepare_vms {
mount_image "${_tmp}" "${image_dir}"
apt_repos_pkgs_image "${repos_pkgs[@]:4:4}"
cleanup_mounts
+ ln -sf "${image_dir}/${_tmp}" "${image_dir}/${vcp_image}"
fi
- ln -sf "${image_dir}/${_tmp}" "${image_dir}/${vcp_image}"
fi
}