diff options
-rwxr-xr-x | etc/guix-install.sh | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 300681e111..8c05d19657 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -9,7 +9,7 @@ # Copyright © 2020 Daniel Brooks <db48x@db48x.net> # Copyright © 2021 Jakub Kądziołka <kuba@kadziolka.net> # Copyright © 2021 Chris Marusich <cmmarusich@gmail.com> -# Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> +# Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> # # This file is part of GNU Guix. # @@ -92,15 +92,25 @@ _debug() fi } -# Return true if user answered yes, false otherwise. +_flush() +{ + while read -t0; do + read -N1 + done +} + +# Return true if user answered yes, false otherwise. It defaults to "yes" +# when a single newline character is input. # $1: The prompt question. prompt_yes_no() { while true; do - read -rp "$1 " yn + _flush + read -N1 -rsp "$1 [Y/n]" yn case $yn in - [Yy]*) return 0;; - [Nn]*) return 1;; - *) _msg "Please answer yes or no." + $'\n') echo && return 0;; + [Yy]*) echo && return 0;; + [Nn]*) echo && return 1;; + *) echo && _msg "Please answer yes or no." esac done } @@ -137,7 +147,7 @@ chk_gpg_keyring() if ! gpg --dry-run --list-keys "$gpg_key_id" >/dev/null 2>&1; then if prompt_yes_no "${INF}The following OpenPGP public key is \ required to verify the Guix binary signature: $gpg_key_id. -Would you like me to fetch it for you? (yes/no)"; then +Would you like me to fetch it for you?"; then wget "https://sv.gnu.org/people/viewgpg.php?user_id=$user_id" \ --no-verbose -O- | gpg --import - else @@ -254,7 +264,7 @@ chk_sys_nscd() configure_substitute_discovery() { if grep -q -- '--discover=no' "$1" && \ prompt_yes_no "Would you like the Guix daemon to automatically \ -discover substitute servers on the local network? (yes/no)"; then +discover substitute servers on the local network?"; then sed -i 's/--discover=no/--discover=yes/' "$1" fi } @@ -490,7 +500,7 @@ sys_enable_guix_daemon() sys_authorize_build_farms() { # authorize the public key of the build farm if prompt_yes_no "Permit downloading pre-built package binaries from the \ -project's build farm? (yes/no)"; then +project's build farm?"; then guix archive --authorize \ < ~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub \ && _msg "${PAS}Authorized public key for ci.guix.gnu.org" |