Don't overwrite user modified issue files.
[carnet-upgrade.git] / src / functions.sh
index b931651..9040822 100644 (file)
@@ -157,7 +157,7 @@ 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
+    pkgrm x11-common
   else
     log "Skipping X Window System removal"
   fi
@@ -603,6 +603,13 @@ upgrade () {
   pkgadd_if_installed $packages
 }
 
+# install packages introduced in this release
+install_new () {
+  if [ "$new_packages" ]; then
+    pkgadd $new_packages
+  fi
+}
+
 # funkcija utrpa ispravan sources.list
 create_sources_list () {
     local sl sl_new
@@ -1177,38 +1184,6 @@ get_variable () {
   echo $val
 }
 
-# preserve mail location on upgrade
-upgrade_dovecot () {
-  local default_mail_env mail_location
-
-  # check if already upgraded
-  if ! pkg dovecot-common lt 1.0; then
-      return
-  fi
-
-  # save old mail location
-  default_mail_env=$(get_variable default_mail_env /etc/dovecot/dovecot.conf)
-
-  # silently upgrade package
-  restore_file /etc/dovecot/dovecot.conf
-  pkgadd dovecot-cn
-
-  # insert old mail location
-  mail_location=$(get_variable mail_location /etc/dovecot/dovecot.conf)
-  if [ "$default_mail_env" -a ! "$mail_location" ]; then
-      check_and_sed '^#mail_location[[:space:]]*=' \
-                   "s|#mail_location[[:space:]]*=.*|mail_location = $default_mail_env|" /etc/dovecot/dovecot.conf || return 0
-
-      if [ -x /etc/init.d/dovecot ]; then
-          if [ -x /usr/sbin/invoke-rc.d ]; then
-              /usr/sbin/invoke-rc.d dovecot restart
-          else
-              /etc/init.d/dovecot restart
-          fi
-      fi
-  fi
-}
-
 # restore munin configs for silent upgrade
 upgrade_munin () {
   local config backup hostname domain
@@ -1265,15 +1240,22 @@ comment_force_overwrite () {
   fi
 }
 
+# try not to overwrite user modified issue files
 fix_issue () {
-  cat > /etc/issue <<EOF
+  if cmp /etc/issue $cnup/files/etc/issue.expect.lenny >/dev/null; then
+    cp -av /etc/issue /etc/issue.$backup_ext
+    cat > /etc/issue <<EOF
 Debian GNU/Linux 5.0 (CARNet Debian 5.0) \\n \\l
 
 EOF
+  fi
 
-  cat > /etc/issue.net <<EOF
+  if cmp /etc/issue.net $cnup/files/etc/issue.net.expect.lenny >/dev/null; then
+    cp -av /etc/issue.net /etc/issue.net.$backup_ext
+    cat > /etc/issue.net <<EOF
 Debian GNU/Linux 5.0 (CARNet Debian 5.0) %h
 EOF
+  fi
 }
 
 check_archives_space() {
@@ -1316,7 +1298,7 @@ check_kernel_space() {
   log "Kernel package: $pkg"
   log "Kernel size: ${kernel_size}MB"
 
-  if LC_ALL=C apt-get --yes --print-uris install kernel-2.6-cn \
+  if LC_ALL=C apt-get -s 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"
@@ -1401,3 +1383,12 @@ round() {
 
   echo $num
 }
+
+# make sure carnet-upgrade doesn't get upgraded until the end
+hold_carnet_upgrade() {
+  echo carnet-upgrade hold | dpkg --set-selections
+}
+
+release_carnet_upgrade() {
+  echo carnet-upgrade install | dpkg --set-selections
+}