| 1 |
#!/bin/sh |
| 2 |
set -e |
| 3 |
|
| 4 |
case "${DEB_BUILD_PROFILES:-}" in |
| 5 |
*pkg.systemd.upstream*) ;; |
| 6 |
*) |
| 7 |
echo "keymapping not supported for now, SKIP test" |
| 8 |
exit 77 |
| 9 |
esac |
| 10 |
|
| 11 |
. `dirname $0`/assert.sh |
| 12 |
|
| 13 |
if [ -f /etc/default/keyboard ]; then |
| 14 |
ORIG_KBD=`cat /etc/default/keyboard` |
| 15 |
else |
| 16 |
ORIG_KBD="" |
| 17 |
fi |
| 18 |
|
| 19 |
cleanup() { |
| 20 |
# reset locale to original |
| 21 |
if [ -n "ORIG_KBD" ]; then |
| 22 |
echo "$ORIG_KBD" > /etc/default/keyboard |
| 23 |
else |
| 24 |
rm -f /etc/default/keyboard |
| 25 |
fi |
| 26 |
rm -f /etc/X11/xorg.conf.d/00-keyboard.conf |
| 27 |
rm -f /etc/dbus-1/system.d/systemd-localed-read-only.conf |
| 28 |
} |
| 29 |
trap cleanup EXIT INT QUIT PIPE |
| 30 |
|
| 31 |
# Calls to localed are blocked as other tools are used to change settings, |
| 32 |
# override that policy |
| 33 |
mkdir -p /etc/dbus-1/system.d/ |
| 34 |
cat >/etc/dbus-1/system.d/systemd-localed-read-only.conf <<EOF |
| 35 |
<?xml version="1.0"?> |
| 36 |
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" |
| 37 |
"https://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> |
| 38 |
<busconfig> |
| 39 |
<policy user="root"> |
| 40 |
<allow send_destination="org.freedesktop.locale1" send_interface="org.freedesktop.locale1" send_member="SetLocale"/> |
| 41 |
<allow send_destination="org.freedesktop.locale1" send_interface="org.freedesktop.locale1" send_member="SetVConsoleKeyboard"/> |
| 42 |
<allow send_destination="org.freedesktop.locale1" send_interface="org.freedesktop.locale1" send_member="SetX11Keyboard"/> |
| 43 |
</policy> |
| 44 |
</busconfig> |
| 45 |
EOF |
| 46 |
systemctl reload dbus.service || true |
| 47 |
|
| 48 |
# should activate daemon and work |
| 49 |
STATUS=`localectl` |
| 50 |
assert_in "X11 Layout:" "`localectl --no-pager`" |
| 51 |
|
| 52 |
# change layout |
| 53 |
assert_eq "`localectl --no-pager set-x11-keymap et pc101 2>&1`" "" |
| 54 |
sync |
| 55 |
|
| 56 |
case "${DEB_BUILD_PROFILES:-}" in |
| 57 |
*pkg.systemd.upstream*) |
| 58 |
# Upstream writes xorg.conf.d file |
| 59 |
assert_in 'Option "XkbLayout" "et' "`cat /etc/X11/xorg.conf.d/00-keyboard.conf`" |
| 60 |
assert_in 'Option "XkbModel" "pc101"' "`cat /etc/X11/xorg.conf.d/00-keyboard.conf`" |
| 61 |
;; |
| 62 |
*) |
| 63 |
# Debian console-setup config file |
| 64 |
assert_in 'XKBLAYOUT="\?et"\?' "`cat /etc/default/keyboard`" |
| 65 |
assert_in 'XKBMODEL="\?pc101"\?' "`cat /etc/default/keyboard`" |
| 66 |
! [ -f /etc/X11/xorg.conf.d/00-keyboard.conf ] |
| 67 |
;; |
| 68 |
esac |
| 69 |
|
| 70 |
STATUS=`localectl --no-pager` |
| 71 |
assert_in "X11 Layout: et" "$STATUS" |
| 72 |
assert_in "X11 Model: pc101" "$STATUS" |
| 73 |
|
| 74 |
case "${DEB_BUILD_PROFILES:-}" in |
| 75 |
*pkg.systemd.upstream*) ;; |
| 76 |
*) |
| 77 |
rm /etc/default/keyboard |
| 78 |
systemctl stop systemd-localed |
| 79 |
assert_in "X11 Layout: (unset)" "`localectl --no-pager`" |
| 80 |
;; |
| 81 |
esac |