#813455 dpkg-maintscript-helper: dir_to_symlink should be transparent to arch:all arch:any package

Package:
dpkg
Source:
dpkg
Description:
Debian package management system
Submitter:
Bastien ROUCARIÈS
Date:
2026-02-08 13:33:03 UTC
Severity:
minor
#813455#5
Date:
2016-02-02 08:24:38 UTC
From:
To:
Hi,

I have moved a package from arch:any to arch:all and used dir_to_symlink in order to link /usr/share/doc/main-package (package is now a transition package).

This fail with message like:
  dpkg-maintscript-helper: error: directory '/usr/share/doc/imagemagick' contains files not owned by package imagemagick:all, cannot switch to symlink
  dpkg: error processing archive /var/cache/apt/archives/imagemagick_8%3a6.9.2.10+dfsg-2_all.deb (--unpack):
   subprocess new pre-installation script returned error exit status 1

Bastien

#813455#16
Date:
2016-02-19 17:54:51 UTC
From:
To:
control: tags -1 - moreinfo
#813455#23
Date:
2016-05-05 13:28:10 UTC
From:
To:
control: tags -1 moreinfo

Hi Guillem,

Any news of this bug ?

bastien

#813455#38
Date:
2017-04-12 21:55:51 UTC
From:
To:
control: tags -1 - moreinfo
#813455#45
Date:
2018-08-07 03:52:55 UTC
From:
To:

#813455#52
Date:
2026-02-08 13:31:03 UTC
From:
To:
Hi Guillem

Does this will solve this bug ?

diff --git a/src/dpkg-maintscript-helper.sh b/src/dpkg-maintscript-helper.sh
index a7b914a2c..33921c53c 100755
--- a/src/dpkg-maintscript-helper.sh
+++ b/src/dpkg-maintscript-helper.sh
@@ -526,11 +526,22 @@ validate_optional_version() {
   fi
 }

+
+# dpkg -L all/any
+dpkg_L_all_arch() {
+  local PKG="$1"
+  dpkg-query -W -f='${Package}:${Architecture}\n' | grep "^${PKG}:" | \
+  while read p; do
+    dpkg-query -L "$p" 2>/dev/null
+  done
+}
+
 ensure_package_owns_file() {
   local PACKAGE="$1"
   local FILE="$2"
+  local ARCH=$(dpkg --print-architecture)

-  if ! dpkg-query -L "$PACKAGE" | grep -F -q -x "$FILE"; then
+  if ! dpkg_L_all_arch "$PACKAGE" | grep -F -q -x "$FILE"; then
     debug "File '$FILE' not owned by package " \
           "'$PACKAGE', skipping $command"
     return 1