From patchwork Fri Oct 7 05:31:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 43182 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 809B627BBE9; Fri, 7 Oct 2022 06:33:29 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4E0AD27BBEA for ; Fri, 7 Oct 2022 06:33:25 +0100 (BST) Received: from localhost ([::1]:56922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogfzA-0005Qs-Fw for patchwork@mira.cbaines.net; Fri, 07 Oct 2022 01:33:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogfyo-0005O6-HU for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34950) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogfyo-0001Dt-9B for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogfyo-0001z6-4b for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58345] [PATCH 1/3] guix-install.sh: Improve prompt_yes_no procedure. References: <20221007052738.20637-1-maxim.cournoyer@gmail.com> In-Reply-To: <20221007052738.20637-1-maxim.cournoyer@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 Oct 2022 05:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58345 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58345@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58345-submit@debbugs.gnu.org id=B58345.16651207407566 (code B ref 58345); Fri, 07 Oct 2022 05:33:02 +0000 Received: (at 58345) by debbugs.gnu.org; 7 Oct 2022 05:32:20 +0000 Received: from localhost ([127.0.0.1]:34025 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogfy4-0001xs-60 for submit@debbugs.gnu.org; Fri, 07 Oct 2022 01:32:19 -0400 Received: from mail-qt1-f179.google.com ([209.85.160.179]:37570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogfxy-0001xG-31 for 58345@debbugs.gnu.org; Fri, 07 Oct 2022 01:32:13 -0400 Received: by mail-qt1-f179.google.com with SMTP id l27so2269573qtv.4 for <58345@debbugs.gnu.org>; Thu, 06 Oct 2022 22:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rWhULu6LKnURKBcVWW85jL0NDjjMvJLC8Ae3SIK7RQ8=; b=KSkB+OyjXSQg6Y7XDc5QiORLa7rUGO8PYC9DR8z8Hq5f6iBkdMcX6z6lOd3b1+qOMn YcrtcbpB7KIQx0aPe924V5WtVm3IwHLYigA45Z8S1bTz9RBw4YdJlY+lFULINoDuB8N2 PtlOEAXjVR5HJsJIcuhURyEaKjn57fMO+aPA0dsSA7Yls3fAIiC5wz4DmQzRaM3pSgiV zhSvG54gyhBt5xFKLDI51vasly4jYpFAZnPEXAJM7QOh7TvCPAvuuHv1rW6d9YbxfNy1 uAmtbHlZD2hh230H1RzI1bAA8wEvJG9GINcw66xM3rSzz6o5iube5wBlXlb6uDUm6ORR 34kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rWhULu6LKnURKBcVWW85jL0NDjjMvJLC8Ae3SIK7RQ8=; b=nnK18Mv6YpOv+ZtrS3kScn9h7uLfmsI+hm2Z3AVuf8/vsVKZDPXdJo+LBjkRQLJ0Df YtBNOKsiVBawCki8WDfk1KmDqakCW3EAWYVwFsKx9Imq7BOUG+9EeKrYZhai193Z/Qyh ZccN1KRYU1+s9rzuEhTT4CwAajJrjcqZfHgv9Vod8/Z2HBNa5TaMdQCeeOwj0cM7ay6w wcnVfn0UZkCxLKq08yU4m1MYLTpZhXqFeg7+zIhq29G4ZP/cPiKxOMHh/IxuRTBKBBtb 1WGUXLFEAeQ8ZfOtPXJnr7/rZvQCTINjiCicaX0sl8eQoFx7x0lJ30SjLzNeLOezUmKO kJHg== X-Gm-Message-State: ACrzQf1W64SxF+1e0aOPZuseBCxpoI1HjQcQBhruAMfJYSn6fizrDl05 rbGnZeFf9sRmv2cuP2CstTV909O/NiE= X-Google-Smtp-Source: AMsMyM69M5Irde1k0F8QQZGgKhxa+HH6Qd57P9ZaJL9lr2hX2EABJXLB2wkKucmabduN2Ml8VZ/QIw== X-Received: by 2002:a05:622a:1181:b0:35b:b57d:fb14 with SMTP id m1-20020a05622a118100b0035bb57dfb14mr2974524qtk.605.1665120724402; Thu, 06 Oct 2022 22:32:04 -0700 (PDT) Received: from localhost.localdomain ([2607:fad8:4:3::1005]) by smtp.gmail.com with ESMTPSA id ff13-20020a05622a4d8d00b0035d420c4ba7sm1367801qtb.54.2022.10.06.22.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 22:32:03 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 7 Oct 2022 01:31:58 -0400 Message-Id: <20221007053200.21177-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * etc/guix-install.sh (_flush): New function. (prompt_yes_no): Clear input, then only read the first character, silently. Add the [Yes/no] string to the message. When a newline is entered by the user, treat it as the default value, which is "yes". (chk_gpg_keyring): Remove "(yes/no)" from the prompt message. (configure_substitute_discovery): Likewise. (sys_authorize_build_farms): Likewise. --- etc/guix-install.sh | 28 +++++++++++++++++++--------- 1 file 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 # Copyright © 2021 Jakub Kądziołka # Copyright © 2021 Chris Marusich -# Copyright © 2021 Maxim Cournoyer +# Copyright © 2021, 2022 Maxim Cournoyer # # 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" From patchwork Fri Oct 7 05:31:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 43183 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id AFC9927BBEA; Fri, 7 Oct 2022 06:33:44 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 72AFF27BBE9 for ; Fri, 7 Oct 2022 06:33:44 +0100 (BST) Received: from localhost ([::1]:37276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogfzT-0005uB-KY for patchwork@mira.cbaines.net; Fri, 07 Oct 2022 01:33:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogfyo-0005O3-18 for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogfyn-0001Dd-PS for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogfyn-0001yz-Jx for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58345] [PATCH 2/3] guix-install.sh: Introduce 'die' utility function. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 Oct 2022 05:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58345 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58345@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58345-submit@debbugs.gnu.org id=B58345.16651207357546 (code B ref 58345); Fri, 07 Oct 2022 05:33:01 +0000 Received: (at 58345) by debbugs.gnu.org; 7 Oct 2022 05:32:15 +0000 Received: from localhost ([127.0.0.1]:34022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogfy2-0001xe-Pv for submit@debbugs.gnu.org; Fri, 07 Oct 2022 01:32:15 -0400 Received: from mail-qt1-f173.google.com ([209.85.160.173]:42939) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogfy0-0001xJ-Kf for 58345@debbugs.gnu.org; Fri, 07 Oct 2022 01:32:13 -0400 Received: by mail-qt1-f173.google.com with SMTP id w28so294708qtv.9 for <58345@debbugs.gnu.org>; Thu, 06 Oct 2022 22:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/4gYhSSvxypjpII3diEaFAK8wifRCAsT//Bt3d9tWtw=; b=o2qTVqKOx3YUa3iMScFG0mmgogYQC9oJnm9P0OIi3lYKbaqZmXOnVnZQhv5X1fT645 7KXmg0kIonfpw9kSXVPLXW0W2YVyUWsV9+VF7AfhMFZWx8aLd3vn6VKKb3tMRNE50oLG aodQiBn97DRVwmlJLZAIRdWNNmwTg4XTej5BCEN+vmvwInHGb1JH2IN9q8FBIkJ4JXDR YrmsJ1NM/XnL2VqEAarc+ceO+8zJ5X4ynJCJnUes5oIlfJlcIdXER+U85dgiXvpI2dhT g5zxbuJwQ9X6QA4JkltQl5G23YP67Nc3h9wcqlw8g17ud1A9ycoL4qo2QZAeKbKhf17n uO8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/4gYhSSvxypjpII3diEaFAK8wifRCAsT//Bt3d9tWtw=; b=542E/5gLsPtOZnvdyZeFGV7nih2nUQkpnNu3AMPM/Cp9E2O8nG2/zeP+0rfjI/ZnFP emP6SwLr6+DgAkD3KiHNIWw28mt0Kqpuyja1SdVkk67Xm8zee8PThVSwjvnKVcsJhYDb yjUP/UFLDZcjDp0njiGewzancDu0bhDIUKwJ/1qWoeytJpKg8d/dhGDYyj33lJzqVyUq y6FD+7V5V04C1tLcBIpwkPwFKviDUoHjnDJJm9UxJnc43V3r6rWy1UHbnJrUTS6dCWg5 4+txBKYTKWyBAp0YmcGyONRKhg6+1uciSRY59U3cRBASKtXtLFMNx1dpgicRLOIGtQRn NFKQ== X-Gm-Message-State: ACrzQf2XLP3VB5S/m0UJZ4pPHTLMXzaU2hYxpMLqJ7BwqqZk7ayHoUrS e5DhsZA2etdUTgl9YvmLHRWdnuiCJEc= X-Google-Smtp-Source: AMsMyM6LBewZEfqWNFP9o3RHo3z7Ed3uKzc6i0KTEOC80D/f2fb7Lv/GPuVNBkfoIIieQUSR/HJU7A== X-Received: by 2002:a05:622a:2c8:b0:391:b8ab:c281 with SMTP id a8-20020a05622a02c800b00391b8abc281mr3086306qtx.188.1665120727012; Thu, 06 Oct 2022 22:32:07 -0700 (PDT) Received: from localhost.localdomain ([2607:fad8:4:3::1005]) by smtp.gmail.com with ESMTPSA id ff13-20020a05622a4d8d00b0035d420c4ba7sm1367801qtb.54.2022.10.06.22.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 22:32:06 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 7 Oct 2022 01:31:59 -0400 Message-Id: <20221007053200.21177-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007053200.21177-1-maxim.cournoyer@gmail.com> References: <20221007053200.21177-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * etc/guix-install.sh (die): New function. (chk_sys_arch): Use it. (guix_get_bin_list, guix_get_bin, sys_create_store): Likewise. --- etc/guix-install.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 8c05d19657..6bf70b7941 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -99,6 +99,11 @@ _flush() done } +die() +{ + _err "${ERR}$*" +} + # Return true if user answered yes, false otherwise. It defaults to "yes" # when a single newline character is input. # $1: The prompt question. @@ -230,8 +235,7 @@ chk_sys_arch() local arch=powerpc64le ;; *) - _err "${ERR}Unsupported CPU type: ${arch}" - exit 1 + die "Unsupported CPU type: ${arch}" esac case "$os" in @@ -239,8 +243,7 @@ chk_sys_arch() local os=linux ;; *) - _err "${ERR}Your operation system (${os}) is not supported." - exit 1 + die "Your operation system (${os}) is not supported." esac ARCH_OS="${arch}-${os}" @@ -295,8 +298,7 @@ guix_get_bin_list() if [[ "${#bin_ver_ls}" -ne "0" ]]; then _msg "${PAS}Release for your system: ${default_ver}" else - _err "${ERR}Could not obtain list of Guix releases." - exit 1 + die "Could not obtain list of Guix releases." fi # Use default to download according to the list and local ARCH_OS. @@ -321,8 +323,7 @@ guix_get_bin() "${url}/${bin_ver}.tar.xz" "${url}/${bin_ver}.tar.xz.sig"; then _msg "${PAS}download completed." else - _err "${ERR}could not download ${url}/${bin_ver}.tar.xz." - exit 1 + die "could not download ${url}/${bin_ver}.tar.xz." fi pushd "${dl_path}" >/dev/null @@ -330,8 +331,7 @@ guix_get_bin() _msg "${PAS}Signature is valid." popd >/dev/null else - _err "${ERR}could not verify the signature." - exit 1 + die "could not verify the signature." fi } @@ -343,8 +343,7 @@ sys_create_store() _debug "--- [ ${FUNCNAME[0]} ] ---" if [[ -e "/var/guix" || -e "/gnu" ]]; then - _err "${ERR}A previous Guix installation was found. Refusing to overwrite." - exit 1 + die "A previous Guix installation was found. Refusing to overwrite." fi cd "$tmp_path" From patchwork Fri Oct 7 05:32:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 43184 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7E48227BBEA; Fri, 7 Oct 2022 06:34:18 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 43D8527BBE9 for ; Fri, 7 Oct 2022 06:34:18 +0100 (BST) Received: from localhost ([::1]:37406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogg01-0006pL-6L for patchwork@mira.cbaines.net; Fri, 07 Oct 2022 01:34:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogfyo-0005O7-Tj for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogfyo-0001Dy-M3 for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ogfyo-0001zD-Hw for guix-patches@gnu.org; Fri, 07 Oct 2022 01:33:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58345] [PATCH 3/3] guix-install.sh: Add Bash prompt customization option. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 07 Oct 2022 05:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58345 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58345@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58345-submit@debbugs.gnu.org id=B58345.16651207407572 (code B ref 58345); Fri, 07 Oct 2022 05:33:02 +0000 Received: (at 58345) by debbugs.gnu.org; 7 Oct 2022 05:32:20 +0000 Received: from localhost ([127.0.0.1]:34027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogfy8-0001xz-0Z for submit@debbugs.gnu.org; Fri, 07 Oct 2022 01:32:20 -0400 Received: from mail-qt1-f181.google.com ([209.85.160.181]:42948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ogfy3-0001xP-HQ for 58345@debbugs.gnu.org; Fri, 07 Oct 2022 01:32:15 -0400 Received: by mail-qt1-f181.google.com with SMTP id w28so294737qtv.9 for <58345@debbugs.gnu.org>; Thu, 06 Oct 2022 22:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GXYGEE/LAq25O6/U8RO/+TCp1qXafjutwUabAClZ0ec=; b=bWpwcJyaeQXwReUuYWNQKjL0eK/nzj4UtS0tN1gSxtemd3htt5ynlJ1lem25R4UphX ecxljdf3cs6q50k+ufW4bLy3rebDMrIjqq0KKwablGGRbKd0NRam2ZoKVZiU1LxBAT2V kIXTANxum4EES7MErtodUX0YXmdUFKIEUm5c7FXS8Ab1hIkmySUNEbsW4sZFWleJ3LkG /JRdvnfCCxyjTaRKB0+ozFXYaThxEiCbhtzuak/P/Xiout3st7EohGYj7Tzx/4d4ct1r /g7ZQfOHuaWmisM3fhBJJDqy/xI01m8yjJOeFdLSVFO2y/Tn5oqzgjR1DyfCZmBAAa8j yPug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GXYGEE/LAq25O6/U8RO/+TCp1qXafjutwUabAClZ0ec=; b=njfPe8jX+ftMW03UG5KqEctbz7NfQekNmmE6t2/v5WJojiQ/8F9jwRBsqHQN46IegK l5WhA+dxBcHGU5/8tYq2pZ1pQjHw79/6NylMjeUE93GALYnx4gmWiQ2N2q0ijM+7gzSr u1ZXsmRGoQ+KSYx0swdEMcTVklxsQCKV8FLNqSq6MEXrm4Ph5mAt/2ZML+H4M51klyjH EdEdTmuPsDAdll0gXr3nmWDQzHkg/3aE6tW1ggaff5VX9f5x7qhi7igwaPTTswszipUV L3p69gbrvQmdRLvu71b/IrfwRzKeiG1bTWr9aq7ojOwGj54/QslNnW/c3UM5Xb0ZtEiN i/lA== X-Gm-Message-State: ACrzQf2tWOFjUKU8RFPn1ng8GXp6mJYT0ZBVyfIzpYeQTpsfAiNaCv/l GS3cVHO8whNUL1jdFTBXq4a1Ap5+7oQ= X-Google-Smtp-Source: AMsMyM7pRYG2yIDGKxajsnVM18XCo8xDrQuxjj4VhM9BTSrP7fUiUg6B0msUPnKaJ9yfnxAalBn2gw== X-Received: by 2002:ac8:5745:0:b0:35c:9f9b:9d56 with SMTP id 5-20020ac85745000000b0035c9f9b9d56mr3008906qtx.103.1665120729975; Thu, 06 Oct 2022 22:32:09 -0700 (PDT) Received: from localhost.localdomain ([2607:fad8:4:3::1005]) by smtp.gmail.com with ESMTPSA id ff13-20020a05622a4d8d00b0035d420c4ba7sm1367801qtb.54.2022.10.06.22.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 22:32:09 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 7 Oct 2022 01:32:00 -0400 Message-Id: <20221007053200.21177-3-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007053200.21177-1-maxim.cournoyer@gmail.com> References: <20221007053200.21177-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * etc/guix-install.sh (sys_customize_bashrc): New function. (main): Use it. --- etc/guix-install.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 6bf70b7941..2b304d1bdc 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -566,6 +566,23 @@ sys_create_shell_completion() _msg "${PAS}installed shell completion" } +sys_customize_bashrc() +{ + prompt_yes_no "Customize users Bash shell prompt for Guix?" || return + for bashrc in /home/*/.bashrc /root/.bashrc; do + test -f "$bashrc" || continue + grep -Fq '$GUIX_ENVIRONMENT' "$bashrc" && continue + cp "${bashrc}" "${bashrc}.bak" + echo ' +if [ -n "$GUIX_ENVIRONMENT" ]; then + if [[ $PS1 =~ (.*)"\\$" ]]; then + PS1="${BASH_REMATCH[1]} [env]\\\$ " + fi +fi +' >> "$bashrc" + done + _msg "${PAS}Bash shell prompt successfully customized for Guix" +} welcome() { @@ -635,6 +652,7 @@ main() sys_authorize_build_farms sys_create_init_profile sys_create_shell_completion + sys_customize_bashrc _msg "${INF}cleaning up ${tmp_path}" rm -r "${tmp_path}"