From patchwork Wed Dec 14 15:56:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 45263 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 74D6327BBEB; Wed, 14 Dec 2022 15:57:53 +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=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 DED5027BBE9 for ; Wed, 14 Dec 2022 15:57:51 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5U84-0001Aq-Sb; Wed, 14 Dec 2022 10:57: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 1p5U7z-00018v-N2 for guix-patches@gnu.org; Wed, 14 Dec 2022 10:57:04 -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 1p5U7y-0006Dh-Nf for guix-patches@gnu.org; Wed, 14 Dec 2022 10:57:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5U7y-0004b4-An for guix-patches@gnu.org; Wed, 14 Dec 2022 10:57:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60068] [PATCH 1/2] 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 15:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60068 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60068@debbugs.gnu.org Cc: Maxim Cournoyer X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.167103338117644 (code B ref -1); Wed, 14 Dec 2022 15:57:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Dec 2022 15:56:21 +0000 Received: from localhost ([127.0.0.1]:40033 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5U7I-0004aV-Uf for submit@debbugs.gnu.org; Wed, 14 Dec 2022 10:56:21 -0500 Received: from lists.gnu.org ([209.51.188.17]:40690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5U7D-0004aP-Lu for submit@debbugs.gnu.org; Wed, 14 Dec 2022 10:56:19 -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 1p5U7D-0000PD-Ad for guix-patches@gnu.org; Wed, 14 Dec 2022 10:56:15 -0500 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5U7B-0005a5-Mj for guix-patches@gnu.org; Wed, 14 Dec 2022 10:56:15 -0500 Received: by mail-qt1-x833.google.com with SMTP id a16so2758197qtw.10 for ; Wed, 14 Dec 2022 07:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=M42CaM3Qax3m81KvT4f6PsgNBkAHyWRAS+1HMFRHEtk=; b=HFostAR0ZhgCw7CjopHSeTqjQwIhSuHIbUjRNas986ADoGTJh9TaF7br9Yj1nX5jzs y+IPNOXTmrKaaH4y2Bw8ViKqAOhuJI4cXF+99EF+JrfNdHNy//Gt3WUTMkTeo6t0X/lc sLCoxYWuuguagZ9WaUdDdawGUCObWdkeoeMbP9hXrAr3sKrF5w0H+oaUHMtcVgQtVclJ LpTJaRG2y7PQjY/lmgHsAkyNi9lvd7T6sDOnAf0JUL23BD3km8BsyCx6k3rIuVVcNLDA HMAc9oG1ezknioyZ3zrYKY8yOJAOVDS1IsW1SHMqRb9IRaM4LcZqRQNraoIceY/u76u7 A1Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=M42CaM3Qax3m81KvT4f6PsgNBkAHyWRAS+1HMFRHEtk=; b=BhtxVw4Sy6jrT7PM12Rx2GrXusDWIcPvRcgrUAqc3hvfaZ2hrI5mgF8TrRg8Lw88cg azAMHRzGDWrjV6fxY6orMJ5M9nKtaEcuAWtcheCPkvJGnhCCgT8eT99L7GrqrGlG8SJG vJ8iduaMy7N9hDS1ZLbGV2dNf/O+9hSqa+4j7AjrQdF++u25m2XXTrpAQ3vIRPRcK4ha JXgvd9afhUG0Cf+B8xdPjn7/ECq/0Wu7l6ujh0X4SU8TcWD8RyXqazlBacvy0NLVrXk8 c7I6Xkom16r3359Xfv7u3N7wrmFGABS5M9br+uPBFuWXzqe2Lcd1YqcOn005UXYt0eBL 9sQQ== X-Gm-Message-State: ANoB5plYGDaqx/VeCuJyzA8bITzHi7jg6HqDBuEp+pMJseG/ReyMh7Mq ZQFDhKIZnH8GBlOM+ThY0KTBI+wsweZAdQ== X-Google-Smtp-Source: AA0mqf6Kk27/Ini121UdPJZ5kt+8/u7x0qvDBwkAjhM8sDlWZp9S4zXyPoVFlRKqrpQVqGkizdoC5A== X-Received: by 2002:ac8:1099:0:b0:3a5:9267:ee07 with SMTP id a25-20020ac81099000000b003a59267ee07mr28823747qtj.63.1671033372016; Wed, 14 Dec 2022 07:56:12 -0800 (PST) Received: from localhost.localdomain ([2607:fad8:4:3::1006]) by smtp.gmail.com with ESMTPSA id k10-20020ac8074a000000b00397b1c60780sm1829150qth.61.2022.12.14.07.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 07:56:11 -0800 (PST) From: Maxim Cournoyer Date: Wed, 14 Dec 2022 10:56:02 -0500 Message-Id: <20221214155603.29381-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::833; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qt1-x833.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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. (REQUIRE): Add missing "useradd" command. (sys_create_store) [GUIX_ALLOW_OVERWRITE]: Skip pre-existing installation checks and output a warning. Extract the tarball directly to /. --- etc/guix-install.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) base-commit: 1b6e251ed1bae7aa2f544e8ccb6b4aaf872e77e6 diff --git a/etc/guix-install.sh b/etc/guix-install.sh index fb9006b3e2..06730f7e3f 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" "$@" @@ -53,6 +69,7 @@ REQUIRE=( "chmod" "uname" "groupadd" + "useradd" "tail" "tr" "xz" @@ -337,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