From c8a0cc4f4a3d46062edcfec308e1c29a8c8ec57b Mon Sep 17 00:00:00 2001 From: Eberhard Beilharz Date: Wed, 22 Feb 2023 19:40:22 +0100 Subject: [PATCH] fix(linux): Fix debian postinst script The ibus-keyman post-installation script failed, causing the entire installation to fail. This change removes `set -e` so that we try to run the rest of the commands even when one command should fail. Also accounts for ibus-daemon being started with the full path, and start ibus-daemon with fill path as well. (cherry picked from commit 9c1500fe57af0d11574c04c68da9ffea70ea1e1a) --- linux/debian/ibus-keyman.postinst | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/linux/debian/ibus-keyman.postinst b/linux/debian/ibus-keyman.postinst index 57c22b8d6d..15e37b467b 100644 --- a/linux/debian/ibus-keyman.postinst +++ b/linux/debian/ibus-keyman.postinst @@ -1,10 +1,13 @@ #!/bin/sh -set -e +# Don't call `set -e`. Even if some commands should fail, it's still +# worth running the rest of the commands. case "$1" in configure) + # (Re-)Start IBus + # if don't have sudo and ps then don't attempt to restart ibus if which sudo > /dev/null && which ps > /dev/null; then @@ -37,20 +40,20 @@ case "$1" in fi # Verify that it's running now - if [ ! -z $SUDO_USER ] && id $SUDO_USER > /dev/null 2>/dev/null; then - ! ibusdaemon=$(ps --user $SUDO_USER -o s= -o cmd | grep --regexp="^[^ZT] ibus-daemon .*--xim.*") - if [ "x$ibusdaemon" = "x" ]; then + if [ -n "$SUDO_USER" ] && id "$SUDO_USER" > /dev/null 2>/dev/null; then + ibusdaemon=$(ps --user "$SUDO_USER" -o s= -o cmd | grep --regexp="^[^ZT] \(/usr/bin/\)\?ibus-daemon .*--xim.*") + if [ "$ibusdaemon" = "" ]; then # otherwise try to start it for the user installing the package - if [ "x$is_gnome_shell" = "x1" ]; then - for session in $(loginctl show-user ${SUDO_USER} -p Sessions --value); do - case $(loginctl show-session ${session} -p Type --value) in - wayland) sudo -H -u "${SUDO_USER}" -i WAYLAND_DISPLAY=wayland-0 -- ibus-daemon -d -r --xim --panel disable;; - x11) sudo -H -u "${SUDO_USER}" -- ibus-daemon -d -r --xim --panel disable;; + if [ "$is_gnome_shell" = "1" ]; then + for session in $(loginctl show-user "${SUDO_USER}" -p Sessions --value); do + case $(loginctl show-session "${session}" -p Type --value) in + wayland) sudo -H -u "${SUDO_USER}" -i WAYLAND_DISPLAY=wayland-0 -- /usr/bin/ibus-daemon -d -r --xim --panel disable;; + x11) sudo -H -u "${SUDO_USER}" -- /usr/bin/ibus-daemon -d -r --xim --panel disable;; *) ;; esac done else - sudo -H -u "${SUDO_USER}" -- ibus-daemon -d -r --xim + sudo -H -u "${SUDO_USER}" -- /usr/bin/ibus-daemon -d -r --xim fi fi fi