summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2023-03-20 01:47:30 +0100
committerFlorian Müllner <fmuellner@gnome.org>2023-04-25 08:07:57 +0000
commitc8c27a270c0d5b7f9efecbae13ba307f55e39288 (patch)
tree8cd06bd33b117551a5d9998e4176dcb2863b0d95
parente5c37d2ff486186cc4acb24db31395afe73e01c3 (diff)
downloadgnome-shell-c8c27a270c0d5b7f9efecbae13ba307f55e39288.tar.gz
ci: Fix meson-install usage check
The script has four mandatory arguments, and also accepts optional build options that are passed on to meson. Checking for the number of arguments *before* filtering out the optional ones means that `./install-meson-project.sh -Done=1 -Dtwo=2 -Dthree=3 -Dfour=4` is considered valid, even though not a single required argument is passed. Fix this by filtering out the arguments before doing the usage check. As it is a nice touch to have usage information at the top of the script, move the message into a usage() function at the top. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2712> (cherry picked from commit 919812a851857ec66ec02d29bb25025f9c2f8205)
-rwxr-xr-x.gitlab-ci/install-meson-project.sh22
1 files changed, 16 insertions, 6 deletions
diff --git a/.gitlab-ci/install-meson-project.sh b/.gitlab-ci/install-meson-project.sh
index f2bacca9b..df188673c 100755
--- a/.gitlab-ci/install-meson-project.sh
+++ b/.gitlab-ci/install-meson-project.sh
@@ -2,12 +2,17 @@
set -e
-if [[ $# -lt 4 ]]; then
- echo Usage: $0 [options] [repo-url] [commit] [subdir]
- echo Options:
- echo -Dkey=val
- exit 1
-fi
+usage() {
+ cat <<-EOF
+ Usage: $(basename $0) [OPTION…] REPO_URL COMMIT SUBDIR PREPARE
+
+ Check out and install a meson project
+
+ Options:
+ -Dkey=val Option to pass on to meson
+
+ EOF
+}
MESON_OPTIONS=()
@@ -16,6 +21,11 @@ while [[ $1 =~ ^-D ]]; do
shift
done
+if [[ $# -lt 4 ]]; then
+ usage
+ exit 1
+fi
+
REPO_URL="$1"
COMMIT="$2"
SUBDIR="$3"