Subject: bug#65666: Lockfiles break package-vc-install-from-checkout

From: Joseph Turner <[email-masked]>
Date: Sat, 02 Sep 2023 10:15:48 -0700

Eli Zaretskii <[email-masked]> writes:
> Or make the REGEXP argument to directory-files-recursively more
> specific, to reject lock files.
>
> But yes, the use of file-exists-p is not TRT, IMO.

See patch.

>From 31ea77e547e333c8e216d759c1c26ad1fe6c4df0 Mon Sep 17 00:00:00 2001
From: Joseph Turner <[email-masked]>
Date: Sat, 2 Sep 2023 10:14:22 -0700
Subject: [PATCH] Don't native compile lock files

* lisp/emacs-lisp/package.el (package--delete-directory):
Exclude lock files in regex.
---
 lisp/emacs-lisp/package.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index e1172d69bf0..8bc7936a5bf 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2484,7 +2484,9 @@ Clean-up the corresponding .eln files if Emacs is native
 compiled."
   (when (featurep 'native-compile)
     (cl-loop
-     for file in (directory-files-recursively dir "\\.el\\'")
+     for file in (directory-files-recursively dir
+                                              ;; Exclude lockfiles
+                                              (rx bos (or (and "." (not "#")) (not ".")) (* nonl) ".el" eos))
      do (comp-clean-up-stale-eln (comp-el-to-eln-filename file))))
   (if (file-symlink-p (directory-file-name dir))
       (delete-file (directory-file-name dir))
-- 
2.41.0