Debian Policy forbids info files not mentioned in Policy, except if their
names start with an underscore to flag them as non-critical.
---
 src/main/unpack.c          | 29 +++++++++++++++++++++++++++++
 tests/t-multiarch/Makefile | 24 ++++++++++++------------
 2 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/src/main/unpack.c b/src/main/unpack.c
index 9048f6fb0..446f8d4c5 100644
--- a/src/main/unpack.c
+++ b/src/main/unpack.c
@@ -496,9 +496,23 @@ pkg_infodb_update_file(const char *filename, const char 
*filetype)
 static void
 pkg_infodb_update(struct pkginfo *pkg, char *cidir, char *cidirrest)
 {
+  char const *const known_info_names[] =
+  {
+    "conffiles",
+    "control",
+    "preinst",
+    "prerm",
+    "postinst",
+    "postrm",
+    "triggers"
+  };
+  size_t const num_known_info_names =
+      sizeof known_info_names / sizeof known_info_names[0];
+
   struct match_node *match_node;
   DIR *dsd;
   struct dirent *de;
+  bool known;
 
   /* Deallocate the match list in case we aborted previously. */
   while ((match_node = match_head)) {
@@ -567,6 +581,21 @@ pkg_infodb_update(struct pkginfo *pkg, char *cidir, char 
*cidirrest)
       continue;
     }
 
+    /* if the info file name starts with an underscore, then it can be
+     * safely ignored */
+    known = (de->d_name[0] == '_');
+
+    /* compare against list of files we understand */
+    for (size_t i = 0; !known && (i < num_known_info_names); ++i)
+      if (strcmp(de->d_name, known_info_names[i]) == 0)
+        known = true;
+
+    /* TODO: error? force option? */
+    if (!known)
+      warning(_("package %s contains unknown info file '%s'"),
+              pkgbin_name(pkg, &pkg->available, pnaw_nonambig),
+              de->d_name);
+
     /* Right, install it */
     newinfofilename = pkg_infodb_get_file(pkg, &pkg->available, de->d_name);
     if (rename(cidir, newinfofilename))
diff --git a/tests/t-multiarch/Makefile b/tests/t-multiarch/Makefile
index 31449437b..99e09c9e9 100644
--- a/tests/t-multiarch/Makefile
+++ b/tests/t-multiarch/Makefile
@@ -787,39 +787,39 @@ test-dpkg-output: ma-setup
        $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH) 
pkg-ma-shared-files:$(FOREIGN_ARCH)
 
 pkg-ma-db-layout_1.0_$(NATIVE_ARCH):: pkg-template
-       touch pkg-ma-db-layout_1.0_$(NATIVE_ARCH)/DEBIAN/foo-1
+       touch pkg-ma-db-layout_1.0_$(NATIVE_ARCH)/DEBIAN/_foo-1
 
 pkg-ma-db-layout_2.0_$(NATIVE_ARCH):: pkg-template
-       touch pkg-ma-db-layout_2.0_$(NATIVE_ARCH)/DEBIAN/foo-2
+       touch pkg-ma-db-layout_2.0_$(NATIVE_ARCH)/DEBIAN/_foo-2
 
 test-db-layout: ma-setup
        $(DPKG_INSTALL) pkg-ma-db-layout_1.0_$(NATIVE_ARCH).deb
        test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
-       test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-1"
+       test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout._foo-1"
        $(DPKG_INSTALL) pkg-ma-db-layout_2.0_$(NATIVE_ARCH).deb
        ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
-       ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-1"
+       ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout._foo-1"
        test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).list"
-       test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).foo-2"
+       test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH)._foo-2"
        $(DPKG_INSTALL) pkg-ma-db-layout_1.0_$(NATIVE_ARCH).deb
        test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
-       test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-1"
+       test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout._foo-1"
        ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).list"
-       ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).foo-2"
+       ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH)._foo-2"
        $(DPKG_PURGE) pkg-ma-db-layout
        # Test the upgrade of the db layout
        $(DPKG_INSTALL) pkg-ma-db-layout_2.0_$(NATIVE_ARCH).deb
        rm -f "$(DPKG_ADMINDIR)/info/format"
        mv "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).list" 
"$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
-       mv "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).foo-2" 
"$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-2"
-       $(call stdout_has,$(DPKG_QUERY) --control-path pkg-ma-db-layout 
foo-2,/pkg-ma-db-layout\.foo-2$$)
+       mv "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH)._foo-2" 
"$(DPKG_ADMINDIR)/info/pkg-ma-db-layout._foo-2"
+       $(call stdout_has,$(DPKG_QUERY) --control-path pkg-ma-db-layout 
_foo-2,/pkg-ma-db-layout\._foo-2$$)
        $(DPKG_CONFIGURE) -a
        grep -q "^1$$" "$(DPKG_ADMINDIR)/info/format"
        test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).list"
-       test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH).foo-2"
+       test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout:$(NATIVE_ARCH)._foo-2"
        ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.list"
-       ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout.foo-2"
-       $(call stdout_has,$(DPKG_QUERY) --control-path pkg-ma-db-layout 
foo-2,/pkg-ma-db-layout:$(NATIVE_ARCH)\.foo-2$$)
+       ! test -e "$(DPKG_ADMINDIR)/info/pkg-ma-db-layout._foo-2"
+       $(call stdout_has,$(DPKG_QUERY) --control-path pkg-ma-db-layout 
_foo-2,/pkg-ma-db-layout:$(NATIVE_ARCH)\._foo-2$$)
        $(DPKG_PURGE) pkg-ma-db-layout
 
 test-clean:
-- 
2.39.2

Reply via email to