Просмотр исходного кода

Remove invalid master alternatives on upgrade

update-alternatives was very laxist in its past and allowed things that
are now rightfully forbidden. For example, you can't use alternatives as
slave when it's a master alternative already. However there is sometimes
cruft files in /var/lib/dpkg/alternatives/ due to historical changes (or
bugs) that incorrectly trigger this check.

We avoid this problem by removing the conflicting files on upgrade.
Raphael Hertzog лет назад: 17
Родитель
Сommit
057523d0a8
2 измененных файлов с 17 добавлено и 0 удалено
  1. 2 0
      debian/changelog
  2. 15 0
      debian/dpkg.preinst

+ 2 - 0
debian/changelog

@@ -6,6 +6,8 @@ dpkg (1.15.3) UNRELEASED; urgency=low
   [ Raphael Hertzog ]
   * Unset TAR_OPTIONS when creating/extracting tar archives for source
     packages. Closes: #530860
+  * Add cleanup of known invalid (master) alternatives in preinst script.
+    Closes: #530633, #531611
 
   [ Updated dpkg translations ]
   * Simplified Chinese (Deng Xiyue). Closes: #531387

+ 15 - 0
debian/dpkg.preinst

@@ -26,12 +26,27 @@ upgrade_dpkg_non_conffile()
     fi
 }
 
+clean_alternative()
+{
+    ALTDIR="/var/lib/dpkg/alternatives"
+    if [ -e "$ALTDIR/$2" ]; then
+        if [ -e "$ALTDIR/$1" ] && grep -q "^$2$" "$ALTDIR/$1"; then
+            echo "Removing conflicting alternative $2 ..."
+            rm -f "$ALTDIR/$2"
+        fi
+    fi
+}
 
 case "$1" in
     install)
 	;;
 
     upgrade)
+        # Cleanup bad alternatives that would choke with new
+        # update-alternatives (see #530633, #531611)
+        clean_alternative x-terminal-emulator x-terminal-emulator.1.gz
+        clean_alternative x-session-manager x-session-manager.1.gz
+
 	case "$2" in
 	    # Upgrade from pre-conffile dpkg.cfg
 	    1.9.21 | 1.10.* )