[bug#60068,v2,2/3] guix-install.sh: Add GUIX_ALLOW_OVERWRITE environment variable.
Commit Message
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(-)
Comments
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
> 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 /.
Like Tobias, I’m reluctant to adding environment variables; I’m also
skeptical about the use case (I think it’s fine to let users remove
their previous installation if that’s what they want).
I also think we’d rather minimize changes to the script since we’re a
couple of days before the release.
Thanks,
Ludo’.
Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
> 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 /.
Like Tobias, I’m reluctant to adding environment variables; I’m also
skeptical about the use case (I think it’s fine to let users remove
their previous installation if that’s what they want).
I also think we’d rather minimize changes to the script since we’re a
couple of days before the release.
Thanks,
Ludo’.
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> writes:
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> 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 /.
>
> Like Tobias, I’m reluctant to adding environment variables; I’m also
> skeptical about the use case (I think it’s fine to let users remove
> their previous installation if that’s what they want).
Removing my previous installation wouldn't have helped (it would have
cleared the guix packs I needed to be able to run the installer).
Without this change, I wouldn't have been able to install guix using
guix-install.sh. It's niche, but I bet it'd help folks trying to
install Guix on Alpine and similar minimal OSes.
> I also think we’d rather minimize changes to the script since we’re a
> couple of days before the release.
The change seems fairly small to me and would be easy to revert if it
causes a problem. But I'll let you do the call, given you're the one
pushing the release forward (thank you!).
@@ -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