From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id h7lSLwwgkmBKCwEAgWs5BA (envelope-from ) for ; Wed, 05 May 2021 06:33:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id wHt2KgwgkmCrcAAAB5/wlQ (envelope-from ) for ; Wed, 05 May 2021 04:33:16 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 623482012D for ; Wed, 5 May 2021 06:33:16 +0200 (CEST) Received: from localhost ([::1]:49508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9Dn-0008Dm-I0 for larch@yhetil.org; Wed, 05 May 2021 00:33:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9Da-00082J-SL for guix-patches@gnu.org; Wed, 05 May 2021 00:33:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45904) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1le9Da-0002uT-Kt for guix-patches@gnu.org; Wed, 05 May 2021 00:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1le9Da-0006lp-IJ for guix-patches@gnu.org; Wed, 05 May 2021 00:33:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48233] [PATCH 2/3] guix-install.sh: Propose automatically fetching OpenPGP keys. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 05 May 2021 04:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48233 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 48233@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 48233-submit@debbugs.gnu.org id=B48233.162018914925999 (code B ref 48233); Wed, 05 May 2021 04:33:02 +0000 Received: (at 48233) by debbugs.gnu.org; 5 May 2021 04:32:29 +0000 Received: from localhost ([127.0.0.1]:57446 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1le9D1-0006lC-Fr for submit@debbugs.gnu.org; Wed, 05 May 2021 00:32:29 -0400 Received: from mail-qt1-f177.google.com ([209.85.160.177]:43637) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1le9Cq-0006kh-Vy for 48233@debbugs.gnu.org; Wed, 05 May 2021 00:32:21 -0400 Received: by mail-qt1-f177.google.com with SMTP id a18so279803qtj.10 for <48233@debbugs.gnu.org>; Tue, 04 May 2021 21:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vop7pnRhyK4/rtiexZP8DFM5Q3qj8ME8JbhLad7dvvY=; b=X3zdk8HmKib2FTUG9xwKWapjjMI4qKZKXBKQq+gXGzIlVEaxB2LAAgaqVagbYrA/Wv Q7Rsr+z1sVnpqKK7p5XDo6SN9c+VxRxLLElpDBKr9od6R8LQ1nMDu3WkrNE+NFy2yf57 AlKQ81p2xTAbG8zgDQ2dRiE02xgT4Q4yZyzCLclMkoh0fp9xrBqBbIdA3tKTGiZQ6fQe uIRh/XUfmHug64XL/s3P5NvK/sXy54ntm+jhhk86tHkNv1IAo5aAweKtptHK3LsKX5Qp 1T52HT7S0KWX8avHBcdp+Lk6EHYk0zfOgbEhLAUyEXK9W182O2OcJUD2fOqYUNhVPG5E HSVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vop7pnRhyK4/rtiexZP8DFM5Q3qj8ME8JbhLad7dvvY=; b=IG8MpueXzAKKNokr9G9HAEXrYojBEWRuksbaBFeEMKEoV/UVYPN6c+w0Oz1cNshR72 As1H5lgm2Ex9AvIYhoUGuM6Uo4u5urkUhkYHQmVyqSzrnKusi5nynC91l+5jhAHAmrF4 oe7MrLG6XrT94Bv28vuLhiKzuw9fyUFLU7AEMFi5dgYVsKbC5GuJUVDqkSJyeFVEeZDT ivK+aNPTknnz9FXK5Kh0ueJ/HBcMP+2KGAFhpDYa7khFdvbe4uuI/xtb+1uiGs/pz4XO 5p+3fbJbtCbJ3dw2BV2rjKfqa79W7DyRZ+KCtDsqak0GewYg+mb+/GgunSgF4ph+XUOP i6ig== X-Gm-Message-State: AOAM532d82J9btaQqMxCU4pFbQ5U2/e1jJBRkvnY6rNvsG6ml7oBa4G2 nC++6WZxLRY+MeCSEv2AI9LPK0g3XPxJAapt X-Google-Smtp-Source: ABdhPJx9KN75vgdTX/wHBkof1JDPUd8BlSlpGF2xUAF5f3t24NFOsRPd2dCkc29zwyysqGd1CyjtHg== X-Received: by 2002:a05:622a:1312:: with SMTP id v18mr25671835qtk.106.1620189131394; Tue, 04 May 2021 21:32:11 -0700 (PDT) Received: from localhost.localdomain (mtl.savoirfairelinux.net. [208.88.110.46]) by smtp.gmail.com with ESMTPSA id l71sm12702122qke.27.2021.05.04.21.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 21:32:11 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 5 May 2021 00:32:01 -0400 Message-Id: <20210505043202.24636-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210505043202.24636-1-maxim.cournoyer@gmail.com> References: <20210505043202.24636-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620189196; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=vop7pnRhyK4/rtiexZP8DFM5Q3qj8ME8JbhLad7dvvY=; b=sqNxPb+3KOWADXmG0PpNB37C7w8wl0qI+McYlSkGMYT1UD8gEfL5Pd54phYWyMvnldCuuH CN+VABUFa0DheFrtTlDLHDdMcbLeCGFSxAcpgGrI2Y1BXkcq2Yas5NBGrjxB3msQZKr4jJ zmLErlGcTOl/hiXg++IJCszXkOJ8H08dnEuqOl75blq7W0tCNHeXmaVf99dHxla7ffIZVa for0nwORfiSlYkCnyFcJgp5tutpBpy9Vf+sXYpdim5/r/Eh+R0D3Ovu7zKdiMXMGEDQMZJ UhUIHIcOCI4yk0Th/xvIM8g+HqsV4jCqpXLEayI96/mcZfmsHZIxgE82qJz+OQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620189196; a=rsa-sha256; cv=none; b=TpqQpOGofvAV0ySbXL4Mq5lmElXbsysdFgbzzp803t2nN6buvRiGHDilUV1gplBfdguqtx UqEKpefsMlyUlQckFzZrh9Yt3Lg4PM6VeIqkRzZb5BdGV5hIPYo9gKvmmr2EgvdBIuDExT X3IlT00gKoUfLnnLtSXwFVyx92KWrMn1BoJpHvMEnuKomqRNLUHrkEPCMjhAc19RY5egoe Jp6ZSlPAy0Fvxp8IlUV5jOAI4g2K/iWOYpvypMvLjZRxLkmfYfRJQEVp7SbigGaFKpasu4 7lhqtuFiKrRgHD8yMPFH7EPlwmQVdXFrbPBH9K/Dke2C29HVbUvyqqTcr0MazQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=X3zdk8Hm; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 2.64 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=X3zdk8Hm; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 623482012D X-Spam-Score: 2.64 X-Migadu-Scanner: scn0.migadu.com X-TUID: V+PX1Hb15RBz 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