Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Meson build system #432

Merged
merged 1 commit into from
Feb 18, 2022
Merged

Add a Meson build system #432

merged 1 commit into from
Feb 18, 2022

Conversation

smcv
Copy link
Collaborator

@smcv smcv commented Jun 17, 2021

  • Add a Meson build system

    This allows bwrap to be built as a subproject in larger Meson projects.
    When built as a subproject, we install into the --libexecdir and
    require a program prefix to be specified: for example, Flatpak would use
    program_prefix=flatpak- to get /usr/libexec/flatpak-bwrap. Verified to
    be backwards-compatible as far as Meson 0.49.0 (Debian 9 backports).

    Loosely based on previous work by Jussi Pakkanen (see Basic build of Bubblewrap with Meson. #133).

    Differences between the Autotools and Meson builds:

    The Meson build requires a version of libcap that has pkg-config
    metadata (introduced in libcap 2.23, in 2013).

    The Meson build has no equivalent of --with-priv-mode=setuid. On
    distributions like Debian <= 10 and RHEL <= 7 that require a setuid bwrap
    executable, the sysadmin or distribution packaging will need to set the
    correct permissions on the bwrap executable; Debian already did this via
    packaging rather than the upstream build system.

    The Meson build supports being used as a subproject, and there is CI
    for this. It automatically disables shell completions and man pages,
    moves the bubblewrap executable to ${libexecdir}, and renames the
    bubblewrap executable according to a program_prefix option that the
    caller must specify (for example, Flatpak would use
    -Dprogram_prefix=flatpak- to get /usr/libexec/flatpak-bwrap). See the
    tests/use-as-subproject/ directory for an example.

@smcv
Copy link
Collaborator Author

smcv commented Jun 17, 2021

I'm not sure whether we will be moving Flatpak to meson, but I'd like to at least be able to consider it.

Another project that might switch to building bubblewrap as a subproject is steam-runtime-tools, which includes a mechanism to run Steam games in containers, used by recent versions of Proton.

@smcv smcv force-pushed the meson branch 2 times, most recently from f7c9bff to 9a9f779 Compare June 17, 2021 10:03
@smcv smcv marked this pull request as draft June 17, 2021 10:06
@smcv
Copy link
Collaborator Author

smcv commented Jun 17, 2021

The test script is timing out during meson dist but not during the main build, I'm not sure why.

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks sane to me offhand. But a general concern here is that we still have some special casing in the buildsystem around e.g. suid handling, so duplicating that is a nontrivial concern.

If we see the autotools as on their way out, i.e. heading towards one build system that this seems more palatable. We could merge but note it's not the default or so?

@smcv
Copy link
Collaborator Author

smcv commented Jun 22, 2021

we still have some special casing in the buildsystem around e.g. suid handling

I think that's mostly a relic of the situation in very old versions where the /usr/bin/bwrap binary ended up different, depending whether you configured it for the setuid or modern setup.

What's left is just the build-system goo to set the setuid bit itself, which I deliberately didn't replicate in the Meson build (at least for now) because I think it's often more appropriate to handle that in a higher layer, such as distro packaging. In particular, if you're installing as a nonzero uid into a DESTDIR, possibly with fakeroot, then I'm not really comfortable with making the executable setuid.

If we see the autotools as on their way out, i.e. heading towards one build system that this seems more palatable. We could merge but note it's not the default or so?

I personally do see Autotools as on their way out, particularly in the GNOME-adjacent and freedesktop.org ecosystems; I did this as an enabler for Flatpak potentially moving to Meson eventually, which is why there's explicit test coverage for using bubblewrap as a subproject.

@smcv
Copy link
Collaborator Author

smcv commented Jun 23, 2021

The test is still timing out during one of the automated tests, but only on CI (not on my laptop) and only during meson dist (not during meson test).

The part of the test that is getting stuck seems to be one that juggles subprocesses using fifos on the filesystem and shell process manipulation, which seems like something where randomly deadlocking is a relatively likely failure mode.

@cgwalters, what do you think about the idea of allowing some of the tests to depend on GLib, as I wondered about in #404? That would put us in the same situation as dbus, where the "production" part of the package has minimal dependencies, but full test coverage requires GLib - which might be a good way to keep dependencies minimal, while not having to write unit tests with one hand tied behind our backs (it's worked well for me in dbus, anyway).

@smcv smcv force-pushed the meson branch 3 times, most recently from bb279b9 to 4b958e7 Compare June 28, 2021 10:15
@smcv smcv mentioned this pull request Jun 28, 2021
@smcv
Copy link
Collaborator Author

smcv commented Jun 28, 2021

WIP. There's still a test failure during meson dist, but only on Github CI, not on my laptop; and only during meson dist, not meson test. With the rebase onto #438 I've isolated it to test-specifying-pidns.sh. Maybe meson dist is leaking a fd down into the test or something?

This allows bwrap to be built as a subproject in larger Meson projects.
When built as a subproject, we install into the --libexecdir and
require a program prefix to be specified: for example, Flatpak would use
program_prefix=flatpak- to get /usr/libexec/flatpak-bwrap. Verified to
be backwards-compatible as far as Meson 0.49.0 (Debian 9 backports).

Loosely based on previous work by Jussi Pakkanen (see containers#133).

Differences between the Autotools and Meson builds:

The Meson build requires a version of libcap that has pkg-config
metadata (introduced in libcap 2.23, in 2013).

The Meson build has no equivalent of --with-priv-mode=setuid. On
distributions like Debian <= 10 and RHEL <= 7 that require a setuid bwrap
executable, the sysadmin or distribution packaging will need to set the
correct permissions on the bwrap executable; Debian already did this via
packaging rather than the upstream build system.

The Meson build supports being used as a subproject, and there is CI
for this. It automatically disables shell completions and man pages,
moves the bubblewrap executable to ${libexecdir}, and renames the
bubblewrap executable according to a program_prefix option that the
caller must specify (for example, Flatpak would use
-Dprogram_prefix=flatpak- to get /usr/libexec/flatpak-bwrap). See the
tests/use-as-subproject/ directory for an example.

Signed-off-by: Simon McVittie <smcv@collabora.com>
@smcv smcv marked this pull request as ready for review February 18, 2022 10:44
@smcv smcv requested a review from cgwalters February 18, 2022 10:44
@smcv
Copy link
Collaborator Author

smcv commented Feb 18, 2022

Please could you take another look at this? There's renewed interest in moving Flatpak to Meson (flatpak/flatpak#2241) for which this is likely to be a prerequisite.

Another project that might switch to building bubblewrap as a subproject is steam-runtime-tools, which includes a mechanism to run Steam games in containers, used by recent versions of Proton.

This is indeed now using bubblewrap as a git subtree, but because bubblewrap doesn't have a Meson build of its own, I had to use a hack. I'd prefer to do this in a more supportable way!

There's still a test failure during meson dist, but only on Github CI, not on my laptop; and only during meson dist, not meson test

This seems to have been resolved at some point, and CI is now passing.

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane to me!

@cgwalters cgwalters merged commit 576e8e0 into containers:main Feb 18, 2022
@eli-schwartz
Copy link

This is indeed now using bubblewrap as a git subtree, but because bubblewrap doesn't have a Meson build of its own, I had to use a hack. I'd prefer to do this in a more supportable way!

Just... for the record, next time you need to hack around support like this I suggest using https://mesonbuild.com/Wrap-dependency-system-manual.html#wrapfile-with-meson-build-patch

It's a bit less hacky than #include <subprojects/......../*.c>. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants