1
0
Fork 0

ci: Make --destdir option in install-meson-project cumulative

When building a system extension for GNOME OS, any extra
dependencies are needed both in the container (for building)
and the extension's destdir (for running).

Because of that, the --destdir flag that was added in commit
8aeb6dc86 does not only install to the specified directory
as expected, but also runs a second install step without
destdir (i.e. to the system).

However that behavior is not a good fit when we extend our
existing toolbox tooling to build system extensions for
Fedora instead of GNOME OS.

To account for that, make the --destdir option cumulative
and install the project to all provided destdirs (or /
if omitted).

This gives us the flexibility to install to the system, a
different destdir, or both:

```
 $ ./install-meson-project.sh  # install to system
 $ ./install-meson-project.sh --destdir /new/dest  # install to destdir
 $ ./install-meson-project.sh --destdir /new/dest --destdir /  # both
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4075>
This commit is contained in:
Florian Müllner 2024-10-04 18:19:58 +02:00 committed by Marge Bot
parent 245dafe811
commit bcdab9d9c0
2 changed files with 14 additions and 10 deletions

View file

@ -11,6 +11,6 @@ DESTDIR="$(realpath $1)"
LIBDIR="lib/$(gcc -print-multiarch)" LIBDIR="lib/$(gcc -print-multiarch)"
# Install common dependencies # Install common dependencies
./$SCRIPTS_DIR/install-common-dependencies.sh --libdir=$LIBDIR --destdir=$DESTDIR ./$SCRIPTS_DIR/install-common-dependencies.sh --libdir=$LIBDIR --destdir=$DESTDIR --destdir=/
# Install below missing dependencies that are exclusive to GNOME OS # Install below missing dependencies that are exclusive to GNOME OS

View file

@ -13,7 +13,8 @@ usage() {
--subdir=DIR Build subdirectory instead of whole project --subdir=DIR Build subdirectory instead of whole project
--prepare=SCRIPT Script to run before build --prepare=SCRIPT Script to run before build
--libdir=DIR Setup the project with a different libdir --libdir=DIR Setup the project with a different libdir
--destdir=DIR Install the project to an additional destdir --destdir=DIR Install the project to DIR, can be used
several times to install to multiple destdirs
-h, --help Display this help -h, --help Display this help
@ -36,7 +37,7 @@ unset TEMP
MESON_OPTIONS=() MESON_OPTIONS=()
SUBDIR=. SUBDIR=.
PREPARE=: PREPARE=:
DESTDIR="" DESTDIRS=()
while true; do while true; do
case "$1" in case "$1" in
@ -61,7 +62,7 @@ while true; do
;; ;;
--destdir) --destdir)
DESTDIR=$2 DESTDIRS+=( $2 )
shift 2 shift 2
;; ;;
@ -85,6 +86,8 @@ fi
REPO_URL="$1" REPO_URL="$1"
COMMIT="$2" COMMIT="$2"
[[ ${#DESTDIRS[@]} == 0 ]] && DESTDIRS+=( / )
CHECKOUT_DIR=$(mktemp --directory) CHECKOUT_DIR=$(mktemp --directory)
trap "rm -rf $CHECKOUT_DIR" EXIT trap "rm -rf $CHECKOUT_DIR" EXIT
@ -94,10 +97,11 @@ pushd "$CHECKOUT_DIR/$SUBDIR"
sh -c "$PREPARE" sh -c "$PREPARE"
meson setup --prefix=/usr _build "${MESON_OPTIONS[@]}" meson setup --prefix=/usr _build "${MESON_OPTIONS[@]}"
# Install it to an additional directory e.g., system extension directory # Install it to all specified dest dirs
if [ -n "${DESTDIR}" ]; then for destdir in "${DESTDIRS[@]}"; do
sudo meson install -C _build --destdir=$DESTDIR # don't use --destdir when installing to root,
fi # so post-install hooks are run
[[ $destdir == / ]] && destdir=
sudo meson install -C _build sudo meson install -C _build ${destdir:+--destdir=$destdir}
done
popd popd