Skip to content

Commit 7d54d05

Browse files
smcvalexlarsson
authored andcommitted
meson: Add options to set a RPATH/RUNPATH on the bwrap executable
This is useful when building a self-contained, relocatable tree containing a build of bubblewrap and all of its non-glibc dependencies (in practice this means libcap and maybe libselinux), as is done in the Steam container runtime. A RPATH/RUNPATH pointing to ${ORIGIN}/../lib allows bwrap to find an adjacent, bundled copy of libcap. Signed-off-by: Simon McVittie <smcv@collabora.com>
1 parent c54bbc6 commit 7d54d05

5 files changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ jobs:
127127
test -x DESTDIR-as-subproject/usr/local/libexec/not-flatpak-bwrap
128128
test ! -e DESTDIR-as-subproject/usr/local/bin/bwrap
129129
test ! -e DESTDIR-as-subproject/usr/local/libexec/bwrap
130+
tests/use-as-subproject/assert-correct-rpath.py DESTDIR-as-subproject/usr/local/libexec/not-flatpak-bwrap
130131
- name: Upload test logs
131132
uses: actions/upload-artifact@v1
132133
if: failure() || cancelled()

meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ bwrap = executable(
121121
'network.c',
122122
'utils.c',
123123
],
124+
build_rpath : get_option('build_rpath'),
124125
install : true,
125126
install_dir : bwrapdir,
127+
install_rpath : get_option('install_rpath'),
126128
dependencies : [selinux_dep, libcap_dep],
127129
)
128130

meson_options.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ option(
1515
type : 'string',
1616
description : 'install bwrap in this directory [default: bindir, or libexecdir in subprojects]',
1717
)
18+
option(
19+
'build_rpath',
20+
type : 'string',
21+
description : 'set a RUNPATH or RPATH on the bwrap executable',
22+
)
23+
option(
24+
'install_rpath',
25+
type : 'string',
26+
description : 'set a RUNPATH or RPATH on the bwrap executable',
27+
)
1828
option(
1929
'man',
2030
type : 'feature',
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/python3
2+
# Copyright 2022 Collabora Ltd.
3+
# SPDX-License-Identifier: LGPL-2.0-or-later
4+
5+
import subprocess
6+
import sys
7+
8+
if __name__ == '__main__':
9+
completed = subprocess.run(
10+
['objdump', '-T', '-x', sys.argv[1]],
11+
stdout=subprocess.PIPE,
12+
)
13+
stdout = completed.stdout
14+
assert stdout is not None
15+
seen_rpath = False
16+
17+
for line in stdout.splitlines():
18+
words = line.strip().split()
19+
20+
if words and words[0] in (b'RPATH', b'RUNPATH'):
21+
print(line.decode(errors='backslashreplace'))
22+
assert len(words) == 2, words
23+
assert words[1] == b'${ORIGIN}/../lib', words
24+
seen_rpath = True
25+
26+
assert seen_rpath

tests/use-as-subproject/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ configure_file(
1414
subproject(
1515
'bubblewrap',
1616
default_options : [
17+
'install_rpath=${ORIGIN}/../lib',
1718
'program_prefix=not-flatpak-',
1819
],
1920
)

0 commit comments

Comments
 (0)