File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ pipeline {
9191 "${WORKSPACE}/component/dev-support/jenkins-scripts/cache-apache-project-artifact.sh" \
9292 --working-dir "${WORKSPACE}/downloads-yetus" \
9393 --keys 'https://www.apache.org/dist/yetus/KEYS' \
94+ --verify-tar-gz \
9495 "${WORKSPACE}/yetus-${YETUS_RELEASE}-bin.tar.gz" \
9596 "yetus/${YETUS_RELEASE}/apache-yetus-${YETUS_RELEASE}-bin.tar.gz"
9697 mv "yetus-${YETUS_RELEASE}-bin.tar.gz" yetus.tar.gz
@@ -137,6 +138,7 @@ pipeline {
137138 "${WORKSPACE}/component/dev-support/jenkins-scripts/cache-apache-project-artifact.sh" \
138139 --working-dir "${WORKSPACE}/downloads-hadoop-2" \
139140 --keys 'http://www.apache.org/dist/hadoop/common/KEYS' \
141+ --verify-tar-gz \
140142 "${WORKSPACE}/hadoop-${HADOOP2_VERSION}-bin.tar.gz" \
141143 "hadoop/common/hadoop-${HADOOP2_VERSION}/hadoop-${HADOOP2_VERSION}.tar.gz"
142144 for stale in $(ls -1 "${WORKSPACE}"/hadoop-2*.tar.gz | grep -v ${HADOOP2_VERSION}); do
@@ -164,6 +166,7 @@ pipeline {
164166 "${WORKSPACE}/component/dev-support/jenkins-scripts/cache-apache-project-artifact.sh" \
165167 --working-dir "${WORKSPACE}/downloads-hadoop-3" \
166168 --keys 'http://www.apache.org/dist/hadoop/common/KEYS' \
169+ --verify-tar-gz \
167170 "${WORKSPACE}/hadoop-${HADOOP3_VERSION}-bin.tar.gz" \
168171 "hadoop/common/hadoop-${HADOOP3_VERSION}/hadoop-${HADOOP3_VERSION}.tar.gz"
169172 for stale in $(ls -1 "${WORKSPACE}"/hadoop-3*.tar.gz | grep -v ${HADOOP3_VERSION}); do
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ function usage {
2121 echo " Usage: ${0} [options] /path/to/download/file.tar.gz download/fragment/eg/project/subdir/some-artifact-version.tar.gz"
2222 echo " "
2323 echo " --force for a redownload even if /path/to/download/file.tar.gz exists."
24+ echo " --verify-tar-gz Only use a cached file if it can be parsed as a gzipped tarball."
2425 echo " --working-dir /path/to/use Path for writing tempfiles. must exist."
2526 echo " defaults to making a directory via mktemp that we clean."
2627 echo " --keys url://to/project/KEYS where to get KEYS. needed to check signature on download."
3536
3637# Get arguments
3738declare done_if_cached=" true"
39+ declare verify_tar_gz=" false"
3840declare working_dir
3941declare cleanup=" true"
4042declare keys
4143while [ $# -gt 0 ]
4244do
4345 case " $1 " in
4446 --force) shift ; done_if_cached=" false" ;;
47+ --verify-tar-gz) shift ; verify_tar_gz=" true" ;;
4548 --working-dir) shift ; working_dir=$1 ; cleanup=" false" ; shift ;;
4649 --keys) shift ; keys=$1 ; shift ;;
4750 --) shift ; break ;;
5861target=" $1 "
5962artifact=" $2 "
6063
61- if [ -f " ${target} " ] && [ " true" = " ${done_if_cached} " ]; then
62- echo " Reusing existing download of '${artifact} '."
63- exit 0
64+ if [ -f " ${target} " ] && [ -s " ${target} " ] && [ -r " ${target} " ] && [ " true" = " ${done_if_cached} " ]; then
65+ if [ " false" = " ${verify_tar_gz} " ]; then
66+ echo " Reusing existing download of '${artifact} '."
67+ exit 0
68+ fi
69+ if ! tar tzf " ${target} " > /dev/null 2>&1 ; then
70+ echo " Cached artifact is not a well formed gzipped tarball; clearing the cached file at '${target} '."
71+ rm -rf " ${target} "
72+ else
73+ echo " Reusing existing download of '${artifact} ', which is a well formed gzipped tarball."
74+ exit 0
75+ fi
6476fi
6577
6678if [ -z " ${working_dir} " ]; then
You can’t perform that action at this time.
0 commit comments