available_disk_space=$(free_space /var/cache/apt/archives/)
archives_size=$(download_size dist-upgrade)
+ if [ $? -ne 0 ]; then
+ log "Failed to get download size, skipping check."
+ return 0
+ fi
+
log "Archives space: ${available_disk_space}MB"
log "Download size: ${archives_size}MB"
available_disk_space=$(free_space /)
kernel_size=$(installed_size kernel-2.6-cn)
+ if [ $? -ne 0 ]; then
+ log "Failed to get installed size, skipping check."
+ return 0
+ fi
+
log "Free space in /: ${available_disk_space}MB"
log "Kernel size: ${kernel_size}MB"
download_size() {
local size
size=$(LC_ALL=C apt-get --yes --print-uris "$@" \
- | sed -n '/^Need to get / {s///; s/B.*//; p}')
+ | grep '^Need to get ')
+
+ if [ $? -ne 0 ]; then
+ log "Failed to get download size for 'apt-get $@'."
+ return 1
+ fi
+
+ size=${size#Need to get }
+ size=${size%%B*}
size_to_mb "${size}B"
}
local package size
package=$1
size=$(apt-cache show $package \
- | awk '$1 == "Installed-Size:" {print $2; exit}')
+ | grep '^Installed-Size:')
+
+ if [ $? -ne 0 ]; then
+ log "Failed to get installed size for '$package'."
+ return 1
+ fi
+
+ size=${size#*: }
size_to_mb "${size}kB"
}