From: Valentin Vidic Date: Fri, 20 Jun 2008 13:52:09 +0000 (+0200) Subject: Remove X if installed. X-Git-Tag: debian/4.0.3~1 X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=commitdiff_plain;h=ee97dd6a97fcb7ebf5f48f28fabcd18af9fcc408;p=carnet-upgrade.git Remove X if installed. Check for free space in / for kernel upgrade. Check for free space in /var for package download. Update package versions. Use hr_HR localization in dialog. --- diff --git a/src/actions/main.queue b/src/actions/main.queue index a6674d0..7e8ae18 100644 --- a/src/actions/main.queue +++ b/src/actions/main.queue @@ -2,6 +2,7 @@ true first_warning true check_apache_version true check_upgrade +pkg xlibs remove_x true remove_bloat true apt_listchanges disable true comment_force_overwrite # ruzna opcija za dpkg @@ -12,8 +13,10 @@ true remove_group_proc # calls post_upgrade add_group_proc pkg slapd backup_slapd_db true backup_etc_dir # etc i drugo true create_sources_list -true update # apt-get update & download -true check_disk_space +true apt_update +true check_archives_space +true check_kernel_space +true apt_download # skini pakete ! debconf_priority check debconf_priority set # utisaj debconf pkg monit disable_monit true upgrade_libc diff --git a/src/data.sh b/src/data.sh index 51a8f09..ab5a6ad 100644 --- a/src/data.sh +++ b/src/data.sh @@ -1,6 +1,3 @@ -# Minimum free space on /var after the download, in MB -min_var_space=50 - # Backup extension backup_ext=cn4-upgrade @@ -10,13 +7,14 @@ needed_versions=' amavisd-cn 2:20030616p10-12 aosi-aai 1.6.5 aosi-www-aai 1.5.9 -apache2-cn 2.0-1 +apache2-cn 2.0-3 bind9-cn 2:9.2.4-1 clamav-cn 2:0.92.1-1 dovecot-cn 0.99.14-0 freeradius-aai 1.1.7-0 iptables-cn 2:1.2.11-6 kernel-2.6-cn 2.6.24.2-2 +monit-cn 1:4.8.1-6 mysql-cn 2:4.0.24-10.5 ntp-cn 2:4.2.0a+stable-2sarge1.1 openldap-aai 2.2.23-13 diff --git a/src/functions.sh b/src/functions.sh index 4775de3..3830ea5 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -2,11 +2,15 @@ # Zoran 'jelly' Dzelajlija 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() { @@ -109,13 +113,17 @@ pkgrm () { } } -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 } @@ -127,6 +135,16 @@ 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 @@ -151,7 +169,7 @@ remove_bloat() { [ -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 @@ -596,7 +614,7 @@ install_keyrings () { pkgadd dpkg apt debconf python-apt dpkg-reconfigure carnet-keyring srce-keyring - update + apt_update } # remove skey (not supported anymore) @@ -801,12 +819,98 @@ Debian GNU/Linux 4.0 (CARNet Debian 4.0) %h 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 +} diff --git a/src/messages.sh b/src/messages.sh index 011615b..a133b08 100644 --- a/src/messages.sh +++ b/src/messages.sh @@ -17,6 +17,13 @@ koja se nalazi u: Zelite li nastaviti?" +msg_remove_x="Na racunalu je pronadjena instalacija KDE, GNOME ili \ +X Window System grafickog okruzenja koji nisu nuzni za normalan rad \ +posluzitelja. Uklanjanje ovih aplikacija ubrzat ce proceduru nadogradnje i \ +smanjiti zauzece diskovnog prostora. + +Zelite li UKLONITI navedene aplikacije?" + msg_remove_bloat="Prethodna inacica distribucije, CARNet Debian 2, donosila je neke pakete koji nisu nuzni za normalan rad posluzitelja. Uklanjanje ovih aplikacija ubrzat ce proceduru nadogradnje i smanjiti zauzece