Skip to content

Commit

Permalink
deb: check with downloaded file
Browse files Browse the repository at this point in the history
Signed-off-by: Kentaro Hayashi <[email protected]>
  • Loading branch information
kenhys committed Jun 24, 2024
1 parent 96d54bc commit 50cfbd5
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions fluent-package/apt/pkgsize-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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)
Expand All @@ -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
;;
*)
Expand All @@ -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
Expand Down

0 comments on commit 50cfbd5

Please sign in to comment.