From patchwork Thu Feb 6 04:25:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Liam Hupfer X-Patchwork-Id: 38305 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 DB99427BBE2; Thu, 6 Feb 2025 04:27:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 8AE8127BBE9 for ; Thu, 6 Feb 2025 04:27:39 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tftTo-0000Ps-Tk; Wed, 05 Feb 2025 23:27:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tftTm-0000Or-M8 for guix-patches@gnu.org; Wed, 05 Feb 2025 23:27:06 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tftTm-000181-8F; Wed, 05 Feb 2025 23:27:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=jf0lWL+Q51AXR8iJHOrYfOcwvNwOczb6iewcDMc3Z4Y=; b=BeREw3ZMOhFbx4rJmV95aOndiGz73dASTfTau5wdZyIl9U8KOsImTt14fo4xmGCbfg6we85uFu/Rbz5hh7Xh7yOaqYTxRgXPghnSf865qASoBJbUeO06YEY3sJaUASTn6hME+djNlH0ODPWNbWWnTDEMK0lJLCFlbrJ9VLUnrOh80CeKdspgZiWs7gJ18S93MHHpPi7V4crGP8J7exN+dBYuDCk1rQKvgWTTbJDxkZpHDQPLXPZjI29mOjYEEy9iVHrPz02StSBmfGIzJMCuDTLHGg5W31G9xIHU1PjdV9pNcntjdTei5Cy9Iu1DKQ4cVPw2qp51NinI3nuVf/Dvsw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tftTl-0002Y7-5j; Wed, 05 Feb 2025 23:27:05 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#76082] [PATCH 9/9] guix-install.sh: Check for existing installation before downloading. Resent-From: Liam Hupfer Original-Sender: "Debbugs-submit" Resent-CC: andrew@trop.in, janneke@gnu.org, ludo@gnu.org, tanguy@bioneland.org, vagrant@debian.org, guix-patches@gnu.org Resent-Date: Thu, 06 Feb 2025 04:27:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76082 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 76082@debbugs.gnu.org Cc: Liam Hupfer , Andrew Tropin , Janneke Nieuwenhuizen , Ludovic =?utf-8?q?Court=C3=A8s?= , Tanguy Le Carrour , Vagrant Cascadian X-Debbugs-Original-Xcc: Andrew Tropin , Janneke Nieuwenhuizen , Ludovic =?utf-8?q?Court=C3=A8s?= , Tanguy Le Carrour , Vagrant Cascadian Received: via spool by 76082-submit@debbugs.gnu.org id=B76082.17388160039685 (code B ref 76082); Thu, 06 Feb 2025 04:27:05 +0000 Received: (at 76082) by debbugs.gnu.org; 6 Feb 2025 04:26:43 +0000 Received: from localhost ([127.0.0.1]:53636 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tftTO-0002W7-Ga for submit@debbugs.gnu.org; Wed, 05 Feb 2025 23:26:42 -0500 Received: from out-189.mta1.migadu.com ([2001:41d0:203:375::bd]:42369) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tftTJ-0002VT-3L for 76082@debbugs.gnu.org; Wed, 05 Feb 2025 23:26:37 -0500 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpfr.net; s=key1; t=1738815990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jf0lWL+Q51AXR8iJHOrYfOcwvNwOczb6iewcDMc3Z4Y=; b=E9wvFNnBDvqzanmcZludj3IoklDNAanJY2na22pmwWWCOl05/01RZ4KlfqXECNcEDYJKWK 20T6fN5soppN9J+MJVJrmYutsrw055FiZFCxZCPL8O8uiQ8CwiXbjQdypJaXx50nfxPlkv By85HTHa+2dceCrVg8SWz9v9QwVuHpq74YL/N9vK1ssOvwpSRiQcrPhAUD1cYtfQxxYIxd f6XCZkJgNoROhIJQ57hV9iScEiwjrCqysyntpE2FzWbhg9ofEyusEFq6hBRI9EDQxu5pbf AvKRcv/9SoB8YlA21N3FPPkem97GvdUntycvtMlugCPUdXwRo5EawzQRtAlgjQ== From: Liam Hupfer Date: Wed, 5 Feb 2025 22:25:05 -0600 Message-ID: <3bdb2d798b0ef6ffbba1f20e7263e47be6e9b9e3.1738815703.git.liam@hpfr.net> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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 --- etc/guix-install.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 7a731962b3..297a726ad6 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -315,6 +315,19 @@ chk_sys_nscd() fi } +chk_existing() +{ # Avoid clobbering existing installations. + _debug "--- [ ${FUNCNAME[0]} ] ---" + + if [[ -e /var/guix && -e /gnu ]]; then + if [ -n "$GUIX_ALLOW_OVERWRITE" ]; then + _msg_warn "Overwriting existing installation!" + else + die "A previous Guix installation was found. Refusing to overwrite." + fi + fi +} + # Configure substitute discovery according to user's preferences. # $1 is the installed service file to edit. configure_substitute_discovery() { @@ -393,16 +406,6 @@ sys_create_store() local pkg="$1" local tmp_path="$2" - _debug "--- [ ${FUNCNAME[0]} ] ---" - - if [[ -e /var/guix && -e /gnu ]]; then - if [ -n "$GUIX_ALLOW_OVERWRITE" ]; then - _msg_warn "Overwriting existing installation!" - else - die "A previous Guix installation was found. Refusing to overwrite." - fi - fi - cd "$tmp_path" _msg_info "Installing /var/guix and /gnu..." # Strip (skip) the leading ‘.’ component, which fails on read-only ‘/’. @@ -875,6 +878,7 @@ main_install() chk_gpg_keyring chk_sys_arch chk_sys_nscd + chk_existing _msg_info "system is ${ARCH_OS}"