8d419f
From 380a3b2b2d38f08ac84d3ac521b205960059d99c Mon Sep 17 00:00:00 2001
8d419f
From: Yu Watanabe <watanabe.yu+github@gmail.com>
8d419f
Date: Tue, 14 Jun 2022 09:10:00 +0900
8d419f
Subject: [PATCH] test: add one more path to search keymaps
8d419f
8d419f
Now it also supports split-usr.
8d419f
8d419f
(cherry picked from commit 569c6fd1b7c7946fa853d558fcbb23e4a45f957f)
8d419f
8d419f
Related: #2087652
8d419f
---
8d419f
 test/test-functions | 59 ++++++++++++++++++++++++++++++---------------
8d419f
 1 file changed, 40 insertions(+), 19 deletions(-)
8d419f
8d419f
diff --git a/test/test-functions b/test/test-functions
8d419f
index d71e2a3328..01fc90fbf5 100644
8d419f
--- a/test/test-functions
8d419f
+++ b/test/test-functions
8d419f
@@ -1844,26 +1844,47 @@ install_pam() {
8d419f
 
8d419f
 # shellcheck disable=SC2120
8d419f
 install_keymaps() {
8d419f
-    dinfo "Install keymaps"
8d419f
-    # The first three paths may be deprecated.
8d419f
-    # It seems now the last two paths are used by many distributions.
8d419f
-    for i in \
8d419f
-        /usr/lib/kbd/keymaps/include/* \
8d419f
-        /usr/lib/kbd/keymaps/i386/include/* \
8d419f
-        /usr/lib/kbd/keymaps/i386/qwerty/us.* \
8d419f
-        /usr/lib/kbd/keymaps/legacy/include/* \
8d419f
-        /usr/lib/kbd/keymaps/legacy/i386/qwerty/us.*; do
8d419f
-            [[ -f "$i" ]] || continue
8d419f
-            inst "$i"
8d419f
-    done
8d419f
+    local i p
8d419f
+    local -a prefix=(
8d419f
+        "/usr"
8d419f
+    )
8d419f
 
8d419f
-    # When it takes any argument, then install more keymaps.
8d419f
-    if [[ $# -gt 1 ]]; then
8d419f
-        for i in \
8d419f
-        /usr/lib/kbd/keymaps/i386/*/* \
8d419f
-        /usr/lib/kbd/keymaps/legacy/i386/*/*; do
8d419f
-            [[ -f "$i" ]] || continue
8d419f
-            inst "$i"
8d419f
+    dinfo "Install console keymaps"
8d419f
+
8d419f
+    if command -v meson >/dev/null \
8d419f
+            && [[ "$(meson configure "${BUILD_DIR:?}" | grep 'split-usr' | awk '{ print $2 }')" == "true" ]] \
8d419f
+            || [[ ! -L /lib ]]; then
8d419f
+        prefix+=(
8d419f
+            ""
8d419f
+        )
8d419f
+    fi
8d419f
+
8d419f
+    if (( $# == 0 )); then
8d419f
+        for p in "${prefix[@]}"; do
8d419f
+            # The first three paths may be deprecated.
8d419f
+            # It seems now the last three paths are used by many distributions.
8d419f
+            for i in \
8d419f
+                "$p"/lib/kbd/keymaps/include/* \
8d419f
+                "$p"/lib/kbd/keymaps/i386/include/* \
8d419f
+                "$p"/lib/kbd/keymaps/i386/qwerty/us.* \
8d419f
+                "$p"/lib/kbd/keymaps/legacy/include/* \
8d419f
+                "$p"/lib/kbd/keymaps/legacy/i386/qwerty/us.* \
8d419f
+                "$p"/lib/kbd/keymaps/xkb/us*; do
8d419f
+                    [[ -f "$i" ]] || continue
8d419f
+                    inst "$i"
8d419f
+            done
8d419f
+        done
8d419f
+    else
8d419f
+        # When it takes any argument, then install more keymaps.
8d419f
+        for p in "${prefix[@]}"; do
8d419f
+            for i in \
8d419f
+                "$p"/lib/kbd/keymaps/include/* \
8d419f
+                "$p"/lib/kbd/keymaps/i386/*/* \
8d419f
+                "$p"/lib/kbd/keymaps/legacy/i386/*/* \
8d419f
+                "$p"/lib/kbd/keymaps/xkb/*; do
8d419f
+                    [[ -f "$i" ]] || continue
8d419f
+                    inst "$i"
8d419f
+            done
8d419f
         done
8d419f
     fi
8d419f
 }