scripts: auto-generate list of schemas

Since the list of schemas is growing and we already have a directory, it
does not need to be updated manually. Make a script for it and check
that that's been done in CI.

Tested: Using 'meson install', check that schemas are installed like
before.
Script works and updates the files as expected.

Change-Id: Ia1b3d99890477c4077e8e3a52a5338805d810440
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/scripts/generate_config_list.sh b/scripts/generate_config_list.sh
index 267e872..5545943 100755
--- a/scripts/generate_config_list.sh
+++ b/scripts/generate_config_list.sh
@@ -1,21 +1,7 @@
 #!/bin/sh
 
 set -eu
-LANG=C
 
-json_files=$(cd configurations; find . -iname "*.json" | sort | sed 's|^\./||')
+self=$(basename "$0")
 
-MESON_FILE=configurations/meson.build
-
-SELF=$(basename "$0")
-
-# Generate the Meson file
-{
-    echo "# This file is auto-generated. Do not edit manually."
-    echo "# File content generated with ${SELF}."
-    echo "configs = ["
-    for file in $json_files; do
-        echo "    '${file}',"
-    done
-    echo "]"
-} > "$MESON_FILE"
+./scripts/generate_meson_array.sh configurations configs "${self}"
diff --git a/scripts/generate_meson_array.sh b/scripts/generate_meson_array.sh
new file mode 100755
index 0000000..39d3127
--- /dev/null
+++ b/scripts/generate_meson_array.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -eu
+LANG=C
+
+if [ "$#" -ne 3 ]; then
+    echo "Usage: $0 <directory> <meson_array_name> <script_name>" >&2
+    exit 1
+fi
+
+dir="$1"
+array_name="$2"
+script_name="$3"
+meson_file="${dir}/meson.build"
+
+json_files=$(cd "$dir"; find . -regex "[\./]?[\/a-zA-Z0-9_\-]+.json" | sort | sed 's|^\./||')
+
+{
+    echo "# This file is auto-generated. Do not edit manually."
+    echo "# File content generated with ${script_name}"
+    echo "${array_name} = ["
+    for file in $json_files; do
+        echo "    '${file}',"
+    done
+    echo "]"
+} > "$meson_file"
+
diff --git a/scripts/generate_schema_list.sh b/scripts/generate_schema_list.sh
new file mode 100755
index 0000000..b319cde
--- /dev/null
+++ b/scripts/generate_schema_list.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -eu
+
+self=$(basename "$0")
+
+./scripts/generate_meson_array.sh schemas schemas "${self}"
diff --git a/scripts/run-ci.sh b/scripts/run-ci.sh
index 9364a97..583a732 100755
--- a/scripts/run-ci.sh
+++ b/scripts/run-ci.sh
@@ -4,6 +4,9 @@
 
 scripts/validate_configs.py -v -k -e test/expected-schema-errors.txt
 
-# fail the script if someone forgot to update the list of configurations
+# fail the script if someone forgot to update the list of configurations or
+# schemas
+
 scripts/generate_config_list.sh
+scripts/generate_schema_list.sh
 git --no-pager diff --exit-code -- .