From patchwork Wed Dec 14 20:46:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 45326 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 8F93727BBED; Wed, 14 Dec 2022 20:47:21 +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=-3.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham 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 0D98627BBE9 for ; Wed, 14 Dec 2022 20:47:21 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5Yee-0005Kn-CR; Wed, 14 Dec 2022 15:47:04 -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 1p5Yec-0005K0-PL for guix-patches@gnu.org; Wed, 14 Dec 2022 15:47:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Yec-00016M-Hd for guix-patches@gnu.org; Wed, 14 Dec 2022 15:47:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5Yec-0004DM-Cn for guix-patches@gnu.org; Wed, 14 Dec 2022 15:47:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60068] [PATCH v2 2/3] guix-install.sh: Add GUIX_ALLOW_OVERWRITE environment variable. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 14 Dec 2022 20:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60068 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60068@debbugs.gnu.org Cc: me@tobias.gr, Maxim Cournoyer Received: via spool by 60068-submit@debbugs.gnu.org id=B60068.167105082116191 (code B ref 60068); Wed, 14 Dec 2022 20:47:02 +0000 Received: (at 60068) by debbugs.gnu.org; 14 Dec 2022 20:47:01 +0000 Received: from localhost ([127.0.0.1]:41787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5Yeb-0004D0-0m for submit@debbugs.gnu.org; Wed, 14 Dec 2022 15:47:01 -0500 Received: from mail-vk1-f176.google.com ([209.85.221.176]:36773) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5YeZ-0004Ch-3b for 60068@debbugs.gnu.org; Wed, 14 Dec 2022 15:46:59 -0500 Received: by mail-vk1-f176.google.com with SMTP id l17so3761570vkk.3 for <60068@debbugs.gnu.org>; Wed, 14 Dec 2022 12:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Un0fZJVaLUxbKw8DTSotXo0HP/nDyh/LNRYFXBJIEhQ=; b=nJdd2Va10Aqw8PFd4EDn+eRpXEogj3qc7PtRYVR/WW8EkOd4qxex3yv9uORuMCKOnm pJ9o9LKx/bIkh40JnDp2kj+Kp0Qe+BJRDmOqtG/eXb7xxn4Bu5pf0QxjzcpcJ8lulOpD znDH2ytGXlyuIACV6yDAFW/4gqjQR7nDvR0Po5qnXHPLjxZAG6DOLlTi7RhLQS5P7jMl Dly82des+YGIbreRqKt3pkTT5ByF4u3vW1qjQ3qrk/GZ6+K+qlQjf0rfCXjo/YJy3Z6k eajfddUTTnZeNpFxnN/4zmx8S9jHLbN1Md5qJ7wT0+D+TRn7asnnfIl3H7bdkBEk0buQ R36w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Un0fZJVaLUxbKw8DTSotXo0HP/nDyh/LNRYFXBJIEhQ=; b=r+tJFgu9xzwVWRdnjYJP6JEDpQnl/odkHs+mf4rXWsp4LDO63GSbA4qCiIj5cS+MzJ d7JHpVkLSFHt847KTbfbkhaRFNioslFsANRht99Dmo0l0uCuv+PKzOnvADvZ2pD1sYNS 72YuiyumXwQ6Wr0AZLQ8Wc+mJci1nsGcxRQLpbCHzPn+f0EYCaek3jBTI1O2D/PR8IEJ h0yBB4PGzlczsl4SXiauuMj7xklw3mgloUPZl7/p3e5kjVd5K07oPIkKQ01cfTdFvkrn joZPZtRU6W1jTxc3k1PXepn0+RsEc7l4ipid3r5/55/RuAQjEwan1VHhILoiT7yWL7Sl ibiw== X-Gm-Message-State: ANoB5pn2qWIauvuAP6P7zb6V5At+eByVSSnX/qZbkwEKjM79ZttpCosA 9BnmsLP39dBr79ymFZ9m6QwTVR/fud60RQ== X-Google-Smtp-Source: AA0mqf51yW3eD6cDdoCOl1Nxef/3Y2DkEoLy7sKOAWtlJ8zH8oTMKBi+S86IRDFloZBDC+4ZaXHRiw== X-Received: by 2002:a1f:ea42:0:b0:3bd:fb7f:e385 with SMTP id i63-20020a1fea42000000b003bdfb7fe385mr13349086vkh.8.1671050813270; Wed, 14 Dec 2022 12:46:53 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1006]) by smtp.gmail.com with ESMTPSA id p13-20020a05620a112d00b006f87d28ea3asm10192676qkk.54.2022.12.14.12.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 12:46:52 -0800 (PST) From: Maxim Cournoyer Date: Wed, 14 Dec 2022 15:46:39 -0500 Message-Id: <20221214204640.16879-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221214204640.16879-1-maxim.cournoyer@gmail.com> References: <20221214204640.16879-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 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 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