summaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authorZhijiang Hu <hu.zhijiang@zte.com.cn>2017-10-26 07:16:59 -0400
committerZhijiang Hu <hu.zhijiang@zte.com.cn>2017-10-28 08:22:03 +0000
commit1c3c253f906e76b76f207f64c03a2c14c48647a1 (patch)
tree887dabff4a897ddb8c15f9bb24635e7a17b63f17 /code
parentb09f1e970d7a9dfb68216975c2705bab3d84eac8 (diff)
Build kolla image in VMopnfv-5.1.RC1
This PS: 1. Build kolla image in VM 2. Use sha512sum to check kolla image 3. Delete suffix dot when there is no ext_tag Change-Id: I94d99e3ff69c47cc247051fae812bfdb29ff0246 Signed-off-by: Zhijiang Hu <hu.zhijiang@zte.com.cn> (cherry picked from commit 377cae861b2c04d8934786acc4d07b41ba98acc5)
Diffstat (limited to 'code')
-rwxr-xr-xcode/makefile_patch.sh52
1 files changed, 51 insertions, 1 deletions
diff --git a/code/makefile_patch.sh b/code/makefile_patch.sh
index 5e734910..16988a64 100755
--- a/code/makefile_patch.sh
+++ b/code/makefile_patch.sh
@@ -76,9 +76,59 @@ function check_or_download_file()
popd > /dev/null
}
+function check_or_download_file_sha512sum()
+{
+ file_path=$1
+ file_url=$2
+ file_name=$(basename $2)
+ if [ $# -eq 3 ]; then sha512sum_url=$3; else sha512sum_url=""; fi
+
+ pushd $file_path >/dev/null
+
+ count=0
+ MAX_DOWNLOAD_TIMES=2
+ while [ $count -lt ${MAX_DOWNLOAD_TIMES} ]; do
+ count=$[count + 1]
+
+ if [ ! -f ${file_name} ]; then
+ echo "Begin to download ${file_name}"
+ wget --progress=dot:giga ${file_url}
+ fi
+
+ if [ ! -z ${sha512sum_url} ]; then
+ rm -f $(basename ${sha512sum_url})
+ wget ${sha512sum_url}
+ sha512sum -c $(basename ${sha512sum_url})
+ if [ $? -ne 0 ]; then
+ echo "sha512sum check failed !"
+ rm -f ${file_name}
+ else
+ echo "sha512sum_url check succeeded !"
+ count=${MAX_DOWNLOAD_TIMES}
+ fi
+ else
+ wget --spider $file_url -o tmp_filesize
+ origin_size=$(cat tmp_filesize | grep Length | awk '{print $2}')
+ rm tmp_filesize
+ local_size=$(stat -c %s ${file_path}/${file_name} | tr -d '\n')
+ if [ ${local_size} -ne ${origin_size} ]; then
+ echo "The local ${file_name} is incomplete."
+ rm -f ${file_name}
+ else
+ echo "File ${file_path}/${file_name} is ok."
+ count=${MAX_DOWNLOAD_TIMES}
+ fi
+ fi
+ done
+
+ popd > /dev/null
+}
+
+
+
if [ ! -d $CACHE_PATH ]; then mkdir -p $CACHE_PATH ; fi
check_or_download_file $CACHE_PATH $isourl
-check_or_download_file $CACHE_PATH $imageserver/${imagename} ${imageserver}/${imagename}.md5
+check_or_download_file_sha512sum $CACHE_PATH $imageserver/${imagename} ${imageserver}/${imagename}.sha512sum
check_or_download_file $CACHE_PATH "http://daisycloud.org/static/files/registry-server.tar"
check_or_download_file $CACHE_PATH ${cirros_url}