summaryrefslogtreecommitdiffstats
path: root/fuel/ci
diff options
context:
space:
mode:
authorJonas Bjurel <jonas.bjurel@ericsson.com>2015-09-17 19:32:50 +0200
committerJonas Bjurel <jonas.bjurel@ericsson.com>2015-09-18 08:58:36 +0000
commit1b340aad0dd8246c3febfc397659749405bacc47 (patch)
tree648a67732dfee6e5e032cc24c7a0cd498070c966 /fuel/ci
parenta9373056094ee6c31e5468daeea2b126aa4e58ea (diff)
Fix to solve issues around cache archives having trailing garbage
Change-Id: I69689767e423cf469b5fdf2e40bb0cc931628002 Signed-off-by: Jonas Bjurel <jonas.bjurel@ericsson.com>
Diffstat (limited to 'fuel/ci')
-rwxr-xr-xfuel/ci/build.sh322
1 files changed, 185 insertions, 137 deletions
diff --git a/fuel/ci/build.sh b/fuel/ci/build.sh
index 51ccdae..0f544b4 100755
--- a/fuel/ci/build.sh
+++ b/fuel/ci/build.sh
@@ -135,53 +135,53 @@ source ${INCLUDE_DIR}/build.sh.debug
while getopts "s:c:v:f:l:r:RtTh" OPTION
do
case $OPTION in
- h)
- usage
- rc=0
- exit $rc
- ;;
-
- s)
- BUILD_SPEC=${OPTARG}
- ;;
-
- c)
- BUILD_CACHE_URI=${OPTARG}
- ;;
-
- l)
- BUILD_LOG=${OPTARG}
- ;;
-
- v)
- BUILD_VERSION=${OPTARG}
- ;;
-
- f)
- BUILD_FLAGS=${OPTARG}
- ;;
-
- r) REMOTE_ACCESS_METHD=${OPTARG}
- ;;
-
- R)
- RECURSIVE=1
- ;;
-
- t)
- INTEGRATION_TEST=1
- ;;
-
- T)
- INTEGRATION_TEST=1
- FULL_INTEGRATION_TEST=1
- ;;
-
- *)
- echo "${OPTION} is not a valid argument"
- rc=100
- exit $rc
- ;;
+ h)
+ usage
+ rc=0
+ exit $rc
+ ;;
+
+ s)
+ BUILD_SPEC=${OPTARG}
+ ;;
+
+ c)
+ BUILD_CACHE_URI=${OPTARG}
+ ;;
+
+ l)
+ BUILD_LOG=${OPTARG}
+ ;;
+
+ v)
+ BUILD_VERSION=${OPTARG}
+ ;;
+
+ f)
+ BUILD_FLAGS=${OPTARG}
+ ;;
+
+ r) REMOTE_ACCESS_METHD=${OPTARG}
+ ;;
+
+ R)
+ RECURSIVE=1
+ ;;
+
+ t)
+ INTEGRATION_TEST=1
+ ;;
+
+ T)
+ INTEGRATION_TEST=1
+ FULL_INTEGRATION_TEST=1
+ ;;
+
+ *)
+ echo "${OPTION} is not a valid argument"
+ rc=100
+ exit $rc
+ ;;
esac
done
@@ -191,44 +191,44 @@ fi
for ((i=0; i<${#BUILD_FLAGS};i++)); do
case ${BUILD_FLAGS:$i:1} in
- s)
- rc=0
- exit $rc
- ;;
-
- f)
- rc=1
- exit $rc
- ;;
-
- t)
- UNIT_TEST=1
- ;;
-
- i)
- INTERACTIVE=1
- ;;
-
- P)
- POPULATE_CACHE=1
- ;;
-
- d)
- DETACH=1
- echo "Detach is not yet supported - exiting ...."
- rc=100
- exit $rc
- ;;
-
- D)
- DEBUG=1
- ;;
-
- *)
- echo "${BUILD_FLAGS:$i:1} is not a valid build flag - exiting ...."
- rc=100
- exit $rc
- ;;
+ s)
+ rc=0
+ exit $rc
+ ;;
+
+ f)
+ rc=1
+ exit $rc
+ ;;
+
+ t)
+ UNIT_TEST=1
+ ;;
+
+ i)
+ INTERACTIVE=1
+ ;;
+
+ P)
+ POPULATE_CACHE=1
+ ;;
+
+ d)
+ DETACH=1
+ echo "Detach is not yet supported - exiting ...."
+ rc=100
+ exit $rc
+ ;;
+
+ D)
+ DEBUG=1
+ ;;
+
+ *)
+ echo "${BUILD_FLAGS:$i:1} is not a valid build flag - exiting ...."
+ rc=100
+ exit $rc
+ ;;
esac
done
@@ -252,13 +252,13 @@ fi
if [ ! -z ${BUILD_LOG} ]; then
if [[ ${RECURSIVE} -ne 1 ]]; then
- set +e
- eval $0 -R $@ > ${BUILD_LOG} 2>&1
- rc=$?
- set -e
- if [ $rc -ne 0]; then
- exit $rc
- fi
+ set +e
+ eval $0 -R $@ > ${BUILD_LOG} 2>&1
+ rc=$?
+ set -e
+ if [ $rc -ne 0]; then
+ exit $rc
+ fi
fi
fi
@@ -284,47 +284,86 @@ echo $$ > ${LOCK_FILE}
if [ ! -z ${BUILD_CACHE_URI} ]; then
if [ ${POPULATE_CACHE} -ne 1 ]; then
- rm -rf ${CACHE_TMP}/cache
- mkdir -p ${CACHE_TMP}/cache
- echo "Downloading cach file ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME} ..."
- set +e
- ${REMOTE_ACCESS_METHD} -o ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}.tgz
- rc=$?
- set -e
- if [ $rc -ne 0 ]; then
- echo "Remote cache does not exist, or is not accessible - a new cache will be built ..."
- POPULATE_CACHE=1
- else
- echo "Unpacking cache file ..."
- tar -C ${CACHE_TMP}/cache -xvf ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz
- cp ${CACHE_TMP}/cache/cache/.versions ${BUILD_BASE}/.
- set +e
- make -C ${BUILD_BASE} validate-cache;
- rc=$?
- set -e
-
- if [ $rc -ne 0 ]; then
- echo "Cache invalid - a new cache will be built "
- POPULATE_CACHE=1
- else
- cp -rf ${CACHE_TMP}/cache/cache/. ${BUILD_BASE}
- fi
- rm -rf ${CACHE_TMP}/cache
- fi
+ rm -rf ${CACHE_TMP}/cache
+ mkdir -p ${CACHE_TMP}/cache
+ echo "Downloading cache archive ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME} ..."
+ set +e
+ ${REMOTE_ACCESS_METHD} -o ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}.tgz
+ rc=$?
+ set -e
+ if [ $rc -ne 0 ]; then
+ echo "Remote cache does not exist, or is not accessible - a new cache will be built ..."
+ POPULATE_CACHE=1
+ else
+ echo "Unpacking cache archive ..."
+ set +e
+ tar -C ${CACHE_TMP}/cache -xvf ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz
+ rc=$?
+ set -e
+ if [ $rc -ne 0 ]; then
+ echo "WARNING: The cache seems to be corrupt or has trailing garbage, will try to use brute force"
+ echo "Info about the cache below:"
+ set +e
+ file ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz
+ tar -C ${CACHE_TMP}/cache -tvf ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz
+ set -e
+ echo "Current time is: `date`"
+ set +e
+ pushd ${CACHE_TMP}/cache
+ gunzip -dcq ${CACHE_TMP}/cache/${LOCAL_CACHE_ARCH_NAME}.tgz | tar -xvf -
+ rc=$?
+ set -e
+ popd
+ if [ $rc -ne 0 ]; then
+ echo "ERROR: Not able to resolve the cache corruption"
+ POPULATE_CACHE=1
+ else
+ echo "The chache corruption was resolved"
+ cp ${CACHE_TMP}/cache/cache/.versions ${BUILD_BASE}/.
+ set +e
+ make -C ${BUILD_BASE} validate-cache;
+ rc=$?
+ set -e
+ if [ $rc -ne 0 ]; then
+ echo "Cache invalid - a new cache will be built "
+ POPULATE_CACHE=1
+ else
+ echo "Cache is up to date and will be used"
+ cp -rf ${CACHE_TMP}/cache/cache/. ${BUILD_BASE}
+ fi
+ fi
+ else
+ echo "Cache archive is intact"
+ cp ${CACHE_TMP}/cache/cache/.versions ${BUILD_BASE}/.
+ set +e
+ make -C ${BUILD_BASE} validate-cache;
+ rc=$?
+ set -e
+
+ if [ $rc -ne 0 ]; then
+ echo "Cache invalid - a new cache will be built "
+ POPULATE_CACHE=1
+ else
+ echo "Cache is up to date and will be used"
+ cp -rf ${CACHE_TMP}/cache/cache/. ${BUILD_BASE}
+ fi
+ fi
+ rm -rf ${CACHE_TMP}/cache
+ fi
fi
fi
if [ ${POPULATE_CACHE} -eq 1 ]; then
if [ ${DEBUG} -eq 0 ]; then
- set +e
- cd ${BUILD_BASE} && make clean
- rc=$?
- set -e
- if [ $rc -ne 0 ]; then
- echo "Build - make clean failed, exiting ..."
- rc=100
- exit $rc
- fi
+ set +e
+ cd ${BUILD_BASE} && make clean
+ rc=$?
+ set -e
+ if [ $rc -ne 0 ]; then
+ echo "Build - make clean failed, exiting ..."
+ rc=100
+ exit $rc
+ fi
fi
fi
@@ -352,12 +391,12 @@ if [ ${DEBUG} -eq 0 ]; then
rc=$?
set -e
if [ $rc -gt 0 ]; then
- echo "Build: make all failed, exiting ..."
- rc=200
- exit $rc
+ echo "Build: make all failed, exiting ..."
+ rc=200
+ exit $rc
fi
else
-debug_make
+ debug_make
fi
set +e
make -C ${BUILD_BASE} prepare-cache
@@ -377,11 +416,20 @@ cp ${RESULT_DIR}/*.iso* ${BUILD_DIR}
if [ $POPULATE_CACHE -eq 1 ]; then
if [ ! -z ${BUILD_CACHE_URI} ]; then
- echo "Building cache ..."
- tar --dereference -C ${BUILD_BASE} -caf ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz ${CACHE_DIR}
- echo "Uploading cache ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}"
- ${REMOTE_ACCESS_METHD} -T ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}.tgz
- rm ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz
+ echo "Building cache ..."
+ tar --dereference -C ${BUILD_BASE} -caf ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz ${CACHE_DIR}
+ set +e
+ tar -C ${CACHE_TMP}/cache -tvf ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz
+ rc=$?
+ set -e
+ if [ $rc -ne 0 ]; then
+ echo "WARNING the cache archive generated seems to be corrupt, or containing trailing garbage"
+ else
+ echo "The Cache archive build is intact"
+ fi
+ echo "Uploading cache ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}"
+ ${REMOTE_ACCESS_METHD} -T ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz ${BUILD_CACHE_URI}/${REMOTE_CACHE_ARCH_NAME}.tgz
+ rm ${BUILD_BASE}/${LOCAL_CACHE_ARCH_NAME}.tgz
fi
fi
echo "Success!!!"