diff options
| author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2021-05-04 22:25:34 -0400 |
|---|---|---|
| committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2021-05-05 11:01:07 -0400 |
| commit | 5b0ce3393b7f8853d3154ede930482446a7c0376 (patch) | |
| tree | 3bf999fca929630e5922f714b1a0d89edb6cbd5a | |
| parent | e61fe664a4a3fd9ae09ff1890cc1dc3285ab3634 (diff) | |
guix-install.sh: Propose automatically fetching OpenPGP keys.
Via, for example, yes | ./guix-install.sh.
* etc/guix-install.sh (prompt_yes_no): New procedure.
(chk_gpg_keyring, sys_authorize_build_farms): Use it.
| -rwxr-xr-x | etc/guix-install.sh | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 6a8f7a20c1d..9f7bd2038a6 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh | |||
| @@ -92,6 +92,18 @@ _debug() | |||
| 92 | fi | 92 | fi |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | # Return true if user answered yes, false otherwise. | ||
| 96 | # $1: The prompt question. | ||
| 97 | prompt_yes_no() { | ||
| 98 | while true; do | ||
| 99 | read -rp "$1" yn | ||
| 100 | case $yn in | ||
| 101 | [Yy]*) return 0;; | ||
| 102 | [Nn]*) return 1;; | ||
| 103 | *) _msg "Please answer yes or no." | ||
| 104 | esac | ||
| 105 | done | ||
| 106 | } | ||
| 95 | 107 | ||
| 96 | chk_require() | 108 | chk_require() |
| 97 | { # Check that every required command is available. | 109 | { # Check that every required command is available. |
| @@ -123,9 +135,19 @@ chk_gpg_keyring() | |||
| 123 | # Without --dry-run this command will create a ~/.gnupg owned by root on | 135 | # Without --dry-run this command will create a ~/.gnupg owned by root on |
| 124 | # systems where gpg has never been used, causing errors and confusion. | 136 | # systems where gpg has never been used, causing errors and confusion. |
| 125 | if ! gpg --dry-run --list-keys "$gpg_key_id" >/dev/null 2>&1; then | 137 | if ! gpg --dry-run --list-keys "$gpg_key_id" >/dev/null 2>&1; then |
| 126 | _err "${ERR}Missing OpenPGP public key ($gpg_key_id). Fetch it with this command:" | 138 | if prompt_yes_no "${INF}The following OpenPGP public key is \ |
| 127 | echo " wget \"https://sv.gnu.org/people/viewgpg.php?user_id=$user_id\" -qO - | sudo -i gpg --import -" | 139 | required to verify the Guix binary signature: $gpg_key_id. |
| 128 | exit_flag=yes | 140 | Would you like me to fetch it for you? (yes/no)"; then |
| 141 | wget "https://sv.gnu.org/people/viewgpg.php?user_id=$user_id" \ | ||
| 142 | -qO - | gpg --import - | ||
| 143 | else | ||
| 144 | _err "${ERR}Missing OpenPGP public key ($gpg_key_id). | ||
| 145 | Fetch it with this command: | ||
| 146 | |||
| 147 | wget \"https://sv.gnu.org/people/viewgpg.php?user_id=$user_id\" -qO - | \ | ||
| 148 | sudo -i gpg --import -" | ||
| 149 | exit_flag=yes | ||
| 150 | fi | ||
| 129 | fi | 151 | fi |
| 130 | done | 152 | done |
| 131 | if [ "$exit_flag" = yes ]; then | 153 | if [ "$exit_flag" = yes ]; then |
| @@ -451,17 +473,14 @@ sys_enable_guix_daemon() | |||
| 451 | 473 | ||
| 452 | sys_authorize_build_farms() | 474 | sys_authorize_build_farms() |
| 453 | { # authorize the public key of the build farm | 475 | { # authorize the public key of the build farm |
| 454 | while true; do | 476 | if prompt_yes_no "Permit downloading pre-built package binaries from the \ |
| 455 | read -rp "Permit downloading pre-built package binaries from the project's build farm? (yes/no) " yn | 477 | project's build farm? (yes/no) "; then |
| 456 | case $yn in | 478 | guix archive --authorize \ |
| 457 | [Yy]*) guix archive --authorize < "~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub" && | 479 | < "~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub" \ |
| 458 | _msg "${PAS}Authorized public key for ci.guix.gnu.org"; | 480 | && _msg "${PAS}Authorized public key for ci.guix.gnu.org" |
| 459 | break;; | 481 | else |
| 460 | [Nn]*) _msg "${INF}Skipped authorizing build farm public keys" | 482 | _msg "${INF}Skipped authorizing build farm public keys" |
| 461 | break;; | 483 | fi |
| 462 | *) _msg "Please answer yes or no."; | ||
| 463 | esac | ||
| 464 | done | ||
| 465 | } | 484 | } |
| 466 | 485 | ||
| 467 | sys_create_init_profile() | 486 | sys_create_init_profile() |
