From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id qLwEI54xp2KJbwEAbAwnHQ (envelope-from ) for ; Mon, 13 Jun 2022 14:46:22 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id QA8HIp4xp2I7LAEAG6o9tA (envelope-from ) for ; Mon, 13 Jun 2022 14:46:22 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 20D6D80F3 for ; Mon, 13 Jun 2022 14:46:22 +0200 (CEST) Received: from localhost ([::1]:51566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o0jSX-0003q1-6F for larch@yhetil.org; Mon, 13 Jun 2022 08:46:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0izC-0003y1-Pe for guix-patches@gnu.org; Mon, 13 Jun 2022 08:16:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o0izC-0008LY-GP for guix-patches@gnu.org; Mon, 13 Jun 2022 08:16:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o0izC-0004DK-A5 for guix-patches@gnu.org; Mon, 13 Jun 2022 08:16:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55941] [PATCH core-updates 1/3] utils: Move switch-symlinks to (guix build utils). References: <20220613121300.20227-1-arunisaac@systemreboot.net> In-Reply-To: <20220613121300.20227-1-arunisaac@systemreboot.net> Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 13 Jun 2022 12:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55941 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55941@debbugs.gnu.org, Maxime Devos Cc: Arun Isaac Received: via spool by 55941-submit@debbugs.gnu.org id=B55941.165512254216152 (code B ref 55941); Mon, 13 Jun 2022 12:16:02 +0000 Received: (at 55941) by debbugs.gnu.org; 13 Jun 2022 12:15:42 +0000 Received: from localhost ([127.0.0.1]:57449 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o0iyg-0004C5-5W for submit@debbugs.gnu.org; Mon, 13 Jun 2022 08:15:42 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:46410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o0iye-0004Bp-Mf for 55941@debbugs.gnu.org; Mon, 13 Jun 2022 08:15:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=dlCNoGuS+wP5MLLp3DnFcE7nCVhugh+XXI7sOlRb0Z8=; b=iSrFDOIr4Zl//DHuWji92uk39t C/dR4deGKg3tPNZZKRmh6lyOydHREC+u2WF8iLePz5N0M+59k3SkuE/mlbx8cbE2OXR2iIxkOZLp6 GS2Z9gMKUQ6MxSn/LImkefayr36HCnxUzOhX97p3dgDB5GkSWd0OFbFyEwFwe6tlVAGpMjgMuiLQ/ GFZh1HuULVXMO6euCfkKemfngWOFGTcaWK+6TnC50vvHu59IK93j7SJtdCxVt9xDpJzUqep+U8r9U 1EYDkiSf1n0bllAhPUG5tDkjuF63S5Pm6EjXIKKXzPH4M5cXvle5zVuUOrdRgiJMPLpQYrm2JCfuO 2Y3wUMTA==; Received: from [192.168.2.1] (port=5296 helo=localhost.localdomain) by systemreboot.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1o0iyb-0004fy-Ce; Mon, 13 Jun 2022 17:45:25 +0530 From: Arun Isaac Date: Mon, 13 Jun 2022 17:45:21 +0530 Message-Id: <20220613121523.20327-1-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655124382; h=from:from:sender:sender: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:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=dlCNoGuS+wP5MLLp3DnFcE7nCVhugh+XXI7sOlRb0Z8=; b=DPGqIKV76AQY5OMvXXDI9d4I7sQ2AkXucxnx3tn6HoAdgCyXSAoT8Pz1Wvs5Qaf2AqqRYO LfDgoavJKNPIWGaHAzKCM67BDvElu9jJ3TfN9h5e/8fSIkPrtTcC4e/8xlONtv1WPH4wST RCjTQqRiOViCgPXMyznOk77sAFUNIZS4zrhgRlsiM99P6hvYBIgxxWWqT/stSgUo+h6v7M ZDjEKld5OPWVDghMMpth0jvzfl9Ogff/gb0xi1ounfboCJVndRZGd8ziqWCTeZTjy4dQXZ YdGu+VV3847TDwJnPNpXukh2KjmmlQ0ANkeEcoQI8yCvz92a/Hfhiz3HLXuVtQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655124382; a=rsa-sha256; cv=none; b=NySumEKnQv6UW1YSm0ORucDobNCKGzaise/HU+qC7vE471asjMA1aKnqw9k727qMFE2xgx Zy7P4RivjjxssGA+/FKbt6xaiDnk5OG1CYarWHxc78ig//kUjblYzN1SMGCCTmOLjZ9lsb eqUoZI6L2zFuOYOhddIvAvqF6oZrV6wrumkv1ILpL7Wl0vWyYux127J3S1CWZE+HOxlWKS IEkbDJV0G1p10nZaobK1OsfpWgI6JmaBIF6br2DRFSfJHoT3T/zJf9O+0v+McOP3aatERI EfqAlecopD4GhdPonYx+d/AeJTgd3Vbqgt5+oNZ6BM1YMV6Uk3hHR0ryQEZ3/A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=iSrFDOIr; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.21 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=iSrFDOIr; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 20D6D80F3 X-Spam-Score: 6.21 X-Migadu-Scanner: scn0.migadu.com X-TUID: Yo7q3W/aCzGx * guix/utils.scm (switch-symlinks): Move to ... * guix/build/utils.scm (switch-symlinks): ... here. * guix/profiles.scm, guix/scripts/home.scm, guix/scripts/package.scm: Import switch-symlinks from (guix build utils). * guix/scripts/system/reconfigure.scm (switch-system-program): Import (guix build utils) in G-expression. --- guix/build/utils.scm | 8 ++++++++ guix/profiles.scm | 3 ++- guix/scripts/home.scm | 3 ++- guix/scripts/package.scm | 3 ++- guix/scripts/system/reconfigure.scm | 4 +++- guix/utils.scm | 8 -------- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index b822caf619..ce7bdb2024 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -60,6 +60,7 @@ (define-module (guix build utils) directory-exists? executable-file? symbolic-link? + switch-symlinks call-with-temporary-output-file call-with-ascii-input-file file-header-match @@ -240,6 +241,13 @@ (define (symbolic-link? file) "Return #t if FILE is a symbolic link (aka. \"symlink\".)" (eq? (stat:type (lstat file)) 'symlink)) +(define (switch-symlinks link target) + "Atomically switch LINK, a symbolic link, to point to TARGET. Works +both when LINK already exists and when it does not." + (let ((pivot (string-append link ".new"))) + (symlink target pivot) + (rename-file pivot link))) + (define (call-with-temporary-output-file proc) "Call PROC with a name of a temporary file and open output port to that file; close the file and delete it when leaving the dynamic extent of this diff --git a/guix/profiles.scm b/guix/profiles.scm index bf50c00a1e..d3ff8379ad 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2019 Mathieu Othacehe ;;; Copyright © 2020 Danny Milosavljevic ;;; Copyright © 2014 David Thompson +;;; Copyright © 2022 Arun Isaac ;;; ;;; This file is part of GNU Guix. ;;; @@ -32,7 +33,7 @@ (define-module (guix profiles) #:use-module ((guix config) #:select (%state-directory)) #:use-module ((guix utils) #:hide (package-name->name+version)) #:use-module ((guix build utils) - #:select (package-name->name+version mkdir-p)) + #:select (package-name->name+version mkdir-p switch-symlinks)) #:use-module ((guix diagnostics) #:select (&fix-hint formatted-message)) #:use-module (guix i18n) #:use-module (guix records) diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 0f5c3388a1..8ba7693a83 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2021 Pierre Langlois ;;; Copyright © 2021 Oleg Pykhalov ;;; Copyright © 2022 Ludovic Courtès +;;; Copyright © 2022 Arun Isaac ;;; ;;; This file is part of GNU Guix. ;;; @@ -63,7 +64,7 @@ (define-module (guix scripts home) #:autoload (guix scripts home edit) (guix-home-edit) #:autoload (guix scripts home import) (import-manifest) #:use-module ((guix status) #:select (with-status-verbosity)) - #:use-module ((guix build utils) #:select (mkdir-p)) + #:use-module ((guix build utils) #:select (mkdir-p switch-symlinks)) #:use-module (guix gexp) #:use-module (guix monads) #:use-module (srfi srfi-1) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 99a6cfaa29..14a8e1f5e8 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2020 Simon Tournier ;;; Copyright © 2018 Steve Sprang ;;; Copyright © 2022 Josselin Poiret +;;; Copyright © 2022 Arun Isaac ;;; ;;; This file is part of GNU Guix. ;;; @@ -49,7 +50,7 @@ (define-module (guix scripts package) #:autoload (guix channels) (channel-name channel-commit channel->code) #:autoload (guix store roots) (gc-roots user-owned?) #:use-module ((guix build utils) - #:select (directory-exists? mkdir-p)) + #:select (directory-exists? mkdir-p switch-symlinks)) #:use-module (ice-9 format) #:use-module (ice-9 match) #:autoload (ice-9 pretty-print) (pretty-print) diff --git a/guix/scripts/system/reconfigure.scm b/guix/scripts/system/reconfigure.scm index 9ca66687ee..a173e011b4 100644 --- a/guix/scripts/system/reconfigure.scm +++ b/guix/scripts/system/reconfigure.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2018 Ricardo Wurmus ;;; Copyright © 2019 Christopher Baines ;;; Copyright © 2019 Jakob L. Kreuze +;;; Copyright © 2022 Arun Isaac ;;; ;;; This file is part of GNU Guix. ;;; @@ -94,7 +95,8 @@ (define* (switch-system-program os #:optional profile) #:select? not-config?) ((guix config) => ,(make-config.scm))) #~(begin - (use-modules (guix config) + (use-modules (guix build utils) + (guix config) (guix profiles) (guix utils)) diff --git a/guix/utils.scm b/guix/utils.scm index 37b2e29800..ed791cce1c 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -120,7 +120,6 @@ (define-module (guix utils) file-sans-extension tarball-sans-extension compressed-file? - switch-symlinks call-with-temporary-directory with-atomic-file-output @@ -892,13 +891,6 @@ (define (compressed-file? file) (->bool (member (file-extension file) '("gz" "bz2" "xz" "lz" "lzma" "tgz" "tbz2" "zip")))) -(define (switch-symlinks link target) - "Atomically switch LINK, a symbolic link, to point to TARGET. Works -both when LINK already exists and when it does not." - (let ((pivot (string-append link ".new"))) - (symlink target pivot) - (rename-file pivot link))) - (define* (string-replace-substring str substr replacement #:optional (start 0) base-commit: 0d09e2e29d1ef0afabebd843f51d41d6cfe340ee -- 2.36.1