Files
bubblewrap/ci/builddeps.sh
Simon McVittie 1927981240 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 #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>
2022-02-18 10:42:55 +00:00

112 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2021 Simon McVittie
# SPDX-License-Identifier: LGPL-2.0-or-later
set -eux
set -o pipefail
usage() {
if [ "${1-2}" -ne 0 ]; then
exec >&2
fi
cat <<EOF
Usage: see source code
EOF
exit "${1-2}"
}
opt_clang=
getopt_temp="help"
getopt_temp="$getopt_temp,clang"
getopt_temp="$(getopt -o '' --long "${getopt_temp}" -n "$0" -- "$@")"
eval set -- "$getopt_temp"
unset getopt_temp
while true; do
case "$1" in
(--clang)
clang=yes
shift
;;
(--help)
usage 0
# not reached
;;
(--)
shift
break
;;
(*)
echo 'Error parsing options' >&2
usage 2
;;
esac
done
# No more arguments please
for arg in "$@"; do
usage 2
done
if dpkg-vendor --derives-from Debian; then
apt-get -y update
apt-get -q -y install \
autoconf \
automake \
build-essential \
docbook-xml \
docbook-xsl \
libcap-dev \
libselinux1-dev \
libtool \
meson \
pkg-config \
python3 \
xsltproc \
${NULL+}
if [ -n "${opt_clang}" ]; then
apt-get -y install clang
fi
exit 0
fi
if command -v yum; then
yum -y install \
'pkgconfig(libselinux)' \
/usr/bin/eu-readelf \
autoconf \
automake \
docbook-style-xsl \
gcc \
git \
libasan \
libcap-devel \
libtool \
libtsan \
libubsan \
libxslt \
make \
meson \
redhat-rpm-config \
rsync \
${NULL+}
if [ -n "${opt_clang}" ]; then
yum -y install clang
fi
exit 0
fi
echo "Unknown distribution" >&2
exit 1
# vim:set sw=4 sts=4 et: