This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=f4ca736d4c4aafe71f363606559b6f0b4df33801

commit f4ca736d4c4aafe71f363606559b6f0b4df33801
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Mon Feb 22 18:12:18 2021 +0100

    dpkg: Fix --auto-deconfigure for essential and protected during installation
    
    Only apply the --force-remove-essential and --force-remove-protected
    during package removals, which can only happen due to Conflicts,
    otherwise we cannot solve auto-deconfigurations due to Breaks on essential
    or protected packages during installations or upgrades.
    
    This is a regression when the Breaks field got introduced, as the same
    function that had been used for Conflicts was refactored to be used for
    Breaks, but without taking into account the removal case.
    
    Fixes: commit b301c0e71a5314bb4560111c6cf1602269f6f672
    Reported-by: Julian Andres Klode <j...@debian.org>
    Ref: #983014
---
 src/archives.c                                              |  4 ++--
 tests/Makefile                                              |  2 ++
 tests/t-breaks-essential/Makefile                           | 13 +++++++++++++
 .../{t-breaks => t-breaks-essential}/lib-a-0/DEBIAN/control |  1 +
 .../{t-breaks => t-breaks-essential}/lib-a-1/DEBIAN/control |  1 +
 .../pkg-c => t-breaks-essential/pkg-b}/DEBIAN/control       |  4 ++--
 tests/t-breaks-protected/Makefile                           | 13 +++++++++++++
 .../{t-breaks => t-breaks-protected}/lib-a-0/DEBIAN/control |  1 +
 .../{t-breaks => t-breaks-protected}/lib-a-1/DEBIAN/control |  1 +
 .../pkg-c => t-breaks-protected/pkg-b}/DEBIAN/control       |  4 ++--
 10 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/src/archives.c b/src/archives.c
