From 14c1dcd322c493cd994d677c9cbb2edbbf0525f2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Aug 2023 12:02:51 +0100 Subject: [PATCH 1/3] meson: Allow `sudo meson install`, which doesn't set `DESTDIR` This is generally not recommended (dbus should usually be installed from the OS distributor's packages, which should install into a staging directory using `DESTDIR`), but we'll want to use it in Gitlab-CI. Signed-off-by: Simon McVittie --- tools/meson-compat-install-emptydirs.py | 4 ++-- tools/meson-compat-install-symlink.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/meson-compat-install-emptydirs.py b/tools/meson-compat-install-emptydirs.py index 0fc76287..45ae62de 100755 --- a/tools/meson-compat-install-emptydirs.py +++ b/tools/meson-compat-install-emptydirs.py @@ -9,10 +9,10 @@ import sys from pathlib import Path for d in sys.argv[1].split(':'): - if os.path.isabs(d) and 'DESTDIR' in os.environ: + if os.path.isabs(d): p = Path(d) d = p.relative_to(p.anchor) - dest = os.path.join(os.environ['DESTDIR'], d) + dest = os.path.join(os.environ.get('DESTDIR', '/'), d) else: dest = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], d) diff --git a/tools/meson-compat-install-symlink.py b/tools/meson-compat-install-symlink.py index 6e7ac333..69ff2a66 100755 --- a/tools/meson-compat-install-symlink.py +++ b/tools/meson-compat-install-symlink.py @@ -14,7 +14,7 @@ link_name, d, pointing_to = sys.argv[1:] if os.path.isabs(d): p = Path(d) d = p.relative_to(p.anchor) - dest = os.path.join(os.environ['DESTDIR'], d) + dest = os.path.join(os.environ.get('DESTDIR', '/'), d) else: dest = os.path.join(os.environ['MESON_INSTALL_DESTDIR_PREFIX'], d) From 4b4aa2491923f3239af85596f385c80ae081626e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 7 Aug 2023 20:16:57 +0100 Subject: [PATCH 2/3] CI: Run "as-installed" tests with Meson, not just Autotools Otherwise, we'd lose this test coverage when we remove Autotools. Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/436 Signed-off-by: Simon McVittie --- tools/ci-build.sh | 75 +++++++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/tools/ci-build.sh b/tools/ci-build.sh index 98afd8aa..a248cbdd 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -320,35 +320,6 @@ case "$ci_buildsys" in LD_LIBRARY_PATH=/usr/local/lib ${make} installcheck || \ maybe_fail_tests cat test/test-suite.log || : - - # Re-run them with gnome-desktop-testing. - # Also, one test needs a finite fd limit to be useful, so we - # can set that here. - env LD_LIBRARY_PATH=/usr/local/lib \ - bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \ - gnome-desktop-testing-runner -d /usr/local/share dbus/ || \ - maybe_fail_tests - - # Some tests benefit from being re-run as non-root, if we were - # not already... - if [ "$(id -u)" = 0 ] && [ "$ci_in_docker" = yes ]; then - sudo -u user \ - env LD_LIBRARY_PATH=/usr/local/lib \ - gnome-desktop-testing-runner -d /usr/local/share \ - dbus/test-dbus-daemon_with_config.test \ - || maybe_fail_tests - fi - - # ... while other tests benefit from being re-run as root, if - # we were not already - if [ "$(id -u)" != 0 ]; then - sudo env LD_LIBRARY_PATH=/usr/local/lib \ - bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \ - gnome-desktop-testing-runner -d /usr/local/share \ - dbus/test-dbus-daemon_with_config.test \ - dbus/test-uid-permissions_with_config.test || \ - maybe_fail_tests - fi fi ;; @@ -548,6 +519,10 @@ case "$ci_buildsys" in fi fi + # We assume this when we set LD_LIBRARY_PATH for as-installed + # testing, below + set -- "$@" --libdir=lib + # openSUSE's mingw*-meson wrappers are designed for self-contained # package building, so they include --wrap-mode=nodownload. Switch # the wrap mode back, so we can use wraps. @@ -562,6 +537,48 @@ case "$ci_buildsys" in [ "$ci_test" = no ] || meson test --print-errorlogs DESTDIR=DESTDIR meson install ( cd DESTDIR && find . -ls) + + if [ "$ci_sudo" = yes ] && [ "$ci_test" = yes ] && [ "$ci_host" = native ]; then + sudo meson install + fi + ;; +esac + +case "$ci_buildsys" in + (autotools | meson*) + if [ "$ci_sudo" = yes ] && [ "$ci_test" = yes ] && [ "$ci_host" = native ]; then + sudo env LD_LIBRARY_PATH=/usr/local/lib \ + /usr/local/bin/dbus-uuidgen --ensure + + # Run "as-installed" tests with gnome-desktop-testing. + # Also, one test needs a finite fd limit to be useful, so we + # can set that here. + env LD_LIBRARY_PATH=/usr/local/lib \ + bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \ + gnome-desktop-testing-runner -d /usr/local/share dbus/ || \ + maybe_fail_tests + + # Some tests benefit from being re-run as non-root, if we were + # not already... + if [ "$(id -u)" = 0 ] && [ "$ci_in_docker" = yes ]; then + sudo -u user \ + env LD_LIBRARY_PATH=/usr/local/lib \ + gnome-desktop-testing-runner -d /usr/local/share \ + dbus/test-dbus-daemon_with_config.test \ + || maybe_fail_tests + fi + + # ... while other tests benefit from being re-run as root, if + # we were not already + if [ "$(id -u)" != 0 ]; then + sudo env LD_LIBRARY_PATH=/usr/local/lib \ + bash -c 'ulimit -S -n 1024; ulimit -H -n 4096; exec "$@"' bash \ + gnome-desktop-testing-runner -d /usr/local/share \ + dbus/test-dbus-daemon_with_config.test \ + dbus/test-uid-permissions_with_config.test || \ + maybe_fail_tests + fi + fi ;; esac From 3e4dd491bb7a30e9b3327bb1aaa237459c4dd6cf Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Aug 2023 12:07:09 +0100 Subject: [PATCH 3/3] CI: Install systemd system and user units into our ${prefix} This keeps everything we install from CI separate from a possible OS-level installation in /usr. Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/470 Signed-off-by: Simon McVittie --- tools/ci-build.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/ci-build.sh b/tools/ci-build.sh index a248cbdd..d53b8bb4 100755 --- a/tools/ci-build.sh +++ b/tools/ci-build.sh @@ -427,6 +427,13 @@ case "$ci_buildsys" in esac set -- -Dmodular_tests=enabled "$@" + # By default, the Meson build would install these into + # /lib/systemd, overwriting any systemd units that might have + # come from the container's base OS. Install into our prefix instead, + # keeping the CI installation separate from the container's base OS + # while still allowing systemd to see the units. (dbus#470) + set -- -Dsystemd_system_unitdir=/usr/local/lib/systemd/system "$@" + set -- -Dsystemd_user_unitdir=/usr/local/lib/systemd/user "$@" case "$ci_variant" in (debug)