From 50cfbd548fb8d23f610df68f7605fa61b3d59671 Mon Sep 17 00:00:00 2001 From: Kentaro Hayashi Date: Mon, 24 Jun 2024 18:18:44 +0900 Subject: [PATCH] deb: check with downloaded file Signed-off-by: Kentaro Hayashi --- fluent-package/apt/pkgsize-test.sh | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/fluent-package/apt/pkgsize-test.sh b/fluent-package/apt/pkgsize-test.sh index aeeea9212..442dcd7fc 100755 --- a/fluent-package/apt/pkgsize-test.sh +++ b/fluent-package/apt/pkgsize-test.sh @@ -25,7 +25,6 @@ for v in `git tag | grep "^v" | sort -r`; do PREVIOUS_VERSIONS+=(`echo $v | sed -e 's/v//'`) done -PREV_DEB_FOUND=0 case ${DISTRIBUTION} in debian) BASE_URI=https://packages.treasuredata.com/5/debian/${CODE_NAME} @@ -35,10 +34,6 @@ case ${DISTRIBUTION} in PREVIOUS_DEB=${BASE_URI}/pool/contrib/f/fluent-package/${BASE_NAME} set +e wget ${PREVIOUS_DEB} - if [ $? -eq 0 ]; then - PREV_DEB_FOUND=1 - break - fi done ;; ubuntu) @@ -49,10 +44,6 @@ case ${DISTRIBUTION} in PREVIOUS_DEB=${BASE_URI}/pool/contrib/f/fluent-package/${BASE_NAME} set +e wget ${PREVIOUS_DEB} - if [ $? -eq 0 ]; then - PREV_DEB_FOUND=1 - break - fi done ;; *) @@ -62,18 +53,20 @@ case ${DISTRIBUTION} in esac set -e -if [ $PREV_DEB_FOUND -ne 1 ]; then - echo "The previous version of deb package is not shipped for ${code_name}, so package size check for ${code_name} is disabled" - exit 0 -fi -PREVIOUS_SIZE=$(stat -c %s $BASE_NAME) -THRESHOLD_SIZE=`echo "$PREVIOUS_SIZE * 1.2" | bc -l | cut -d. -f1` DEB=$(find $REPOSITORIES_DIR/${DISTRIBUTION}/pool/${CODE_NAME}/${CHANNEL}/f/fluent-package/fluent-package_*${ARCH}.deb | sort -n | tail -1) CURRENT_SIZE=$(stat -c %s $DEB) +CURRENT_SIZE_MIB=$(echo "scale=2; ${CURRENT_SIZE} / 1024 / 1024" | bc) +if [ ! -e $BASE_NAME ]; then + echo "OLD: Not found (not supported)" + echo "NEW: ${CURRENT_SIZE_MIB} MiB (${CURRENT_SIZE}) : ${DEB}" + exit 0 +fi + +PREVIOUS_SIZE=$(stat -c %s $BASE_NAME) PREVIOUS_SIZE_MIB=$(echo "scale=2; ${PREVIOUS_SIZE} / 1024 / 1024" | bc) -CURRENT_SIZE_MIB=$(echo "scale=2; ${CURRENT_SIZE} / 1024 / 1024" | bc) +THRESHOLD_SIZE=`echo "$PREVIOUS_SIZE * 1.2" | bc -l | cut -d. -f1` echo "OLD: ${PREVIOUS_SIZE_MIB} MiB (${PREVIOUS_SIZE}) : ${BASE_NAME}" echo "NEW: ${CURRENT_SIZE_MIB} MiB (${CURRENT_SIZE}) : ${DEB}" if [ $CURRENT_SIZE -gt $THRESHOLD_SIZE ]; then