Control: tags -1 + patch On Sun, 06 Aug 2023 at 14:47:40 +0100, Simon McVittie wrote: > As a result of upstream changes in meson and changes to the Debian > packaging/patches of Python, rebuilding gi-docgen with meson >= 1.2.0 > results in the installed tree in debian/tmp putting Python code in > /usr/local, not /usr. ... > pybuild avoids this by setting DEB_PYTHON_INSTALL_LAYOUT=deb ... > I think either debhelper's cmake and meson build systems should be doing > this for us, or debhelper should be doing this globally, to avoid every > affected package having to be changed for this.
Please consider <https://salsa.debian.org/debian/debhelper/-/merge_requests/107>. Also attached as a patch since some maintainers require that. If I receive review feedback on Salsa, I will assume that's the preferred contribution route and only update that version, unless reminded to send an updated patch to the bug. smcv
>From 2254e54fec6d6f537d63d90692e69f0f2bbe9f16 Mon Sep 17 00:00:00 2001 From: Simon McVittie <s...@debian.org> Date: Sun, 6 Aug 2023 14:02:57 +0100 Subject: [PATCH] cmake, meson: Set DEB_PYTHON_INSTALL_LAYOUT=deb if not already set With recent versions of cmake, meson and python3, the default installation layout discovered by cmake or meson is below /usr/local, unless we explicitly override DEB_PYTHON_INSTALL_LAYOUT to tell Python that we are building a distro package. Closes: #1043136 Signed-off-by: Simon McVittie <s...@debian.org> --- lib/Debian/Debhelper/Buildsystem/cmake.pm | 12 +++++++++++- lib/Debian/Debhelper/Buildsystem/meson.pm | 18 +++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/Debian/Debhelper/Buildsystem/cmake.pm b/lib/Debian/Debhelper/Buildsystem/cmake.pm index 2b793939..c64c418e 100644 --- a/lib/Debian/Debhelper/Buildsystem/cmake.pm +++ b/lib/Debian/Debhelper/Buildsystem/cmake.pm @@ -79,6 +79,12 @@ sub new { return $this; } +sub _get_cmake_env { + my $update_env = {}; + $update_env->{DEB_PYTHON_INSTALL_LAYOUT} = 'deb' unless $ENV{DEB_PYTHON_INSTALL_LAYOUT}; + return $update_env; +} + sub configure { my $this=shift; # Standard set of cmake flags @@ -141,7 +147,10 @@ sub configure { $this->mkdir_builddir(); eval { - $this->doit_in_builddir("cmake", @flags, @_, $this->get_source_rel2builddir()); + my %options = ( + update_env => _get_cmake_env(), + ); + $this->doit_in_builddir(\%options, "cmake", @flags, @_, $this->get_source_rel2builddir()); }; if (my $err = $@) { if (-e $this->get_buildpath("CMakeCache.txt")) { @@ -196,6 +205,7 @@ sub install { update_env => { 'LC_ALL' => 'C.UTF-8', 'DESTDIR' => $destdir, + %{ _get_cmake_env() }, } ); print_and_doit(\%options, 'cmake', '--install', $this->get_buildpath, @_); diff --git a/lib/Debian/Debhelper/Buildsystem/meson.pm b/lib/Debian/Debhelper/Buildsystem/meson.pm index 3cd447de..066216a7 100644 --- a/lib/Debian/Debhelper/Buildsystem/meson.pm +++ b/lib/Debian/Debhelper/Buildsystem/meson.pm @@ -48,6 +48,14 @@ sub new { return $this; } +sub _get_meson_env { + my $update_env = { + LC_ALL => 'C.UTF-8', + }; + $update_env->{DEB_PYTHON_INSTALL_LAYOUT} = 'deb' unless $ENV{DEB_PYTHON_INSTALL_LAYOUT}; + return $update_env; +} + sub configure { my $this=shift; @@ -92,7 +100,7 @@ sub configure { $this->mkdir_builddir(); eval { my %options = ( - update_env => { LC_ALL => 'C.UTF-8'}, + update_env => _get_meson_env(), ); $this->doit_in_builddir(\%options, "meson", "setup", $this->get_source_rel2builddir(), @opts, @_); }; @@ -115,9 +123,7 @@ sub test { # In compat 13 with meson+ninja, we prefer using "meson test" # over "ninja test" my %options = ( - update_env => { - 'LC_ALL' => 'C.UTF-8', - } + update_env => _get_meson_env(), ); if ($this->get_parallel() > 0) { $options{update_env}{MESON_TESTTHREADS} = $this->get_parallel(); @@ -144,9 +150,7 @@ sub install { # In compat 14 with meson+ninja, we prefer using "meson install" # over "ninja install" my %options = ( - update_env => { - 'LC_ALL' => 'C.UTF-8', - } + update_env => _get_meson_env(), ); $this->doit_in_builddir(\%options, 'meson', 'install', '--destdir', $destdir, @args); } -- 2.40.1