From 1c3c253f906e76b76f207f64c03a2c14c48647a1 Mon Sep 17 00:00:00 2001 From: Zhijiang Hu Date: Thu, 26 Oct 2017 07:16:59 -0400 Subject: Build kolla image in VM 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 (cherry picked from commit 377cae861b2c04d8934786acc4d07b41ba98acc5) --- code/makefile_patch.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'code') 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} -- cgit 1.2.3-korg