unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 58345@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#58345] [PATCH 2/3] guix-install.sh: Introduce 'die' utility function.
Date: Fri,  7 Oct 2022 01:31:59 -0400	[thread overview]
Message-ID: <20221007053200.21177-2-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20221007053200.21177-1-maxim.cournoyer@gmail.com>

* 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"
-- 
2.37.3





  reply	other threads:[~2022-10-07  5:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-07  5:27 [bug#58345] [PATCH 0/3] Customize PS1 on foreign distributions Maxim Cournoyer
2022-10-07  5:31 ` [bug#58345] [PATCH 1/3] guix-install.sh: Improve prompt_yes_no procedure Maxim Cournoyer
2022-10-07  5:31   ` Maxim Cournoyer [this message]
2022-10-07  8:30     ` [bug#58345] [PATCH 2/3] guix-install.sh: Introduce 'die' utility function zimoun
2022-10-07 12:23       ` Maxim Cournoyer
2022-10-07  5:32   ` [bug#58345] [PATCH 3/3] guix-install.sh: Add Bash prompt customization option Maxim Cournoyer
2022-10-07  8:34     ` zimoun
2022-10-07 12:28       ` bug#58345: " 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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221007053200.21177-2-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=58345@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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).