summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-05-04 22:25:34 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2021-05-05 11:01:07 -0400
commit5b0ce3393b7f8853d3154ede930482446a7c0376 (patch)
tree3bf999fca929630e5922f714b1a0d89edb6cbd5a
parente61fe664a4a3fd9ae09ff1890cc1dc3285ab3634 (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-xetc/guix-install.sh47
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.
97prompt_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
96chk_require() 108chk_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 -" 139required to verify the Guix binary signature: $gpg_key_id.
128 exit_flag=yes 140Would 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).
145Fetch it with this command:
146
147 wget \"https://sv.gnu.org/people/viewgpg.php?user_id=$user_id\" -qO - | \
148sudo -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
452sys_authorize_build_farms() 474sys_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 477project'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
467sys_create_init_profile() 486sys_create_init_profile()