Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added a script to check the size of all images in the installation package. #238

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions build/installer/check_image_size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

convert_to_memory_unit() {
local num=$1
local unit="B"
if [[ $num -ge 1073741824 ]]; then
num=`echo $num | awk '{ printf("%.2lf",$1/1073741824) }'`
unit="GB"
elif [[ $num -ge 1048576 ]]; then
num=`echo $num | awk '{ printf("%.2lf",$1/1048576) }'`
unit="MB"
elif [[ $num -ge 1024 ]]; then
num=`echo $num | awk '{ printf("%.2lf",$1/1024) }'`
unit="KB"
fi
echo "$num$unit"
}


>image.size.tmp.txt
>image.size.raw.txt
>image.size.txt

for path in `ls images/*.tar.gz`
do
image=`basename $path`
rm -rf tmp
mkdir tmp
cp images/$image tmp/$image

cd tmp
size=`ls -l | awk '{ print $5 }' | tail --line 1`
echo $image
tar -xzf $image
name=`cat manifest.json | awk -F"RepoTags" '{ print $2 }' | awk -F"\"" '{ print $3 }'`
cd ..

echo -e $size"\t"$name >> image.size.tmp.txt
done

sort -k1 -nr image.size.tmp.txt > image.size.raw.txt
rm image.size.tmp.txt

while read size image
do
echo -e $(convert_to_memory_unit $size)"\t"$image >> image.size.txt
done < image.size.raw.txt
Loading