From: Valentin Vidic Date: Thu, 28 Aug 2008 11:01:57 +0000 (+0200) Subject: Handle errors in download and kernel size checks. X-Git-Tag: debian/4.0.6~8 X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=commitdiff_plain;h=6f4f76a38153d21d9c8d3034f997d28d7f2fba83;p=carnet-upgrade.git Handle errors in download and kernel size checks. --- diff --git a/src/functions.sh b/src/functions.sh index 0ddd941..5fce053 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -831,6 +831,11 @@ check_archives_space() { 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" @@ -846,6 +851,11 @@ check_kernel_space() { 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" @@ -870,7 +880,15 @@ free_space() { 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" } @@ -879,7 +897,14 @@ installed_size() { 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" }