From 56c48ba3e9fb71da6a9a97e5e3f1e647e7342476 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Thu, 18 Jul 2024 18:04:10 +0200 Subject: [PATCH] CI: Add missing dependencies To fix the build of mutter. This is taken from mutter's own CI. --- .gitlab-ci.yml | 1 + .gitlab-ci/install-common-dependencies.sh | 82 +++++++++++++++++ .gitlab-ci/install-meson-project.sh | 103 ++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100755 .gitlab-ci/install-common-dependencies.sh create mode 100755 .gitlab-ci/install-meson-project.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index efb0208..35c9984 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,7 @@ build-fedora: stage: build before_script: - dnf upgrade -y + - .gitlab-ci/install-common-dependencies.sh - .gitlab-ci/checkout-mutter.sh - meson mutter mutter/build --prefix=/usr - meson install -C mutter/build diff --git a/.gitlab-ci/install-common-dependencies.sh b/.gitlab-ci/install-common-dependencies.sh new file mode 100755 index 0000000..3e55bef --- /dev/null +++ b/.gitlab-ci/install-common-dependencies.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +set -e + +usage() { + cat <<-EOF + Usage: $(basename $0) [OPTION…] + + Install common dependencies to a base image or system extension + + Options: + --libdir Setup the projects with a different libdir + --destdir Install the projects to an additional destdir + + -h, --help Display this help + + EOF +} + +TEMP=$(getopt \ + --name=$(basename $0) \ + --options='' \ + --longoptions='libdir:' \ + --longoptions='destdir:' \ + --longoptions='help' \ + -- "$@") + +eval set -- "$TEMP" +unset TEMP + +OPTIONS=() + +while true; do + case "$1" in + --libdir) + OPTIONS+=( --libdir=$2 ) + shift 2 + ;; + + --destdir) + OPTIONS+=( --destdir=$2 ) + shift 2 + ;; + + -h|--help) + usage + exit 0 + ;; + + --) + shift + break + ;; + esac +done + +SCRIPTS_DIR="$(dirname $0)" + +if ! pkgconf --atleast-version 1.23.0 wayland-server +then + ./$SCRIPTS_DIR/install-meson-project.sh \ + "${OPTIONS[@]}" \ + https://gitlab.freedesktop.org/wayland/wayland.git \ + 1.23.0 +fi + +if ! pkgconf --atleast-version 1.36 wayland-protocols +then + ./$SCRIPTS_DIR/install-meson-project.sh \ + "${OPTIONS[@]}" \ + https://gitlab.freedesktop.org/wayland/wayland-protocols.git \ + 1.36 +fi + +if ! gsettings list-keys org.gnome.desktop.peripherals.tablet.stylus | \ + grep -q button-keybinding >/dev/null 2>&1 +then + ./$SCRIPTS_DIR/install-meson-project.sh \ + "${OPTIONS[@]}" \ + https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas.git \ + master +fi diff --git a/.gitlab-ci/install-meson-project.sh b/.gitlab-ci/install-meson-project.sh new file mode 100755 index 0000000..7750193 --- /dev/null +++ b/.gitlab-ci/install-meson-project.sh @@ -0,0 +1,103 @@ +#!/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 + sudo meson install -C _build --destdir=$DESTDIR +fi + +sudo meson install -C _build +popd -- GitLab