From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 48233@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#48233] [PATCH 2/3] guix-install.sh: Propose automatically fetching OpenPGP keys.
Date: Wed, 5 May 2021 00:32:01 -0400 [thread overview]
Message-ID: <20210505043202.24636-2-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20210505043202.24636-1-maxim.cournoyer@gmail.com>
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.
---
etc/guix-install.sh | 47 +++++++++++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 11836f2c33..3d2936c873 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -92,6 +92,18 @@ _debug()
fi
}
+# Return true if user answered yes, false otherwise.
+# $1: The prompt question.
+prompt_yes_no() {
+ while true; do
+ read -rp "$1" yn
+ case $yn in
+ [Yy]*) return 0;;
+ [Nn]*) return 1;;
+ *) _msg "Please answer yes or no."
+ esac
+ done
+}
chk_require()
{ # Check that every required command is available.
@@ -123,9 +135,19 @@ chk_gpg_keyring()
# Without --dry-run this command will create a ~/.gnupg owned by root on
# systems where gpg has never been used, causing errors and confusion.
if ! gpg --dry-run --list-keys "$gpg_key_id" >/dev/null 2>&1; then
- _err "${ERR}Missing OpenPGP public key ($gpg_key_id). Fetch it with this command:"
- echo " wget \"https://sv.gnu.org/people/viewgpg.php?user_id=$user_id\" -qO - | sudo -i gpg --import -"
- exit_flag=yes
+ 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
+ wget "https://sv.gnu.org/people/viewgpg.php?user_id=$user_id" \
+ -qO - | gpg --import -
+ else
+ _err "${ERR}Missing OpenPGP public key ($gpg_key_id).
+Fetch it with this command:
+
+ wget \"https://sv.gnu.org/people/viewgpg.php?user_id=$user_id\" -qO - | \
+sudo -i gpg --import -"
+ exit_flag=yes
+ fi
fi
done
if [ "$exit_flag" = yes ]; then
@@ -450,17 +472,14 @@ sys_enable_guix_daemon()
sys_authorize_build_farms()
{ # authorize the public key of the build farm
- while true; do
- read -rp "Permit downloading pre-built package binaries from the project's build farm? (yes/no) " yn
- case $yn in
- [Yy]*) guix archive --authorize < "~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub" &&
- _msg "${PAS}Authorized public key for ci.guix.gnu.org";
- break;;
- [Nn]*) _msg "${INF}Skipped authorizing build farm public keys"
- break;;
- *) _msg "Please answer yes or no.";
- esac
- done
+ if prompt_yes_no "Permit downloading pre-built package binaries from the \
+project's build farm? (yes/no) "; 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"
+ else
+ _msg "${INF}Skipped authorizing build farm public keys"
+ fi
}
sys_create_init_profile()
--
2.31.1
next prev parent reply other threads:[~2021-05-05 4:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-05 4:10 [bug#48233] [PATCH 0/3] Modest improvements to the guix-install.sh script Maxim Cournoyer
2021-05-05 4:32 ` [bug#48233] [PATCH 1/3] guix-install.sh: Please the shellcheck linter Maxim Cournoyer
2021-05-05 4:32 ` Maxim Cournoyer [this message]
2021-05-05 4:32 ` [bug#48233] [PATCH 3/3] guix-install.sh: Exit early if Guix is already installed Maxim Cournoyer
2021-05-05 10:50 ` [bug#48233] [PATCH 1/3] guix-install.sh: Please the shellcheck linter Julien Lepiller
2021-05-05 15:00 ` bug#48233: " Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210505043202.24636-2-maxim.cournoyer@gmail.com \
--to=maxim.cournoyer@gmail.com \
--cc=48233@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.