build-unit-test-docker: create hashed tags for final image

Create a tag for the final image in the same format as the stage
images.  Display this tag to stdout at the end of the docker build
so that other scripts can consume it via calls like:
    $(scripts/build-unit-test-docker)

Modify `run-unit-test-docker.sh` to get the docker image from
`build-unit-test-docker` rather than a static image name.  This
ensures that the docker image used in unit testing is the exact
image requested to be built.  (Soon this will allow us to incorporate
Gerrit changes into the docker image itself.)

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Idd7a9a7b0157f1c520b33b3ec7ac0d5b52018d9e
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index f6ee0ef..4dd4c44 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -448,10 +448,7 @@
 
 
 def docker_img_build(pkg, tag, dockerfile):
-    if not force_build and pkg != "final":
-        # TODO: the 'final' is here because we do not tag the final image yet
-        # so we always need to rebuild it.  This will be changed in a future
-        # commit so that we tag even the final image.
+    if not force_build:
         if docker.image.ls(tag, "--format", '"{{.Repository}}:{{.Tag}}"'):
             print(f"Image {tag} already exists.  Skipping.", file=sys.stderr)
             return
@@ -692,4 +689,7 @@
 """
 
 # Do the final docker build
-docker_img_build("final", docker_image_name, dockerfile)
+docker_final_img_name = docker_img_tagname(docker_image_name, dockerfile)
+docker_img_build("final", docker_final_img_name, dockerfile)
+# Print the tag of the final image.
+print(docker_final_img_name)