unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 60068@debbugs.gnu.org
Cc: me@tobias.gr, Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#60068] [PATCH v2 2/3] guix-install.sh: Add GUIX_ALLOW_OVERWRITE environment variable.
Date: Wed, 14 Dec 2022 15:46:39 -0500	[thread overview]
Message-ID: <20221214204640.16879-2-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20221214204640.16879-1-maxim.cournoyer@gmail.com>

The need for this use case appeared when attempting to install Guix on a truly
minimal image made with Buildroot, which lacked enough GNU components that I
had to extract a guix pack to /gnu before attempting installation, which would
then refuse to proceed because of the existing /gnu.

* etc/guix-install.sh: Document environment variables.
(sys_create_store) [GUIX_ALLOW_OVERWRITE]: Skip pre-existing installation
checks and output a warning.  Extract the tarball directly to /.
---
 etc/guix-install.sh | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index b8ea9e54c3..62d85e765a 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -29,6 +29,22 @@
 
 # We require Bash but for portability we'd rather not use /bin/bash or
 # /usr/bin/env in the shebang, hence this hack.
+
+# Environment variables
+#
+# GUIX_BINARY_FILE_NAME
+#
+# Can be used to override the automatic download mechanism and point
+# to a local Guix binary archive filename like
+# "/tmp/guix-binary-1.4.0rc2.armhf-linux.tar.xz"
+#
+# GUIX_ALLOW_OVERWRITE
+#
+# Instead of aborting to avoid overwriting a previous installations,
+# allow copying over /var/guix or /gnu.  This can be useful when the
+# installation required the user to extract Guix packs under /gnu to
+# satisfy its dependencies.
+
 if [ "x$BASH_VERSION" = "x" ]
 then
     exec bash "$0" "$@"
@@ -338,16 +354,15 @@ sys_create_store()
 
     _debug "--- [ ${FUNCNAME[0]} ] ---"
 
-    if [[ -e "/var/guix" || -e "/gnu" ]]; then
+    if [[ -z $GUIX_ALLOW_OVERWRITE && (-e /var/guix || -e /gnu) ]]; then
         die "A previous Guix installation was found.  Refusing to overwrite."
+    else
+        _msg "${WAR}Overwriting existing installation!"
     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" /
+    tar --extract --file "$pkg" -C /
 
     _msg "${INF}Linking the root user's profile"
     mkdir -p ~root/.config/guix
-- 
2.38.1





  reply	other threads:[~2022-12-14 20:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-14 15:56 [bug#60068] [PATCH 1/2] guix-install.sh: Add GUIX_ALLOW_OVERWRITE environment variable Maxim Cournoyer
2022-12-14 15:56 ` [bug#60069] [PATCH 2/2] guix-install.sh: Directly exit in case of errors in chk_require Maxim Cournoyer
2022-12-14 16:37   ` Tobias Geerinckx-Rice via Guix-patches via
2022-12-14 18:17     ` Maxim Cournoyer
2022-12-14 18:33       ` Maxim Cournoyer
2022-12-14 16:16 ` [bug#60068] [PATCH 1/2] guix-install.sh: Add GUIX_ALLOW_OVERWRITE environment variable Tobias Geerinckx-Rice via Guix-patches via
2022-12-14 18:25   ` Maxim Cournoyer
2023-02-04  4:36     ` Maxim Cournoyer
2022-12-14 20:46 ` [bug#60068] [PATCH v2 1/3] guix-install.sh: Add missing "useradd" command Maxim Cournoyer
2022-12-14 20:46   ` Maxim Cournoyer [this message]
2022-12-15 14:43     ` [bug#60068] bug#60069: [PATCH 2/2] guix-install.sh: Directly exit in case of errors in chk_require Ludovic Courtès
2022-12-16  5:07       ` [bug#60069] " Maxim Cournoyer
2022-12-15 14:44     ` [bug#60068] bug#60069: " Ludovic Courtès
2022-12-14 20:46   ` [bug#60068] [PATCH v2 3/3] " Maxim Cournoyer
2022-12-15 14:41   ` [bug#60068] bug#60069: [PATCH 2/2] " Ludovic Courtès
2022-12-16  5:24     ` 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=20221214204640.16879-2-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=60068@debbugs.gnu.org \
    --cc=me@tobias.gr \
    /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).