8aeb6dc864
To build a system extension we need to: 1. Add dependencies to the container (to build it), and also 2. Add dependencies to the extension (to run it, later). So there's effectively two locations where we need to install those dependencies. See https://discourse.gnome.org/t/towards-a-better-way-to-hack-and-test-your-system-components/21075 See https://gitlab.gnome.org/GNOME/gnome-build-meta/-/issues/837 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3843>
103 lines
1.6 KiB
Bash
Executable file
103 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
usage() {
|
|
cat <<-EOF
|
|
Usage: $(basename $0) [OPTION…] REPO_URL COMMIT
|
|
|
|
Check out and install a meson project
|
|
|
|
Options:
|
|
-Dkey=val Option to pass on to meson
|
|
--subdir Build subdirectory instead of whole project
|
|
--prepare Script to run before build
|
|
--libdir Setup the project with a different libdir
|
|
--destdir Install the project to an additional destdir
|
|
|
|
-h, --help Display this help
|
|
|
|
EOF
|
|
}
|
|
|
|
TEMP=$(getopt \
|
|
--name=$(basename $0) \
|
|
--options='D:h' \
|
|
--longoptions='subdir:' \
|
|
--longoptions='prepare:' \
|
|
--longoptions='libdir:' \
|
|
--longoptions='destdir:' \
|
|
--longoptions='help' \
|
|
-- "$@")
|
|
|
|
eval set -- "$TEMP"
|
|
unset TEMP
|
|
|
|
MESON_OPTIONS=()
|
|
SUBDIR=.
|
|
PREPARE=:
|
|
DESTDIR=""
|
|
|
|
while true; do
|
|
case "$1" in
|
|
-D)
|
|
MESON_OPTIONS+=( -D$2 )
|
|
shift 2
|
|
;;
|
|
|
|
--subdir)
|
|
SUBDIR=$2
|
|
shift 2
|
|
;;
|
|
|
|
--prepare)
|
|
PREPARE=$2
|
|
shift 2
|
|
;;
|
|
|
|
--libdir)
|
|
MESON_OPTIONS+=( --libdir=$2 )
|
|
shift 2
|
|
;;
|
|
|
|
--destdir)
|
|
DESTDIR=$2
|
|
shift 2
|
|
;;
|
|
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ $# -lt 2 ]]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
REPO_URL="$1"
|
|
COMMIT="$2"
|
|
|
|
CHECKOUT_DIR=$(mktemp --directory)
|
|
trap "rm -rf $CHECKOUT_DIR" EXIT
|
|
|
|
git clone --depth 1 "$REPO_URL" -b "$COMMIT" "$CHECKOUT_DIR"
|
|
|
|
pushd "$CHECKOUT_DIR/$SUBDIR"
|
|
sh -c "$PREPARE"
|
|
meson setup --prefix=/usr _build "${MESON_OPTIONS[@]}"
|
|
|
|
# Install it to an additional directory e.g., system extension directory
|
|
if [ -n "${DESTDIR}" ]; then
|
|
meson install -C _build --destdir=$DESTDIR
|
|
fi
|
|
|
|
meson install -C _build
|
|
popd
|