Skip to content

Commit b701c40

Browse files
committed
code simlification
1 parent bb5dd08 commit b701c40

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

debian/usability-misc.postinst

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,29 @@ generate_grub_keyboard_layouts_maybe() {
5151
fi
5252

5353
if ! command -v update-grub >/dev/null 2>&1; then
54-
true "INFO: Skipping 'set-grub-keymap --build-all' because update-grub is unavailable, ok."
54+
true "INFO: Skipping 'set-grub-keymap --build-all' because command 'update-grub' is unavailable, ok."
5555
return 0
5656
fi
5757

5858
## > /usr/bin/set-grub-keymap: ERROR: Cannot proceed with generating GRUB keymap because requirements are unavailable. The 'ckbcomp' program is unavailable in the PATH environment variable or not installed. Is package 'console-setup' or 'console-setup-mini' installed?
5959
if ! command -v ckbcomp >/dev/null 2>&1; then
60-
true "INFO: Skipping 'set-grub-keymap --build-all' because ckbcomp is unavailable, ok."
60+
true "INFO: Skipping 'set-grub-keymap --build-all' because command 'ckbcomp' is unavailable, ok."
6161
return 0
6262
fi
6363

64-
if ! [ -d /boot/grub/kb_layouts ]; then
65-
if timeout --kill-after 5 5 localectl &>/dev/null; then
66-
## Test run of 'localectl' was successful.
67-
if ischroot; then
68-
true "INFO: Skipping 'set-grub-keymap --build-all' because postinst is running in chroot, ok."
69-
return 0
70-
else
71-
## Use '--no-update-grub' because this postinst script will run 'update-grub' if available anyhow.
72-
if set-grub-keymap --build-all --no-update-grub >/dev/null 2>&1; then
73-
printf '%s\n' "INFO: Command 'set-grub-keymap --build-all' success."
74-
else
75-
printf '%s\n' "INFO: Minor issue. Command 'set-grub-keymap --build-all' failed. This means, the GRUB boot menu will have no keyboard layout selection menu, which is a minor usability feature. For most users, no action is required. If you know to need this feature, please execute 'sudo set-grub-keymap --build-all' (in sysmaint session)."
76-
return 0
77-
fi
78-
fi
79-
else
80-
true "INFO: Skipping 'set-grub-keymap --build-all' because localectl failed, ok."
81-
return 0
82-
fi
64+
if [ -d /boot/grub/kb_layouts ]; then
65+
true "INFO: Skipping 'set-grub-keymap --build-all' because file '/boot/grub/kb_layouts' already exists, ok."
66+
return 0
8367
fi
8468

69+
## Use '--no-update-grub' because this postinst script will run 'update-grub' if available anyhow.
70+
if ! set-grub-keymap --build-all --no-update-grub >/dev/null 2>&1; then
71+
printf '%s\n' "INFO: Minor issue. Command 'set-grub-keymap --build-all' failed. This means, the GRUB boot menu will have no keyboard layout selection menu, which is a minor usability feature. For most users, no action is required. If you know to need this feature, please execute 'sudo set-grub-keymap --build-all' (in sysmaint session)."
72+
return 0
73+
fi
74+
75+
printf '%s\n' "INFO: Command 'set-grub-keymap --build-all' success."
76+
8577
mkdir -p "/var/lib/usability-misc/do_once"
8678
touch "/var/lib/usability-misc/do_once/${FUNCNAME}_version_1"
8779
}

0 commit comments

Comments
 (0)