Use dpkg-divert to disable apt-listchanges.
[carnet-upgrade.git] / src / functions.sh
index d3bd0de..25ef535 100644 (file)
@@ -479,13 +479,27 @@ restore_configs () {
   fi
 }
 
-# temporary remove listchanges packages to reduce clutter during upgrade
-disable_apt_listchanges () {
-  for p in apt-listchanges apt-listchanges-cn; do
-      if pkg $p; then
-          pkgrm $p
-          post_upgrade pkgadd $p
-      fi
+# temporary disable listchanges packages to reduce clutter during upgrade
+apt_listchanges () {
+  local file command=$1
+
+  for file in /etc/apt/apt.conf.d/20listchanges \
+              /etc/apt/apt.conf.d/20listchanges-cn
+  do
+      case $command in
+           disable)
+               if [ -f $file ]; then
+                   dpkg-divert --local --rename --divert $file.$backup_ext \
+                               --add $file || true
+               fi
+               ;;
+
+           enable)
+               if [ -f $file.$backup_ext ]; then
+                   dpkg-divert --remove $file || true
+               fi
+               ;;
+     esac
   done
 }