From 1c66a8516b382b9f636a60bbc890d2acb1da3c84 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Thu, 25 Jun 2026 10:01:48 -0500 Subject: [PATCH 1/3] libmariadb-dev: make Multi-Arch: same co-installable libmariadb-dev could not be co-installed for multiple architectures because it lacked Multi-Arch: same and shipped two files that differ per architecture at shared (non-triplet) paths: * /usr/bin/mariadb_config (a compiled ELF binary) * /usr/include/mariadb/mariadb_version.h (only MARIADB_MACHINE_TYPE and MARIADB_PLUGINDIR differ) All 146 other shared files are byte-identical between architectures. Mark the package Multi-Arch: same and neutralise the two differing files at build time (execute_after_dh_install): * Replace the compiled mariadb_config with an architecture-independent POSIX shell script that derives the multiarch triplet at runtime, so the installed file is identical on every architecture. * Move only the two arch-varying macros out of mariadb_version.h into a stub header in the per-arch triplet include directory (auto-searched by the compiler), keeping the public header byte-identical. The header is deliberately not relocated: mysql.h includes it with quotes. Closes: #1140296 --- debian/control | 1 + debian/mariadb_config | 37 +++++++++++++++++++++++++++++++++++++ debian/rules | 24 ++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100755 debian/mariadb_config diff --git a/debian/control b/debian/control index 9939b13..bc9dce0 100644 --- a/debian/control +++ b/debian/control @@ -57,6 +57,7 @@ Vcs-Git: https://salsa.debian.org/mariadb-team/mariadb-server.git Package: libmariadb-dev Architecture: any +Multi-Arch: same Section: libdevel Depends: libmariadb3 (= ${binary:Version}), diff --git a/debian/mariadb_config b/debian/mariadb_config new file mode 100755 index 0000000..dd02a57 --- /dev/null +++ b/debian/mariadb_config @@ -0,0 +1,37 @@ +#!/bin/sh +# Architecture-independent mariadb_config (Debian multi-arch co-install fix). +# Derives the multiarch triplet at runtime so this file is byte-identical +# across architectures and libmariadb-dev can be Multi-Arch: same. +set -e +triplet=$(${CC:-cc} -print-multiarch 2>/dev/null) || true +[ -n "$triplet" ] || triplet=$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null) || true +[ -n "$triplet" ] || triplet=$(${CC:-cc} -dumpmachine 2>/dev/null) || true +libdir="/usr/lib/$triplet" +vhdr="/usr/include/mariadb/mariadb_version.h" +version=$(sed -n 's/.*MARIADB_CLIENT_VERSION_STR[^"]*"\([^"]*\)".*/\1/p' "$vhdr" 2>/dev/null) +[ -n "$version" ] || version=unknown +inc="-I/usr/include/mariadb -I/usr/include/mariadb/mysql" +usage() { + cat <&2; exit 1 ;; + esac +done diff --git a/debian/rules b/debian/rules index 4b10965..0b5da6e 100755 --- a/debian/rules +++ b/debian/rules @@ -227,6 +227,30 @@ override_dh_installinit: override_dh_gencontrol: dh_gencontrol -- -Tdebian/substvars +# Make libmariadb-dev co-installable across architectures (Multi-Arch: same). +# Two files would otherwise differ between architectures at shared paths: +# - /usr/bin/mariadb_config: replace the per-arch compiled binary with an +# architecture-independent shell script that derives the multiarch triplet +# at runtime, so the file is byte-identical on every architecture. +# - /usr/include/mariadb/mariadb_version.h: move only the two arch-varying +# macros (MARIADB_MACHINE_TYPE, MARIADB_PLUGINDIR) into a stub header in the +# per-arch triplet include dir (which the compiler searches automatically), +# leaving the public header byte-identical across architectures. The header +# must NOT be relocated: mysql.h pulls it in with #include "..." (same dir). +execute_after_dh_install: + set -e; pkgdir=debian/libmariadb-dev; inc=$$pkgdir/usr/include; \ + if [ -f $$inc/mariadb/mariadb_version.h ]; then \ + install -m0755 debian/mariadb_config $$pkgdir/usr/bin/mariadb_config; \ + mkdir -p $$inc/$(DEB_HOST_MULTIARCH); \ + grep -E 'MARIADB_MACHINE_TYPE|MARIADB_PLUGINDIR' \ + $$inc/mariadb/mariadb_version.h \ + > $$inc/$(DEB_HOST_MULTIARCH)/mariadb_version_arch.h; \ + sed -i -E '/MARIADB_MACHINE_TYPE|MARIADB_PLUGINDIR/d' \ + $$inc/mariadb/mariadb_version.h; \ + sed -i '/#define _mariadb_version_h_/a #include ' \ + $$inc/mariadb/mariadb_version.h; \ + fi + # If a file is not supposed to be included anywhere, add it to the not-installed # file and document the reason. Note that dh_install supports the above mentioned # white list file only starting from Debian Stretch and Ubuntu Xenial. -- 2.47.3