Coverity: shadow clone mbed-tls

Avoids some (unnecessary) git content download. It also removes some
code that does the tag checkout and instead it is done at the same
git-clone command.

Change-Id: If690a871578325faa8d6b65d8d80261e771a5077
Signed-off-by: Leonardo Sandoval <leonardo.sandoval@linaro.org>
diff --git a/script/tf-coverity/common-def.sh b/script/tf-coverity/common-def.sh
index ea54d18..bcf7547 100644
--- a/script/tf-coverity/common-def.sh
+++ b/script/tf-coverity/common-def.sh
@@ -7,6 +7,10 @@
 
 JENKINS_URL=https://jenkins.oss.arm.com/
 
+# mbed TLS variables
+MBED_TLS_DIR=mbedtls
+MBED_TLS_URL_REPO=https://github.com/ARMmbed/mbedtls.git
+
 # mbed TLS source tag to checkout when building Trusted Firmware with Trusted
 # Board Boot support.
 MBED_TLS_SOURCES_TAG="mbedtls-2.18.0"
diff --git a/script/tf-coverity/tf-cov-make b/script/tf-coverity/tf-cov-make
index cda8227..a18dcf9 100755
--- a/script/tf-coverity/tf-cov-make
+++ b/script/tf-coverity/tf-cov-make
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/usr/bin/env bash
 #
 # Copyright (c) 2019-2020, Arm Limited. All rights reserved.
 #
@@ -26,17 +26,16 @@
 
 export CROSS_COMPILE=aarch64-none-elf-
 
+containing_dir="$(readlink -f "$(dirname "$0")/")"
+. $containing_dir/common-def.sh
+
 # Get mbed TLS library code to build Trusted Firmware with Trusted Board Boot
 # support. The version of mbed TLS to use here must be the same as when
 # building TF in the usual context.
-if [ ! -d mbedtls ]; then
-    git clone https://github.com/ARMmbed/mbedtls.git
+if [ ! -d "$MBED_TLS_DIR" ]; then
+    git clone -q --depth 1 -b "$MBED_TLS_SOURCES_TAG" "$MBED_TLS_URL_REPO" "$MBED_TLS_DIR"
 fi
-cd mbedtls
-containing_dir="$(readlink -f "$(dirname "$0")/")"
-. $containing_dir/common-def.sh
-git checkout "$MBED_TLS_SOURCES_TAG"
-cd -
+
 TBB_OPTIONS="TRUSTED_BOARD_BOOT=1 GENERATE_COT=1 MBEDTLS_DIR=$(pwd)/mbedtls"
 ARM_TBB_OPTIONS="$TBB_OPTIONS ARM_ROTPK_LOCATION=devel_rsa"