Minor fixes to documentation and code.
[carnet-upgrade.git] / src / functions.sh
index 3830ea5..0af728b 100644 (file)
@@ -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"