abuild: show package size in human readable format

This commit is contained in:
Natanael Copa 2012-10-04 06:52:19 +00:00
parent 1fa61905d1
commit 9b3f778971

View File

@ -995,8 +995,16 @@ scan_shared_objects() {
done > "$controldir"/.needs-so
}
# read size in bytes from stdin and show as human readable
human_size() {
awk '{ split("B KB MB GB TB PB", type)
for(i=5; y < 1; i--)
y = $1 / (2**(10*i))
printf("%.1f %s\n", y, type[i+2]) }'
}
create_apks() {
local file= dir= name= ver= apk= datadir=
local file= dir= name= ver= apk= datadir= size=
getpkgver || return 1
mkdir -p "$PKGDEST"
if [ "$arch" != "noarch" ] && ! options_has "!tracedeps"; then
@ -1012,11 +1020,13 @@ create_apks() {
dir="${file%/.PKGINFO}"
name=$(pkginfo_val pkgname $file)
ver=$(pkginfo_val pkgver $file)
size=$(pkginfo_val size $file | human_size)
apk=$name-$ver.apk
datadir="$pkgbasedir"/$name
subpkgname=$name
trace_apk_deps "$name" "$dir" || return 1
msg "Package size: ${size}"
msg "Compressing data..."
(
cd "$datadir"