diff options
| author | Liam Hupfer <liam@hpfr.net> | 2025-02-05 22:25:05 -0600 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-02-21 15:27:11 +0100 |
| commit | bff76fe66abd83d4986a758731dad404c40e2ca3 (patch) | |
| tree | 45d2709fb8368e486e3e004b65043f82fbc63e58 /etc/guix-install.sh | |
| parent | 201db94628ea044b720ab4916d19eda022a4d6e7 (diff) | |
guix-install.sh: Check for existing installation before downloading.
Previously, the check came after guix_get_bin. There’s no need to fetch
the rather large release archive if there’s an existing installation, so
check first. Refactor the check into a function similar to other
preflight checks.
* etc/guix-install.sh: Check for existing installation before
downloading.
Change-Id: I5506fb1cacdc88bd6355e8dfa1f690acf7886c1f
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'etc/guix-install.sh')
| -rwxr-xr-x | etc/guix-install.sh | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 7a731962b3f..297a726ad6d 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh | |||
| @@ -315,6 +315,19 @@ chk_sys_nscd() | |||
| 315 | fi | 315 | fi |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | chk_existing() | ||
| 319 | { # Avoid clobbering existing installations. | ||
| 320 | _debug "--- [ ${FUNCNAME[0]} ] ---" | ||
| 321 | |||
| 322 | if [[ -e /var/guix && -e /gnu ]]; then | ||
| 323 | if [ -n "$GUIX_ALLOW_OVERWRITE" ]; then | ||
| 324 | _msg_warn "Overwriting existing installation!" | ||
| 325 | else | ||
| 326 | die "A previous Guix installation was found. Refusing to overwrite." | ||
| 327 | fi | ||
| 328 | fi | ||
| 329 | } | ||
| 330 | |||
| 318 | # Configure substitute discovery according to user's preferences. | 331 | # Configure substitute discovery according to user's preferences. |
| 319 | # $1 is the installed service file to edit. | 332 | # $1 is the installed service file to edit. |
| 320 | configure_substitute_discovery() { | 333 | configure_substitute_discovery() { |
| @@ -393,16 +406,6 @@ sys_create_store() | |||
| 393 | local pkg="$1" | 406 | local pkg="$1" |
| 394 | local tmp_path="$2" | 407 | local tmp_path="$2" |
| 395 | 408 | ||
| 396 | _debug "--- [ ${FUNCNAME[0]} ] ---" | ||
| 397 | |||
| 398 | if [[ -e /var/guix && -e /gnu ]]; then | ||
| 399 | if [ -n "$GUIX_ALLOW_OVERWRITE" ]; then | ||
| 400 | _msg_warn "Overwriting existing installation!" | ||
| 401 | else | ||
| 402 | die "A previous Guix installation was found. Refusing to overwrite." | ||
| 403 | fi | ||
| 404 | fi | ||
| 405 | |||
| 406 | cd "$tmp_path" | 409 | cd "$tmp_path" |
| 407 | _msg_info "Installing /var/guix and /gnu..." | 410 | _msg_info "Installing /var/guix and /gnu..." |
| 408 | # Strip (skip) the leading ‘.’ component, which fails on read-only ‘/’. | 411 | # Strip (skip) the leading ‘.’ component, which fails on read-only ‘/’. |
| @@ -875,6 +878,7 @@ main_install() | |||
| 875 | chk_gpg_keyring | 878 | chk_gpg_keyring |
| 876 | chk_sys_arch | 879 | chk_sys_arch |
| 877 | chk_sys_nscd | 880 | chk_sys_nscd |
| 881 | chk_existing | ||
| 878 | 882 | ||
| 879 | _msg_info "system is ${ARCH_OS}" | 883 | _msg_info "system is ${ARCH_OS}" |
| 880 | 884 | ||
