From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.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 0Ay+N5PqnWJ/dgEAbAwnHQ (envelope-from ) for ; Mon, 06 Jun 2022 13:52:51 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 4PKzN5PqnWLdIgAAauVa8A (envelope-from ) for ; Mon, 06 Jun 2022 13:52:51 +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 9A5A630C7C for ; Mon, 6 Jun 2022 13:52:51 +0200 (CEST) Received: from localhost ([::1]:43750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyAuS-0005T2-PK for larch@yhetil.org; Mon, 06 Jun 2022 07:28:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyAtw-0005QN-MV for guix-devel@gnu.org; Mon, 06 Jun 2022 07:28:04 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:34380) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyAts-00009d-V7; Mon, 06 Jun 2022 07:28:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nynM8DN8qWDKLmms5u3LT4fKtbnJ2M3NkNjVpNUL9Bs=; b=io3nzKvr9zYly1bdXf61GRnH0f iBNdk6Q9a4qjoX+8TcpcUNf4+QjfKnQEnNizIFADMUKFnh1lUQmCoErDRG1SZKNIE/w8jeoeVOoY3 B2s57/LK15DS4Bu7DbxxfFR6kPIXGeAVuOoRbHxcCvxDDDCBJFkHhE1CVb4gAYH6duucT7TAZ7zlN KyFEi5G2KmyUb/GLa8Dw94aCDj1Ni6X6vEyyC+o2LPeyUvHUEtq2lBYnJVc1JWZ2qlmXsDW613cQS z93MHBw0wyxX2/RYy0ErEj0T5Ilsghst11l0RI+bZSVSFRNaBIaUaRUdHXjHjvX5z129shkhhVDvW vYHiRQqA==; Received: from [192.168.2.1] (port=17890 helo=steel) by systemreboot.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1nyAtm-000AOb-BR; Mon, 06 Jun 2022 16:57:54 +0530 From: Arun Isaac To: Maxime Devos , Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: Guix Devel Subject: Re: Move switch-symlinks to (guix build utils) In-Reply-To: <2c194c3b2f192ba49caaf585703f95b6c6bcb7d9.camel@telenet.be> References: <87pmjsdeh7.fsf@systemreboot.net> <72a63d9badd632af81adb75b66cd95d9c05bc31a.camel@telenet.be> <87ee07cdfn.fsf@systemreboot.net> <8735glk8gs.fsf@gnu.org> <2c194c3b2f192ba49caaf585703f95b6c6bcb7d9.camel@telenet.be> Date: Mon, 06 Jun 2022 16:57:49 +0530 Message-ID: <87czfmm3pm.fsf@systemreboot.net> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=139.59.75.54; envelope-from=arunisaac@systemreboot.net; helo=mugam.systemreboot.net 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" 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=1654516371; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=nynM8DN8qWDKLmms5u3LT4fKtbnJ2M3NkNjVpNUL9Bs=; b=nfvyna2FGuQFHrOWgwnlUMUlbG1x3E3qVikgHFTjvI9sX8pmxSWvHS/CsHDp4on/l7PYZf H24JrLFqtciipP3M7Ye+H1aPQFw3CWM8Q2WEQuccVY4Qkg6R3QIgQBco7xjCWKZaVYhvB5 643BaIO2x0pfo8bKUjQCWrEycbkRp8p5zwf1QeXjhliV5OUdzorQbAfaVvM0uP2qDypXbo 8lGQjZRvhmgOx/ahN8uYhMefrLgJm3q8LW7xfyBFv4BS2xwGytAQ1hw01SP2dwB7+rB9s8 U3Yl70oZLQX1E3pOM3Bhs6KdJXh9mXKTtzA/V/nleS3CQFukclFR2KWkll57iA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654516371; a=rsa-sha256; cv=none; b=sv6Y/c+/IdFcLhv+BX5z1LWTjb+8eC9pBojEzuAStCzTJNDhjzLLdE8e2fIzBVfiuYbGtK HL03ToEHgoKSYoy4pn2eF0YnH68kBdKal9fLU7diKMTY6Sc6OT2RZ3idhI0Ey7ymDY92jU Zl50+4Q1lf3AeofkCNEDaeTeA2/FmlDHU+HSaoRq3wMihLjc6kkPrWwddHqoTju5SxrXCv VwpikbTbfkNOBbh8ym0JVI1iQrvmfyKbEhoLu7fclQm/iOaV7IDcQnPIkU5EHnC5lMeuUt o1vfXTc6/Gke3xeoAj99J/M4YV1Pfpo4YrkhTYU2FnBkFTrrTf88YeKCoZpuHA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=io3nzKvr; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 6.19 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=io3nzKvr; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9A5A630C7C X-Spam-Score: 6.19 X-Migadu-Scanner: scn1.migadu.com X-TUID: iOavDCkB5ocA > Maybe replace > > (symlink target pivot) > > by (symlink/remove-old target pivot) > > where > > (define (symlink/remove-old target link) > "Make a symbolic link named LINK pointing to TARGET. > If LINK already exists, it will be removed first. > This is not an atomic operation." > (catch 'system-error > (lambda () > (symlink target link)) > (lambda stuff > (if (= (system-error-errno stuff) EEXIST) > (begin > ;; remove old link and retry > (delete-file link) > (symlink/remove-old link target)) > (apply throw stuff))))) > > ? Could we implement symlink/remove-old without catch and throw? Something like: --8<---------------cut here---------------start------------->8--- (define (symlink/remove-old target link) "Make a symbolic link named LINK pointing to TARGET. If LINK already exists, it will be removed first. This is not an atomic operation." (when (file-exists? link) (delete-file link)) (symlink target link)) --8<---------------cut here---------------end--------------->8--- We might also inline this into switch-symlinks like so. --8<---------------cut here---------------start------------->8--- (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"))) ;; Delete pivot link in case it already exists. This can happen if ;; a previous switch-symlinks was interrupted. (when (file-exists? pivot) (delete-file pivot)) (symlink target pivot) (rename-file pivot link))) --8<---------------cut here---------------end--------------->8--- WDYT?