From patchwork Wed May 5 04:32:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 29123 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 A3B1A27BC82; Wed, 5 May 2021 05:33:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D960F27BC81 for ; Wed, 5 May 2021 05:33:09 +0100 (BST) Received: from localhost ([::1]:49088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9Dh-00082m-3O for patchwork@mira.cbaines.net; Wed, 05 May 2021 00:33:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9Da-000826-2G for guix-patches@gnu.org; Wed, 05 May 2021 00:33:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1le9DZ-0002ti-QX for guix-patches@gnu.org; Wed, 05 May 2021 00:33:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1le9DZ-0006lb-O4 for guix-patches@gnu.org; Wed, 05 May 2021 00:33:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48233] [PATCH 1/3] guix-install.sh: Please the shellcheck linter. References: <87czu5lspv.fsf@gmail.com> In-Reply-To: <87czu5lspv.fsf@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 05 May 2021 04:33:01 +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.162018914725986 (code B ref 48233); Wed, 05 May 2021 04:33:01 +0000 Received: (at 48233) by debbugs.gnu.org; 5 May 2021 04:32:27 +0000 Received: from localhost ([127.0.0.1]:57442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1le9Cv-0006l2-PG for submit@debbugs.gnu.org; Wed, 05 May 2021 00:32:27 -0400 Received: from mail-qv1-f46.google.com ([209.85.219.46]:41942) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1le9Cq-0006kg-Qz for 48233@debbugs.gnu.org; Wed, 05 May 2021 00:32:20 -0400 Received: by mail-qv1-f46.google.com with SMTP id l19so624205qvu.8 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:mime-version :content-transfer-encoding; bh=/S7Ka7E16PV/VR5vThVHFJ7XXACY5XQkVsoo+wY8kGQ=; b=faZmRzEcBfXxvrIEGEl7yg6xujRQq67QSi5W9mNQsUFsiXVu/nC3sZP0npvjv2kvLp V1FytLtQIdUIFw1d3LkZ2OfD/pBrFe2A1NYWNt9Lz5Ui0hI0oXEqraeYUiTLzUEsGI5/ Xa+0K4Don0F20yOTyAjQLRVvcNr/mrabEvoygnnvUdHSPSIgNtsv+qXo7qtAmimHPlZw zi3FNwRjVAj3FFt8xMfQ/SzHEwT4gU6Zh0dtndDzQLsLsIUNyR2BbCSOqb7v9ggyNLNE vapqv9/MfZHa8DILXCz7Z0HmiGsYVfzMN7g9/9yw3IvnAXN5EGd7cxGnFYn4rHFxovqc meBA== 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:mime-version :content-transfer-encoding; bh=/S7Ka7E16PV/VR5vThVHFJ7XXACY5XQkVsoo+wY8kGQ=; b=UyQymBr3KK4peXHrFHGqD92I4+j7A8Mcc39wI0Nrmbai5xOBjLy77qGwOAcgpC2Lp4 PM4bisjmrpbA+l5TsG4/+LIOKimSHKd24IbNonWqC/kikWhx2eH5UQzk8rZ5JY74+7Pe s6XVr8Vwk+G0SXg3iEWR8se0BHaUGyzd7s4U3iwxTqdff7LBNylJrPdBajZl9GouZYY0 rjWxbA7HPnagFqQD5YQYghnTdV7TB0ZHVsChd6zSh4o0fCrDn6zByHxT4WfXUHiOOOx0 JjZuC+4777czbDTwiiJtrNsBrJ/Imy1gEFoqxM4RlwQILBBFgKYELgSGmkY0v20qFDQV 5lcg== X-Gm-Message-State: AOAM531A34ntWpsFwMxWNlNCP8Fg5G2rSDZz/BFnwz3Wty7cbmHE3MEQ r0veZHYbY/scxsBUs8Rj1YR9fuLn/bPrZAND X-Google-Smtp-Source: ABdhPJxGA8MpmeH+3mXfuEh9QngCGK+RgfusBvUPoa/NgcT9z9AT40JAohQ08NI5rIvjw1BPWQdylA== X-Received: by 2002:a0c:9e5e:: with SMTP id z30mr29691227qve.61.1620189130884; Tue, 04 May 2021 21:32:10 -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:10 -0700 (PDT) From: Maxim Cournoyer Date: Wed, 5 May 2021 00:32:00 -0400 Message-Id: <20210505043202.24636-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.31.1 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 : Explicitly refer to the first item of the FUNCNAME array. (ROOT_HOME): Replace variable by ~root directly; manually expanding it via echo was not necessary. (chk_gpg_keyring): Use an if branch for the exit to avoid a warning about expression precedence. (chk_term) : Remove unused variable. (guix_get_bin) : Test the commands directly. (sys_create_store): Disable SC1090 for the source command, as we don't care about following the sourced script. <_msg>: Reuse the GUIX_PROFILE variable in the message. (sys_create_build_user) : Test the command directly. --- etc/guix-install.sh | 74 +++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 06a3edd1a6..11836f2c33 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -9,6 +9,7 @@ # Copyright © 2020 Daniel Brooks # Copyright © 2021 Jakub Kądziołka # Copyright © 2021 Chris Marusich +# Copyright © 2021 Maxim Cournoyer # # This file is part of GNU Guix. # @@ -71,11 +72,6 @@ declare -A GPG_SIGNING_KEYS GPG_SIGNING_KEYS[15145]=3CE464558A84FDC69DB40CFB090B11993D9AEBB5 # ludo GPG_SIGNING_KEYS[127547]=27D586A4F8900854329FF09F1260E46482E63562 # maxim -# This script needs to know where root's home directory is. However, we -# cannot simply use the HOME environment variable, since there is no guarantee -# that it points to root's home directory. -ROOT_HOME="$(echo ~root)" - # ------------------------------------------------------------------------------ #+UTILITIES @@ -102,7 +98,7 @@ chk_require() declare -a warn local c - _debug "--- [ $FUNCNAME ] ---" + _debug "--- [ ${FUNCNAME[0]} ] ---" for c in "$@"; do command -v "$c" &>/dev/null || warn+=("$c") @@ -117,7 +113,7 @@ chk_require() chk_gpg_keyring() { # Check whether the Guix release signing public key is present. - _debug "--- [ $FUNCNAME ] ---" + _debug "--- [ ${FUNCNAME[0]} ] ---" local user_id local gpg_key_id local exit_flag @@ -132,21 +128,19 @@ chk_gpg_keyring() exit_flag=yes fi done - test "$exit_flag" = yes && exit 1 || true + if [ "$exit_flag" = yes ]; then + exit 1 + fi } chk_term() { # Check for ANSI terminal for color printing. - local ansi_term - if [ -t 2 ]; then if [ "${TERM+set}" = 'set' ]; then case "$TERM" in xterm*|rxvt*|urxvt*|linux*|vt*|eterm*|screen*) - ansi_term=true ;; *) - ansi_term=false ERR="[ FAIL ] " PAS="[ PASS ] " ;; @@ -243,7 +237,7 @@ guix_get_bin_list() local latest_ver local default_ver - _debug "--- [ $FUNCNAME ] ---" + _debug "--- [ ${FUNCNAME[0]} ] ---" # Filter only version and architecture bin_ver_ls=("$(wget -qO- "$gnu_url" \ @@ -273,24 +267,23 @@ guix_get_bin() local bin_ver="$2" local dl_path="$3" - _debug "--- [ $FUNCNAME ] ---" + _debug "--- [ ${FUNCNAME[0]} ] ---" _msg "${INF}Downloading Guix release archive" wget --help | grep -q '\--show-progress' && \ _PROGRESS_OPT="-q --show-progress" || _PROGRESS_OPT="" - wget $_PROGRESS_OPT -P "$dl_path" "${url}/${bin_ver}.tar.xz" "${url}/${bin_ver}.tar.xz.sig" - if [[ "$?" -eq 0 ]]; then - _msg "${PAS}download completed." + if wget "$_PROGRESS_OPT" -P "$dl_path" \ + "${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 fi pushd "${dl_path}" >/dev/null - gpg --verify "${bin_ver}.tar.xz.sig" >/dev/null 2>&1 - if [[ "$?" -eq 0 ]]; then + if gpg --verify "${bin_ver}.tar.xz.sig" >/dev/null 2>&1; then _msg "${PAS}Signature is valid." popd >/dev/null else @@ -304,7 +297,7 @@ sys_create_store() local pkg="$1" local tmp_path="$2" - _debug "--- [ $FUNCNAME ] ---" + _debug "--- [ ${FUNCNAME[0]} ] ---" cd "$tmp_path" tar --extract \ @@ -321,28 +314,29 @@ sys_create_store() fi _msg "${INF}Linking the root user's profile" - mkdir -p "${ROOT_HOME}/.config/guix" + mkdir -p "~root/.config/guix" ln -sf /var/guix/profiles/per-user/root/current-guix \ - "${ROOT_HOME}/.config/guix/current" + "~root/.config/guix/current" - GUIX_PROFILE="${ROOT_HOME}/.config/guix/current" + GUIX_PROFILE="~root/.config/guix/current" + # shellcheck disable=SC1090 source "${GUIX_PROFILE}/etc/profile" - _msg "${PAS}activated root profile at ${ROOT_HOME}/.config/guix/current" + _msg "${PAS}activated root profile at ${GUIX_PROFILE}" } sys_create_build_user() { # Create the group and user accounts for build users. - _debug "--- [ $FUNCNAME ] ---" + _debug "--- [ ${FUNCNAME[0]} ] ---" - if [ $(getent group guixbuild) ]; then + if getent group guixbuild > /dev/null; then _msg "${INF}group guixbuild exists" else groupadd --system guixbuild _msg "${PAS}group created" fi - if [ $(getent group kvm) ]; then + if getent group kvm > /dev/null; then _msg "${INF}group kvm exists and build users will be added to it" local KVMGROUP=,kvm fi @@ -371,7 +365,7 @@ sys_enable_guix_daemon() local local_bin local var_guix - _debug "--- [ $FUNCNAME ] ---" + _debug "--- [ ${FUNCNAME[0]} ] ---" info_path="/usr/local/share/info" local_bin="/usr/local/bin" @@ -380,7 +374,7 @@ sys_enable_guix_daemon() case "$INIT_SYS" in upstart) { initctl reload-configuration; - cp "${ROOT_HOME}/.config/guix/current/lib/upstart/system/guix-daemon.conf" \ + cp "~root/.config/guix/current/lib/upstart/system/guix-daemon.conf" \ /etc/init/ && start guix-daemon; } && _msg "${PAS}enabled Guix daemon via upstart" @@ -389,15 +383,15 @@ sys_enable_guix_daemon() { # systemd .mount units must be named after the target directory. # Here we assume a hard-coded name of /gnu/store. # XXX Work around until next release. - if [ -f "${ROOT_HOME}/.config/guix/current/lib/systemd/system/gnu-store.mount" ]; then - cp "${ROOT_HOME}/.config/guix/current/lib/systemd/system/gnu-store.mount" \ + if [ -f "~root/.config/guix/current/lib/systemd/system/gnu-store.mount" ]; then + cp "~root/.config/guix/current/lib/systemd/system/gnu-store.mount" \ /etc/systemd/system/; chmod 664 /etc/systemd/system/gnu-store.mount; systemctl daemon-reload && systemctl enable gnu-store.mount; fi - cp "${ROOT_HOME}/.config/guix/current/lib/systemd/system/guix-daemon.service" \ + cp "~root/.config/guix/current/lib/systemd/system/guix-daemon.service" \ /etc/systemd/system/; chmod 664 /etc/systemd/system/guix-daemon.service; @@ -418,7 +412,7 @@ sys_enable_guix_daemon() ;; sysv-init) { mkdir -p /etc/init.d; - cp "${ROOT_HOME}/.config/guix/current/etc/init.d/guix-daemon" \ + cp "~root/.config/guix/current/etc/init.d/guix-daemon" \ /etc/init.d/guix-daemon; chmod 775 /etc/init.d/guix-daemon; @@ -429,7 +423,7 @@ sys_enable_guix_daemon() ;; openrc) { mkdir -p /etc/init.d; - cp "${ROOT_HOME}/.config/guix/current/etc/openrc/guix-daemon" \ + cp "~root/.config/guix/current/etc/openrc/guix-daemon" \ /etc/init.d/guix-daemon; chmod 775 /etc/init.d/guix-daemon; @@ -439,7 +433,7 @@ sys_enable_guix_daemon() ;; NA|*) _msg "${ERR}unsupported init system; run the daemon manually:" - echo " ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild" + echo " ~root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild" ;; esac @@ -457,9 +451,9 @@ sys_enable_guix_daemon() sys_authorize_build_farms() { # authorize the public key of the build farm while true; do - read -p "Permit downloading pre-built package binaries from the project's build farm? (yes/no) " yn + 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_HOME}/.config/guix/current/share/guix/ci.guix.gnu.org.pub" && + [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" @@ -470,7 +464,7 @@ sys_authorize_build_farms() } sys_create_init_profile() -{ # Create /etc/profile.d/guix.sh for better desktop integration +{ # Define for better desktop integration # This will not take effect until the next shell or desktop session! [ -d "/etc/profile.d" ] || mkdir /etc/profile.d # Just in case cat <<"EOF" > /etc/profile.d/guix.sh @@ -544,7 +538,7 @@ This script installs GNU Guix on your system https://www.gnu.org/software/guix/ EOF echo -n "Press return to continue..." - read -r ANSWER + read -r } main() @@ -574,7 +568,7 @@ main() if ! [[ $GUIX_BINARY_FILE_NAME =~ $ARCH_OS ]]; then _err "$ARCH_OS not in ${GUIX_BINARY_FILE_NAME}; aborting" fi - _msg "Using manually provided binary ${GUIX_BINARY_FILE_NAME}" + _msg "${INF}Using manually provided binary ${GUIX_BINARY_FILE_NAME}" GUIX_BINARY_FILE_NAME=$(realpath "$GUIX_BINARY_FILE_NAME") fi From patchwork Wed May 5 04:32:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 29124 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 C870E27BC82; Wed, 5 May 2021 05:33:19 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B098E27BC81 for ; Wed, 5 May 2021 05:33:15 +0100 (BST) Received: from localhost ([::1]:49508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9Dm-0008Dm-U9 for patchwork@mira.cbaines.net; Wed, 05 May 2021 00:33:14 -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 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 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() From patchwork Wed May 5 04:32:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 29122 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 CFA1327BC83; Wed, 5 May 2021 05:33:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 7DBBF27BC81 for ; Wed, 5 May 2021 05:33:09 +0100 (BST) Received: from localhost ([::1]:49084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9Dg-00082U-MA for patchwork@mira.cbaines.net; Wed, 05 May 2021 00:33:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9Da-00082D-FH for guix-patches@gnu.org; Wed, 05 May 2021 00:33:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1le9Da-0002tq-7w 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-0006li-4V for guix-patches@gnu.org; Wed, 05 May 2021 00:33:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48233] [PATCH 3/3] guix-install.sh: Exit early if Guix is already installed. 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.162018914725993 (code B ref 48233); Wed, 05 May 2021 04:33:02 +0000 Received: (at 48233) by debbugs.gnu.org; 5 May 2021 04:32:27 +0000 Received: from localhost ([127.0.0.1]:57444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1le9D1-0006l5-7b for submit@debbugs.gnu.org; Wed, 05 May 2021 00:32:27 -0400 Received: from mail-qk1-f178.google.com ([209.85.222.178]:35728) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1le9Cr-0006kj-Jk for 48233@debbugs.gnu.org; Wed, 05 May 2021 00:32:20 -0400 Received: by mail-qk1-f178.google.com with SMTP id x8so441562qkl.2 for <48233@debbugs.gnu.org>; Tue, 04 May 2021 21:32:17 -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=zfwf7htFMvncxtEZufjiMkHtH3YTO/d4IsNcRc7h1/4=; b=eL2VGH9XjkIVMQAvjfP7kjZfGFmg7Vm5z9X4pCE6stPLzQQi+bkCAPE2xO7k+I6JhG PeyVdPxNPcPWr0y90oEn2dHdCaUt6wm6EdVbPolwLXuqByxt5U6UmQacjqmSv+r9TL2X TuWzxVBqijh3zLgXSMAMz/tV/tlKrkTWNW5LbZNi96TR+1uHEbqLQGZiVj83T6YVRal0 Z+pIm89lJwRWaVVGSQfM6720Hsb5ct3Q0CjaTuk6D+EJet47B3wIzvWimfclC9KMfabd Ldtpvtso/mQZFqP0NGDCCWA03a4e1QKol+z7d/G6EgprGSnX5cmB/JP3ygk//QOhh73V YTBQ== 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=zfwf7htFMvncxtEZufjiMkHtH3YTO/d4IsNcRc7h1/4=; b=MYfW3et73CrB+uWt0e7LM/lwa3YisWMQnMtk6A6CCr96cDGQoj8lvzSfHRB7Y13F9o Yr49Ku/4iBil7s1vgnBGP1V7lBz/qATbvLx5kHk0pDNBBuApIppqxBF7Pzg2EYkC51zd Hn0CU9lDQxiUphRGGGlEvIM05HjgUPNZwuNPGZMBOQhKgFz61w3VZpYXuQm3lNjNIu5z y3/y513lMhgUPV3ORExydTVUzzB3iSIz7IUnjBuOgK/ShftB1QFYT83v9phPU6v59aWW Bum6J6i0wazVxmGi1DGr0shcP4OIk4mAbXkORP5BHFL1vvU885/DQm3LB73GwLSNeAfX WJVA== X-Gm-Message-State: AOAM530/m1GU9kL9eJX8p0yxGba+1RWfHZ17IrB+IxizXYHsKY0/9KJW B2coSqVH8Y7zMgL2Bp4BWm2JoDGAgkug0Wb6 X-Google-Smtp-Source: ABdhPJwR3Q6I1cLrF7kor5pBDSvL4EIebmPvGzOSPoDx3B+0C8LV/7d4duvZuRZ8QIkvRTU+enBqMQ== X-Received: by 2002:a37:e30f:: with SMTP id y15mr27561896qki.480.1620189132041; Tue, 04 May 2021 21:32:12 -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.11 (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:02 -0400 Message-Id: <20210505043202.24636-3-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 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_create_store): Move the check & exit before The Guix binary archive is unpacked. Re-indent tar extraction command. --- etc/guix-install.sh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 3d2936c873..f7ef0c2671 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -321,20 +321,18 @@ sys_create_store() _debug "--- [ ${FUNCNAME[0]} ] ---" - cd "$tmp_path" - tar --extract \ - --file "$pkg" && - _msg "${PAS}unpacked archive" - if [[ -e "/var/guix" || -e "/gnu" ]]; then _err "${ERR}A previous Guix installation was found. Refusing to overwrite." exit 1 - else - _msg "${INF}Installing /var/guix and /gnu..." - mv "${tmp_path}/var/guix" /var/ - mv "${tmp_path}/gnu" / fi + cd "$tmp_path" + tar --extract --file "$pkg" && _msg "${PAS}unpacked archive" + + _msg "${INF}Installing /var/guix and /gnu..." + mv "${tmp_path}/var/guix" /var/ + mv "${tmp_path}/gnu" / + _msg "${INF}Linking the root user's profile" mkdir -p "~root/.config/guix" ln -sf /var/guix/profiles/per-user/root/current-guix \