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 ms0.migadu.com with LMTPS id IDOmLgaqTmKzSwAAgWs5BA (envelope-from ) for ; Thu, 07 Apr 2022 11:08: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 mp12.migadu.com with LMTPS id 8FFMKwaqTmKlCAAAauVa8A (envelope-from ) for ; Thu, 07 Apr 2022 11:08: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 53C5E15E10 for ; Thu, 7 Apr 2022 11:08:22 +0200 (CEST) Received: from localhost ([::1]:43894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ncO7o-00007r-HE for larch@yhetil.org; Thu, 07 Apr 2022 05:08:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncO7W-00007b-St for guix-patches@gnu.org; Thu, 07 Apr 2022 05:08:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ncO7W-0003ub-Jb for guix-patches@gnu.org; Thu, 07 Apr 2022 05:08:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ncO7W-0007Ow-Ek for guix-patches@gnu.org; Thu, 07 Apr 2022 05:08:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#54762] [PATCH] home: symlink-manager: Use no-follow version of file-exists?. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 07 Apr 2022 09:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54762 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54762@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164932246528425 (code B ref -1); Thu, 07 Apr 2022 09:08:02 +0000 Received: (at submit) by debbugs.gnu.org; 7 Apr 2022 09:07:45 +0000 Received: from localhost ([127.0.0.1]:59838 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncO7F-0007OP-1M for submit@debbugs.gnu.org; Thu, 07 Apr 2022 05:07:45 -0400 Received: from lists.gnu.org ([209.51.188.17]:59652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ncO7D-0007OI-Oe for submit@debbugs.gnu.org; Thu, 07 Apr 2022 05:07:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncO7D-00005j-JX for guix-patches@gnu.org; Thu, 07 Apr 2022 05:07:43 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:50283) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ncO7A-0003sC-Cj for guix-patches@gnu.org; Thu, 07 Apr 2022 05:07:43 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id E79E81C000F for ; Thu, 7 Apr 2022 09:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1649322456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=rSv6pD3gnTqFUXI0QPlTCOjl1m8sq3aKV9O+hqhJDLM=; b=iW8Hr92LrXhFY97d/uT1UoYQO5mmRMrfvmnpQQNCmJ0WNGLOI2LQPv/rDL7U+T5LhdMtil +W36luQCidXy3gh4rb16iUte3KIocaLPoCAyGIcMOjdvPel0CmQh/wv4aQlctLWFI8zWtS oW6qwFv6QVxH9iY+Ry/pTyZPgoPYLfB/x959vDeJrZdUiFa+ujMX46OdHLZ+QAERWu/CvY v+8lT/CaOLz8j/URsz8mqopv2KS3IKVP/g8bXUFxiWN7Lr3tPBMGgukhzqFUlKr95Tjn+q 2t66qO06trH7X21gka0qEUMEgOLST9wpCNmqwhPGFBf6Kt0y8O1wjdz3AznfpQ== From: Andrew Tropin Date: Thu, 7 Apr 2022 11:22:48 +0300 Message-ID: <87zgkxxnvv.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: pass client-ip=217.70.183.197; envelope-from=andrew@trop.in; helo=relay5-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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: 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=1649322502; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=rSv6pD3gnTqFUXI0QPlTCOjl1m8sq3aKV9O+hqhJDLM=; b=jaNR0qdhTQvRXQ80e4D/6YMVu4JOy7CtbAA+88+aA7yJo4p+cErCv/9UeeaPIY0Cp/PR9Z KHI+ClmYTIZ2rV5QRJnBpS6NUSW7K6KBeDmKQrNiCK5VFcwuyyKVcgP5wo5j4vgI7pml3y rJG2zOpZrZjOiWNSt527jiJN7HGP9jPYi8XHA9+u5pTryFJtkILI5nkkBI3JOcYWVr+zjq WeJJueD+Q3WfoZd2m8fcMqrdl4tNRw3UI7diJIpKcY9apw/XM5kAzxAahWL8xsgQQk6dEI sGc1QxHb8/ZhYBRj2za+LlwTxE1mEgFLePsBXaoaETLqWsOQZjlXDFWVst/9qg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1649322502; a=rsa-sha256; cv=none; b=AI6DmSBt0+9/q0peXb4wy5LkI3bPtkgpMGJxN+doDFB9Gfvq2nGt5pmRxASGLxZh+djRfb 9MBPNzyb+Fhc8S1vO/ZBF5uubpSuLbUID4I9zGwCULCm52qfoQu3YXCyJjYrY6XmmHO1pv J7WO8TRc0FkiEK3o/x1wIlsoj+9XgYZbt10vIrTYg0X+f1i9dfoSMf7zL07YC8axolYtMY ddOUQHsIDB5tcKe2ShUzYDrQZFwfGzRg+uWuIPeFRwkjqLfi2DmfN9ib97Vj8z2LajLXZe jPgcOjTgaS3NUQpfMjq+Gl8zvxaKkzzH7/bYkgvOMxZsU0DUJ1b6ZurEqQZZGw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=iW8Hr92L; dmarc=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: -1.27 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=iW8Hr92L; dmarc=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: 53C5E15E10 X-Spam-Score: -1.27 X-Migadu-Scanner: scn0.migadu.com X-TUID: yLXYqYcVPYrd --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable * gnu/home/services/symlink-manager.scm (update-symlinks-script): Use no-follow version of file-exists?. =2D-- file-exists? returns #f on dangling symlinks, which makes such files "invisible" during the cleanup process and breaks activation of home environment. gnu/home/services/symlink-manager.scm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gnu/home/services/symlink-manager.scm b/gnu/home/services/syml= ink-manager.scm index 6d19258ec7..bb67152e5b 100644 =2D-- a/gnu/home/services/symlink-manager.scm +++ b/gnu/home/services/symlink-manager.scm @@ -85,6 +85,13 @@ (define (target-file file) ;; such as "config/fontconfig/fonts.conf" or "bashrc". (string-append home-directory "/" (preprocess-file file))) =20 + (define (no-follow-file-exists? file) + "Return #t if file exists, even if it's a dangling symlink." + (or (file-exists? file) + (and=3D> (false-if-exception (lstat file)) + (lambda (x) + (equal? (stat:type x) 'symlink))))) + (define (symlink-to-store? file) (catch 'system-error (lambda () @@ -123,7 +130,7 @@ (define (strip file) (const #t) (lambda (file stat _) ;leaf (let ((file (target-file (strip file)))) =2D (when (file-exists? file) + (when (no-follow-file-exists? file) ;; DO NOT remove the file if it is no longer a symlink to ;; the store, it will be backed up later during ;; create-symlinks phase. @@ -183,7 +190,7 @@ (define (source-file file) (lambda (file stat result) ;leaf (let ((source (source-file (strip file))) (target (target-file (strip file)))) =2D (when (file-exists? target) + (when (no-follow-file-exists? target) (backup-file (strip file))) (format #t (G_ "Symlinking ~a -> ~a...") target source) @@ -192,7 +199,7 @@ (define (source-file file) (lambda (directory stat result) ;down (unless (string=3D? directory config-file-directory) (let ((target (target-file (strip directory)))) =2D (when (and (file-exists? target) + (when (and (no-follow-file-exists? target) (not (file-is-directory? target))) (backup-file (strip directory))) =20 =2D-=20 2.34.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmJOqdQPHGFuZHJld0B0 cm9wLmluAAoJECII0glYwd6wWssP/R3DnmjRX8tROgJDGXixms/N0MahKWhSIAXG mIxhPmqeYT22RjXDQWxuAK7d0nBWY9CD6yNocQeQ6lBZ5lyiiow+GAqUYqj+vQLO RWLbuk+1+prUbGDE8OyXO0nVAFv8f7PYVb6P5shL0m4qIfONcwGI70NAW8wx3FaP 1RvzsbZLlNwHRfquB63OV7oi7w7Ku93sJGoIBZpOPD1ezTFi6Es9m60DEDSoNu9y v6SiQdmMpPa9mljJa6iIT3uYy5x9X3wd1FDvN1nl9ioxFv6l6RQLyg8NQu7cZlOu AsbA8u3XN9PlTCKRkQPyLAQhhy9oLIA4QILa5z6rI28Y8CX9GcLtn2HrPXGw9y3W li9YATvZ/27u9f3lpmmviP+1qHLJYE+3byqfiNLWgry7JD1xIs8NWtWJmOdfyk1w 6hJEkr+B1a7rj0AzmQ2yet7BwDUZ9iVTDZnOo66CDeM4EWX5Z6Byx5/83CK/uTok +dwFzI0/tdTzNUagScGJwPssRz8w3u0U71sG9mGWmyWkjZt/RhKzaEN3dowvBixU 24B+2cnzos/rEE0CWKAJ8X6L/c6YIbkVO5O/mzYxWSluYri7selClDAXbqOCDfS3 +gD6SDsPA6fDzsfb7AtTTPCXxxKS4Z4ODk5FdxwRBteDzEJxBL1NDiyd8hPJwpv3 p0RRM2D5 =cHw6 -----END PGP SIGNATURE----- --=-=-=--