build-stx-base.sh --latest --clean fails to clean the latest image

When both --latest and --clean flags are passed to build-stx-base.sh
we expect the docker image tagged as '...-latest' to be deleted
from the local build environment.

This did not occure ...

starlingx/stx-centos      dev-latest          279c713e0b5d        7
hours ago         331MB
starlingx/stx-centos      <none>              dda342637517        19
hours ago        331MB

Adding a code block to handle the case when these flags are combined.

Closes-Bug: 1808544
Change-Id: Ic2d17bc285f3746965c2a5e7ec49c278f0fbf066
Signed-off-by: Scott Little <scott.little@windriver.com>
This commit is contained in:
Scott Little 2018-12-14 10:35:30 -05:00
parent f1bfa53e87
commit 32c08a8dd4
1 changed files with 9 additions and 0 deletions

View File

@ -249,6 +249,15 @@ if [ "${CLEAN}" = "yes" ]; then
exit 1
fi
if [ "$TAG_LATEST" = "yes" ]; then
echo "Deleting image: ${IMAGE_NAME_LATEST}"
docker image rm ${IMAGE_NAME_LATEST}
if [ $? -ne 0 ]; then
echo "Failed running docker image rm command" >&2
exit 1
fi
fi
if [ ${BASE_IMAGE_PRESENT} -ne 0 ]; then
# The base image was not already present, so delete it
echo "Removing docker image ${OS}:${OS_VERSION}"