Package: dpkg Version: 1.18.23 As discussed on irc yesterday there is a bug in dpkg when a conffile moves from pkg-a to pkg-b and the "dpkg --root=/dir" option is used.
The Ubuntu bugreport is https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1673247 Attached is a patch for the dpkg-tests.git repository that reproduces the issue and a patch (from Guillem Jover) that fixes the issue. I tested the patch both against the minimal test-case and also against the "real" issue we were seeing on the Ubuntu live-cd with ubiquity. Thanks, Michael
>From 4da6ee05156257972fc461b9e2b2634026354cc8 Mon Sep 17 00:00:00 2001 From: Michael Vogt <m...@ubuntu.com> Date: Fri, 17 Mar 2017 08:36:44 +0100 Subject: [PATCH] add test for LP:1673247 --- Makefile | 1 + t-conffile-root-option/Makefile | 30 ++++++++++++++++++++++ .../pkg-conff-a.v1/DEBIAN/conffiles | 1 + .../pkg-conff-a.v1/DEBIAN/control | 8 ++++++ .../pkg-conff-a.v1/test-conffile | 1 + .../pkg-conff-a.v2/DEBIAN/control | 8 ++++++ .../pkg-conff-b.v1/DEBIAN/control | 8 ++++++ .../pkg-conff-b.v2/DEBIAN/conffiles | 1 + .../pkg-conff-b.v2/DEBIAN/control | 8 ++++++ .../pkg-conff-b.v2/test-conffile | 1 + 10 files changed, 67 insertions(+) create mode 100644 t-conffile-root-option/Makefile create mode 100644 t-conffile-root-option/pkg-conff-a.v1/DEBIAN/conffiles create mode 100644 t-conffile-root-option/pkg-conff-a.v1/DEBIAN/control create mode 100644 t-conffile-root-option/pkg-conff-a.v1/test-conffile create mode 100644 t-conffile-root-option/pkg-conff-a.v2/DEBIAN/control create mode 100644 t-conffile-root-option/pkg-conff-b.v1/DEBIAN/control create mode 100644 t-conffile-root-option/pkg-conff-b.v2/DEBIAN/conffiles create mode 100644 t-conffile-root-option/pkg-conff-b.v2/DEBIAN/control create mode 100644 t-conffile-root-option/pkg-conff-b.v2/test-conffile diff --git a/Makefile b/Makefile index 996fab1..75a34b9 100644 --- a/Makefile +++ b/Makefile @@ -137,6 +137,7 @@ TESTS_PASS += t-substvars TESTS_PASS += t-failinst-failrm TESTS_PASS += t-dir-extension-check TESTS_PASS += t-multiarch +TESTS_PASS += t-conffile-root-option ifneq (,$(filter test-all,$(DPKG_TESTSUITE_OPTIONS))) TESTS := $(TESTS_PASS) $(TESTS_FAIL) $(TESTS_MANUAL) diff --git a/t-conffile-root-option/Makefile b/t-conffile-root-option/Makefile new file mode 100644 index 0000000..bbbba0a --- /dev/null +++ b/t-conffile-root-option/Makefile @@ -0,0 +1,30 @@ +TESTS_DEB := pkg-conff-a.v1 pkg-conff-a.v2 pkg-conff-b.v1 pkg-conff-b.v2 + +include ../Test.mk + +TEST_CASES += test-conffile-travels-packages-no-rootdir test-conffile-travels-packages-rootdir + +test-case: $(TEST_CASES) + +test-conffile-travels-packages-no-rootdir: + # install base version + $(DPKG_INSTALL) pkg-conff-a.v1.deb pkg-conff-b.v1.deb + # instlal update, conffile traves from a to b + $(DPKG_INSTALL) pkg-conff-a.v2.deb pkg-conff-b.v2.deb + -$(DPKG_PURGE) pkg-conff-b + -$(DPKG_PURGE) pkg-conff-a + +test-conffile-travels-packages-rootdir: + # install base version + mkdir -p $(CURDIR)/target/var/lib/dpkg/info + mkdir -p $(CURDIR)/target/var/lib/dpkg/updates + touch $(CURDIR)/target/var/lib/dpkg/status + $(DPKG_INSTALL) --root=$(CURDIR)/target pkg-conff-a.v1.deb pkg-conff-b.v1.deb + # instlal update, conffile traves from a to b + $(DPKG_INSTALL) --root=$(CURDIR)/target pkg-conff-a.v2.deb pkg-conff-b.v2.deb + -$(DPKG_PURGE) --root=$(CURDIR)/target pkg-conff-b + -$(DPKG_PURGE) --root=$(CURDIR)/target pkg-conff-a + +test-clean: + -$(DPKG_PURGE) pkg-conff-a pkg-conff-b + -rm -rf $(CURDIR)/target diff --git a/t-conffile-root-option/pkg-conff-a.v1/DEBIAN/conffiles b/t-conffile-root-option/pkg-conff-a.v1/DEBIAN/conffiles new file mode 100644 index 0000000..4fad7e9 --- /dev/null +++ b/t-conffile-root-option/pkg-conff-a.v1/DEBIAN/conffiles @@ -0,0 +1 @@ +/test-conffile diff --git a/t-conffile-root-option/pkg-conff-a.v1/DEBIAN/control b/t-conffile-root-option/pkg-conff-a.v1/DEBIAN/control new file mode 100644 index 0000000..e97fe2e --- /dev/null +++ b/t-conffile-root-option/pkg-conff-a.v1/DEBIAN/control @@ -0,0 +1,8 @@ +Package: pkg-conff-a +Version: 1 +Section: test +Priority: extra +Maintainer: Dpkg Developers <debian-d...@lists.debian.org> +Architecture: all +Description: test package - conflicting conffile + diff --git a/t-conffile-root-option/pkg-conff-a.v1/test-conffile b/t-conffile-root-option/pkg-conff-a.v1/test-conffile new file mode 100644 index 0000000..024da49 --- /dev/null +++ b/t-conffile-root-option/pkg-conff-a.v1/test-conffile @@ -0,0 +1 @@ +pkg-conff-a diff --git a/t-conffile-root-option/pkg-conff-a.v2/DEBIAN/control b/t-conffile-root-option/pkg-conff-a.v2/DEBIAN/control new file mode 100644 index 0000000..1174243 --- /dev/null +++ b/t-conffile-root-option/pkg-conff-a.v2/DEBIAN/control @@ -0,0 +1,8 @@ +Package: pkg-conff-a +Version: 2 +Section: test +Priority: extra +Maintainer: Dpkg Developers <debian-d...@lists.debian.org> +Architecture: all +Description: test package - conflicting conffile + diff --git a/t-conffile-root-option/pkg-conff-b.v1/DEBIAN/control b/t-conffile-root-option/pkg-conff-b.v1/DEBIAN/control new file mode 100644 index 0000000..6281f4d --- /dev/null +++ b/t-conffile-root-option/pkg-conff-b.v1/DEBIAN/control @@ -0,0 +1,8 @@ +Package: pkg-conff-b +Version: 1 +Section: test +Priority: extra +Maintainer: Dpkg Developers <debian-d...@lists.debian.org> +Architecture: all +Description: test package - conflicting conffile + diff --git a/t-conffile-root-option/pkg-conff-b.v2/DEBIAN/conffiles b/t-conffile-root-option/pkg-conff-b.v2/DEBIAN/conffiles new file mode 100644 index 0000000..4fad7e9 --- /dev/null +++ b/t-conffile-root-option/pkg-conff-b.v2/DEBIAN/conffiles @@ -0,0 +1 @@ +/test-conffile diff --git a/t-conffile-root-option/pkg-conff-b.v2/DEBIAN/control b/t-conffile-root-option/pkg-conff-b.v2/DEBIAN/control new file mode 100644 index 0000000..7eddd27 --- /dev/null +++ b/t-conffile-root-option/pkg-conff-b.v2/DEBIAN/control @@ -0,0 +1,8 @@ +Package: pkg-conff-b +Version: 2 +Section: test +Priority: extra +Maintainer: Dpkg Developers <debian-d...@lists.debian.org> +Architecture: all +Description: test package - conflicting conffile + diff --git a/t-conffile-root-option/pkg-conff-b.v2/test-conffile b/t-conffile-root-option/pkg-conff-b.v2/test-conffile new file mode 100644 index 0000000..006fbc7 --- /dev/null +++ b/t-conffile-root-option/pkg-conff-b.v2/test-conffile @@ -0,0 +1 @@ +pkg-conff-b -- 2.9.3
diff --git i/src/archives.c w/src/archives.c index d91a07588..5b7c575f5 100644 --- i/src/archives.c +++ w/src/archives.c @@ -875,14 +875,7 @@ tarobject(void *ctx, struct tar_entry *ti) conff = conff->next) { if (!conff->obsolete) continue; - if (stat(conff->name, &stabtmp)) { - if (errno == ENOENT || errno == ENOTDIR || errno == ELOOP) - continue; - else - ohshite(_("cannot stat file '%s'"), conff->name); - } - if (stabtmp.st_dev == stab.st_dev && - stabtmp.st_ino == stab.st_ino) + if (strcmp(conff->name, nifd->namenode->name) == 0) break; } if (conff) {