Allow creation of Dockerfile.aarch64 through patch
[releng.git] / jjb / releng / opnfv-docker.sh
index edb10d1..7066d37 100644 (file)
@@ -43,19 +43,29 @@ fi
 if [[ -n "$(docker images | grep $DOCKER_REPO_NAME)" ]]; then
     echo "Docker images to remove:"
     docker images | head -1 && docker images | grep $DOCKER_REPO_NAME
-    image_tags=($(docker images | grep $DOCKER_REPO_NAME | awk '{print $2}'))
-    for tag in "${image_tags[@]}"; do
-        if [[ -n "$(docker images|grep $DOCKER_REPO_NAME|grep $tag)" ]]; then
-            echo "Removing docker image $DOCKER_REPO_NAME:$tag..."
-            docker rmi -f $DOCKER_REPO_NAME:$tag
+    image_ids=($(docker images | grep $DOCKER_REPO_NAME | awk '{print $3}'))
+    for id in "${image_ids[@]}"; do
+        if [[ -n "$(docker images|grep $DOCKER_REPO_NAME|grep $id)" ]]; then
+            echo "Removing docker image $DOCKER_REPO_NAME:$id..."
+            docker rmi -f $id
         fi
     done
 fi
 
 cd $WORKSPACE/docker
-if [ ! -f ${DOCKERFILE} ]; then
-    echo "ERROR: Dockerfile not found."
-    exit 1
+HOST_ARCH=$(uname -m)
+if [ ! -f "${DOCKERFILE}" ]; then
+    # If this is expected to be a Dockerfile for other arch than x86
+    # and it does not exist, but there is a patch for the said arch,
+    # then apply the patch and create the Dockerfile.${HOST_ARCH} file
+    if [[ "${DOCKERFILE}" == *"${HOST_ARCH}" && \
+          -f "Dockerfile.${HOST_ARCH}.patch" ]]; then
+        patch -o Dockerfile."${HOST_ARCH}" Dockerfile \
+        Dockerfile."${HOST_ARCH}".patch
+    else
+        echo "ERROR: No Dockerfile or ${HOST_ARCH} patch found."
+        exit 1
+    fi
 fi
 
 # Get tag version