# Zoran 'jelly' Dzelajlija <jelly@srce.hr>
notice () {
- dialog --backtitle "$title" --msgbox "$*" 18 75
+ LC_MESSAGES=hr_HR dialog --backtitle "$title" --msgbox "$*" 18 75
}
first_warning () {
- dialog --backtitle "$title" --yesno "$msg_first_warning" 18 75
+ LC_MESSAGES=hr_HR dialog --backtitle "$title" --yesno "$msg_first_warning" 18 75
+ if [ $? -ne 0 ]; then
+ log "Upgrade canceled."
+ exit 0
+ fi
}
pkg() {
}
}
-update() {
+apt_update() {
log "Running apt-get update ..."
apt-get -y$s update || {
apt-get -yf install
apt-get -y$s update
}
apt-get autoclean
+}
+
+apt_download() {
+ log "Running apt-get download ..."
apt-get -dy$s dist-upgrade
}
}
}
+remove_x() {
+ LC_MESSAGES=hr_HR dialog --backtitle "$title" --yesno "$msg_remove_x" 18 75
+ if [ $? -eq 0 ]; then
+ log "Removing X Window System"
+ pkgrm xlibs
+ else
+ log "Skipping X Window System removal"
+ fi
+}
+
remove_bloat() {
local to_remove add_this i j n text to_show cmd tmpfile installed
local update_selections pkgs_to_deselect pkgs_to_remove oldifs pkglist
[ -z "$to_show" ] && return 0
test $n -gt 8 && n=8
tmpfile=$(mktemp /var/lib/carnet-upgrade/dialog-tmp.XXXXXX)
- cmd="dialog --nocancel --backtitle \""$title"\" --checklist \""$text"\" 20 75 $n $to_show"
+ cmd="LC_MESSAGES=hr_HR dialog --nocancel --backtitle \""$title"\" --checklist \""$text"\" 20 75 $n $to_show"
[ "$DEBUG" ] && set +x
eval $cmd 2> $tmpfile
[ "$DEBUG" ] && set -x
pkgadd dpkg apt debconf python-apt
dpkg-reconfigure carnet-keyring srce-keyring
- update
+ apt_update
}
# remove skey (not supported anymore)
EOF
}
-check_disk_space() {
- local available_disk_space
- available_disk_space=$(df -m /var|tail -1|awk '{print $4}')
- if [ $available_disk_space -lt $min_var_space ]; then
- log "carnet-upgrade aborted: not enough space on /var (need ${min_var_space}MB)"
- notice "Premalo mjesta na /var particiji. Potrebno je imati barem ${min_var_space}MB."
+check_archives_space() {
+ local available_disk_space archives_size
+ available_disk_space=$(free_space /var/cache/apt/archives/)
+ archives_size=$(download_size dist-upgrade)
+
+ log "Archives space: ${available_disk_space}MB"
+ log "Download size: ${archives_size}MB"
+
+ if [ $available_disk_space -lt $archives_size ]; then
+ log "carnet-upgrade aborted: not enough space in /var/cache/apt/archives/ (have ${available_disk_space}MB, need ${archives_size}MB)"
+ notice "Premalo slobodnog mjesta u /var/cache/apt/archives/ za skidanje paketa (potrebno je barem ${archives_size}MB). Procitajte poglavlje 'Izvanredne situacije' u dokumentaciji."
+ exit 1
+ fi
+}
+
+check_kernel_space() {
+ local available_disk_space kernel_size
+ available_disk_space=$(free_space /)
+ kernel_size=$(installed_size kernel-2.6-cn)
+
+ log "Free space in /: ${available_disk_space}MB"
+ log "Kernel size: ${kernel_size}MB"
+
+ if LC_ALL=C apt-get --yes --print-uris install kernel-2.6-cn \
+ | grep -q '^kernel-2.6-cn is already the newest version.$'
+ then
+ log "Not checking free space in /: kernel-2.6-cn already installed"
+ return
+ fi
+
+ if [ $available_disk_space -lt $kernel_size ]; then
+ log "carnet-upgrade aborted: not enough space in / (have ${available_disk_space}MB, need ${kernel_size}MB)"
+ notice "Premalo mjesta u / za instalaciju kernela (potrebno je barem ${kernel_size}MB). Procitajte poglavlje 'Izvanredne situacije' u dokumentaciji."
exit 1
fi
}
+
+free_space() {
+ df --portability --block-size=1M "$1" | tail -1 | awk '{print $4}'
+}
+
+download_size() {
+ local size
+ size=$(LC_ALL=C apt-get --yes --print-uris "$@" \
+ | sed -n '/^Need to get / {s///; s/B\/.*//; p}')
+
+ size_to_mb $size
+}
+
+installed_size() {
+ local package size
+ package=$1
+ size=$(apt-cache show $package \
+ | awk '$1 == "Installed-Size:" {print $2; exit}')
+
+ size_to_mb "${size}k"
+}
+
+size_to_mb() {
+ local size
+ size=$1
+ if [ -z "$size" ]; then
+ size=0;
+ fi
+
+ if [ "${size%k}" != "$size" ]; then
+ size=$(round ${size%k})
+ size=$(($size/1024+1))
+ elif [ "${size%M}" != "$size" ]; then
+ size=$(round ${size%M})
+ elif [ "${size%G}" != "$size" ]; then
+ size=$(round ${size%G})
+ size=$(($size*1024))
+ elif [ "${size%[0-9]}" != "$size" ]; then
+ size=$(round $size)
+ size=$(($size/1024/1024+1))
+ else
+ log "unrecognized size unit: $size"
+ return 1
+ fi
+
+ echo $size
+}
+
+round() {
+ local num
+ num=$1
+
+ if [ "${num%.*}" != "$num" ]; then
+ num=${num%.*}
+ num=$(($num+1))
+ fi
+
+ echo $num
+}