index 96079ab1f..aa56e9e9c 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -1239,7 +1239,7 @@ try_deconfigure_can(bool (*force_p)(struct deppossi *), 
struct pkginfo *pkg,
     warning(_("ignoring dependency problem with %s:\n%s"), action, why);
     return 2;
   } else if (f_autodeconf) {
-    if (pkg->installed.essential) {
+    if (removal && pkg->installed.essential) {
       if (in_force(FORCE_REMOVE_ESSENTIAL)) {
         warning(_("considering deconfiguration of essential\n"
                   " package %s, to enable %s"),
@@ -1251,7 +1251,7 @@ try_deconfigure_can(bool (*force_p)(struct deppossi *), 
struct pkginfo *pkg,
         return 0;
       }
     }
-    if (pkg->installed.is_protected) {
+    if (removal && pkg->installed.is_protected) {
       if (in_force(FORCE_REMOVE_PROTECTED)) {
         warning(_("considering deconfiguration of protected\n"
                   " package %s, to enable %s"),
diff --git a/tests/Makefile b/tests/Makefile
index 6a52e50e2..3b885f04e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -53,6 +53,8 @@ TESTS_PASS += t-provides-self
 TESTS_PASS += t-provides-arch-implicit
 TESTS_PASS += t-provides-arch-qualified
 TESTS_PASS += t-breaks
+TESTS_PASS += t-breaks-protected
+TESTS_PASS += t-breaks-essential
 TESTS_PASS += t-conflicts
 TESTS_PASS += t-conflict-provide-replace-real
 TESTS_PASS += t-conflict-provide-replace-virtual
diff --git a/tests/t-breaks-essential/Makefile 
b/tests/t-breaks-essential/Makefile
new file mode 100644
index 000000000..ace63f0ef
--- /dev/null
+++ b/tests/t-breaks-essential/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := lib-a-0 lib-a-1 pkg-b
+
+include ../Test.mk
+
+DPKG_OPTIONS += --auto-deconfigure
+
+test-case:
+       $(DPKG_INSTALL) lib-a-0.deb
+       $(DPKG_INSTALL) pkg-b.deb lib-a-1.deb
+
+test-clean:
+       $(DPKG_PURGE) pkg-b
+       $(DPKG_PURGE) --force-remove-essential lib-a
diff --git a/tests/t-breaks/lib-a-0/DEBIAN/control 
b/tests/t-breaks-essential/lib-a-0/DEBIAN/control
similarity index 92%
copy from tests/t-breaks/lib-a-0/DEBIAN/control
copy to tests/t-breaks-essential/lib-a-0/DEBIAN/control
index 241a6fc94..7643fd86b 100644
--- a/tests/t-breaks/lib-a-0/DEBIAN/control
+++ b/tests/t-breaks-essential/lib-a-0/DEBIAN/control
@@ -4,4 +4,5 @@ Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-d...@lists.debian.org>
 Architecture: all
+Essential: yes
 Description: test package - broken package
diff --git a/tests/t-breaks/lib-a-1/DEBIAN/control 
b/tests/t-breaks-essential/lib-a-1/DEBIAN/control
similarity index 92%
copy from tests/t-breaks/lib-a-1/DEBIAN/control
copy to tests/t-breaks-essential/lib-a-1/DEBIAN/control
index e0f19ec94..5c37c036c 100644
--- a/tests/t-breaks/lib-a-1/DEBIAN/control
+++ b/tests/t-breaks-essential/lib-a-1/DEBIAN/control
@@ -4,4 +4,5 @@ Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-d...@lists.debian.org>
 Architecture: all
+Essential: yes
 Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/pkg-c/DEBIAN/control 
b/tests/t-breaks-essential/pkg-b/DEBIAN/control
similarity index 81%
copy from tests/t-breaks-multiarch/pkg-c/DEBIAN/control
copy to tests/t-breaks-essential/pkg-b/DEBIAN/control
index 95ebbacf6..c0da700ab 100644
--- a/tests/t-breaks-multiarch/pkg-c/DEBIAN/control
+++ b/tests/t-breaks-essential/pkg-b/DEBIAN/control
@@ -1,8 +1,8 @@
-Package: pkg-c
+Package: pkg-b
 Version: 0
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-d...@lists.debian.org>
 Architecture: all
-Breaks: lib-b (<< 1)
+Breaks: lib-a (<< 1)
 Description: test package - breaking package
diff --git a/tests/t-breaks-protected/Makefile 
b/tests/t-breaks-protected/Makefile
new file mode 100644
index 000000000..3f85436e6
--- /dev/null
+++ b/tests/t-breaks-protected/Makefile
@@ -0,0 +1,13 @@
+TESTS_DEB := lib-a-0 lib-a-1 pkg-b
+
+include ../Test.mk
+
+DPKG_OPTIONS += --auto-deconfigure
+
+test-case:
+       $(DPKG_INSTALL) lib-a-0.deb
+       $(DPKG_INSTALL) pkg-b.deb lib-a-1.deb
+
+test-clean:
+       $(DPKG_PURGE) pkg-b
+       $(DPKG_PURGE) --force-remove-protected lib-a
diff --git a/tests/t-breaks/lib-a-0/DEBIAN/control 
b/tests/t-breaks-protected/lib-a-0/DEBIAN/control
similarity index 92%
copy from tests/t-breaks/lib-a-0/DEBIAN/control
copy to tests/t-breaks-protected/lib-a-0/DEBIAN/control
index 241a6fc94..7ca516e75 100644
--- a/tests/t-breaks/lib-a-0/DEBIAN/control
+++ b/tests/t-breaks-protected/lib-a-0/DEBIAN/control
@@ -4,4 +4,5 @@ Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-d...@lists.debian.org>
 Architecture: all
+Protected: yes
 Description: test package - broken package
diff --git a/tests/t-breaks/lib-a-1/DEBIAN/control 
b/tests/t-breaks-protected/lib-a-1/DEBIAN/control
similarity index 92%
copy from tests/t-breaks/lib-a-1/DEBIAN/control
copy to tests/t-breaks-protected/lib-a-1/DEBIAN/control
index e0f19ec94..132031814 100644
--- a/tests/t-breaks/lib-a-1/DEBIAN/control
+++ b/tests/t-breaks-protected/lib-a-1/DEBIAN/control
@@ -4,4 +4,5 @@ Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-d...@lists.debian.org>
 Architecture: all
+Protected: yes
 Description: test package - broken package
diff --git a/tests/t-breaks-multiarch/pkg-c/DEBIAN/control 
b/tests/t-breaks-protected/pkg-b/DEBIAN/control
similarity index 81%
copy from tests/t-breaks-multiarch/pkg-c/DEBIAN/control
copy to tests/t-breaks-protected/pkg-b/DEBIAN/control
index 95ebbacf6..c0da700ab 100644
--- a/tests/t-breaks-multiarch/pkg-c/DEBIAN/control
+++ b/tests/t-breaks-protected/pkg-b/DEBIAN/control
@@ -1,8 +1,8 @@
-Package: pkg-c
+Package: pkg-b
 Version: 0
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-d...@lists.debian.org>
 Architecture: all
-Breaks: lib-b (<< 1)
+Breaks: lib-a (<< 1)
 Description: test package - breaking package

-- 
Dpkg.Org's dpkg

Reply via email to