download_size() {
local size
size=$(LC_ALL=C apt-get --yes --print-uris "$@" \
- | sed -n '/^Need to get / {s///; s/B\/.*//; p}')
+ | sed -n '/^Need to get / {s///; s/B.*//; p}')
- size_to_mb $size
+ size_to_mb "${size}B"
}
installed_size() {
size=$(apt-cache show $package \
| awk '$1 == "Installed-Size:" {print $2; exit}')
- size_to_mb "${size}k"
+ size_to_mb "${size}kB"
}
size_to_mb() {
size=0;
fi
- if [ "${size%k}" != "$size" ]; then
- size=$(round ${size%k})
+ if [ "${size%kB}" != "$size" ]; then
+ size=$(round ${size%kB})
size=$(($size/1024+1))
- elif [ "${size%M}" != "$size" ]; then
- size=$(round ${size%M})
- elif [ "${size%G}" != "$size" ]; then
- size=$(round ${size%G})
+ elif [ "${size%MB}" != "$size" ]; then
+ size=$(round ${size%MB})
+ elif [ "${size%GB}" != "$size" ]; then
+ size=$(round ${size%GB})
size=$(($size*1024))
- elif [ "${size%[0-9]}" != "$size" ]; then
- size=$(round $size)
+ elif [ "${size%[0-9]B}" != "$size" ]; then
+ size=$(round ${size%B})
size=$(($size/1024/1024+1))
else
log "unrecognized size unit: $size"