X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Ffunctions.sh;h=0af728bf701decf0cbe1aadd0dfe5e9b1084cb6b;hb=a97320a33fcf92f0c683b0830dbf700b88726a99;hp=3830ea5dbf36cd8dade2b4e49a8d61707572303d;hpb=ee97dd6a97fcb7ebf5f48f28fabcd18af9fcc408;p=carnet-upgrade.git diff --git a/src/functions.sh b/src/functions.sh index 3830ea5..0af728b 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -865,7 +865,7 @@ download_size() { size=$(LC_ALL=C apt-get --yes --print-uris "$@" \ | sed -n '/^Need to get / {s///; s/B\/.*//; p}') - size_to_mb $size + size_to_mb "${size}B" } installed_size() { @@ -874,7 +874,7 @@ 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() { @@ -884,16 +884,16 @@ 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"