From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 YFrzGrcxp2L2GQAAbAwnHQ (envelope-from ) for ; Mon, 13 Jun 2022 14:46:47 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id kGTwGrcxp2IXxgAA9RJhRA (envelope-from ) for ; Mon, 13 Jun 2022 14:46:47 +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 0D9BE8305 for ; Mon, 13 Jun 2022 14:46:47 +0200 (CEST) Received: from localhost ([::1]:52066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o0jSw-0004Ge-7N for larch@yhetil.org; Mon, 13 Jun 2022 08:46:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0izF-0003zG-0k for guix-patches@gnu.org; Mon, 13 Jun 2022 08:16:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o0izD-0008Lj-5j for guix-patches@gnu.org; Mon, 13 Jun 2022 08:16:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o0izD-0004Db-2H for guix-patches@gnu.org; Mon, 13 Jun 2022 08:16:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55941] [PATCH core-updates 2/3] utils: Make switch-symlinks robust against interruption. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 13 Jun 2022 12:16:03 +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.165512254916173 (code B ref 55941); Mon, 13 Jun 2022 12:16:03 +0000 Received: (at 55941) by debbugs.gnu.org; 13 Jun 2022 12:15:49 +0000 Received: from localhost ([127.0.0.1]:57453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o0iyw-0004Ce-Dz for submit@debbugs.gnu.org; Mon, 13 Jun 2022 08:15:49 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:46412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o0iye-0004Bq-N2 for 55941@debbugs.gnu.org; Mon, 13 Jun 2022 08:15:30 -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:References:In-Reply-To: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:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Kof9tc4lW0D+8E8RqFR3cKRVrp2VHJY3zzVyjfFYuRw=; b=MP7Nlvg4JBWG4noocZrV75gAXx iPpcxE0XBWmQMZATH7YymyubWmMUqDz9eLTfVeQFVRI6U0aiTyFOlm2uwg/Xe5GdtaAH2hQMs6jDE VnsglvzW2RJn1PdaMoyvGmk0Q8CSNQpJCK0npdaDpqDXe8UmFKiuSaO+ORySHUXQ/Us6Y+vqFd+CE /ZixEpU/HEBYAtA206TKiG76ErEHZLjTOLzfa5VL9+1ymIDubXM0S7DGmkrgokVxPYR3uWwXIa/Q1 wivJggVm0ILFNA2KKG0u9ViVSbXxu5oDe0jw0z5kFmHjlP/gGGU0KuwdneIIT8faUurknuUHtXQuQ 83meT+wg==; 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-JE; Mon, 13 Jun 2022 17:45:25 +0530 From: Arun Isaac Date: Mon, 13 Jun 2022 17:45:22 +0530 Message-Id: <20220613121523.20327-2-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613121523.20327-1-arunisaac@systemreboot.net> References: <20220613121523.20327-1-arunisaac@systemreboot.net> 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=1655124407; 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=Kof9tc4lW0D+8E8RqFR3cKRVrp2VHJY3zzVyjfFYuRw=; b=WhZOh/DIthkmUnz49t8gCMJrACBAyxiBQ7lpmFbW9vj0Vy8lslg1NGjHrqmQ82oaZNTmsw oBgnYmNxZdi58dpBHGhn2QrQaFrt2v6sRmF4zKPF6Bk9hAZkqrt9MEYwyL7v9nDfww3GnH AnSHCm+nLzEc9+PZejjrpYLAe2gYM1xfYMS6m9lt86m7N4pM8cyu67maLL71ponpb/2dId VetrgA/oJP2ZfHNaGSj7MbHYXQI8PhKknw1RjOagtxxcWgut+D7jXNGW1CV33avTL81Kcj BXi8OWCMW5cGzdr/AaXl42zvGtBcAxvnoQ7CezGTxvlnMOOf/Eg378uWsHXzpQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655124407; a=rsa-sha256; cv=none; b=Nr/4ODh0mNlu/Wyb6O7cSgA7Wf7g72oNN5sImzWFTsyh/mB1tpD+Jf6HaWZalqA9Hmq/Ao DOytV1wCQBYrZRXGR2I+d9PkiUXEXCI6fvkEs9dyHERWpe/hpx2L+PCl/8Eu46sD5Kn0S0 8J07UU2mMiB2uX4K94b0sF3++95O/Xkqlof8dJi2+awBigcUMvz9NElf5FuGt9uIaz8zTV oEwCJkOFbCPztidQWJZbb/UGmdSokfPsR6Cgwp7WGOdjxIKlZfUiDiXAVx7kwVWqQvqzNj Xn0q6BQUv9qtlMBZgY37xRAG7xPyALu8//GzfLKRNJWx3/H1GJR+9A0V5Chsjw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=MP7Nlvg4; 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: 7.01 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b=MP7Nlvg4; 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: 0D9BE8305 X-Spam-Score: 7.01 X-Migadu-Scanner: scn1.migadu.com X-TUID: tnJRVGo5oKas * guix/build/utils.scm (switch-symlinks): Delete pivot link if it already exists. Co-authored-by: Maxime Devos --- guix/build/utils.scm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/guix/build/utils.scm b/guix/build/utils.scm index ce7bdb2024..5ea3b98353 100644 --- a/guix/build/utils.scm +++ b/guix/build/utils.scm @@ -3,11 +3,11 @@ ;;; Copyright © 2013 Andreas Enge ;;; Copyright © 2013 Nikita Karetnikov ;;; Copyright © 2015, 2018, 2021 Mark H Weaver -;;; Copyright © 2018 Arun Isaac +;;; Copyright © 2018, 2022 Arun Isaac ;;; Copyright © 2018, 2019 Ricardo Wurmus ;;; Copyright © 2020 Efraim Flashner ;;; Copyright © 2020, 2021 Maxim Cournoyer -;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2021, 2022 Maxime Devos ;;; Copyright © 2021 Brendan Tildesley ;;; ;;; This file is part of GNU Guix. @@ -245,7 +245,19 @@ (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) + ;; Create pivot link, deleting it if it already exists. This can + ;; happen if a previous switch-symlinks was interrupted. + (let symlink/remove-old () + (catch 'system-error + (lambda () + (symlink target pivot)) + (lambda args + (if (= (system-error-errno args) EEXIST) + (begin + ;; Remove old link and retry. + (delete-file pivot) + (symlink/remove-old)) + (apply throw args))))) (rename-file pivot link))) (define (call-with-temporary-output-file proc) -- 2.36.1