aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Kaludercic2025-05-03 23:39:17 +0200
committerPhilip Kaludercic2025-05-03 23:40:57 +0200
commitf41ab0b425c7cfb2c337deb28ef2d7e4bd339394 (patch)
treef82b06c39752dda3f894a8e807803aca6149317d
parent8a097aede53dfb8f595d79824c784c188b210093 (diff)
downloademacs-f41ab0b425c7cfb2c337deb28ef2d7e4bd339394.tar.gz
emacs-f41ab0b425c7cfb2c337deb28ef2d7e4bd339394.zip
Preserve directory structure of local packages
* lisp/emacs-lisp/package.el (package-unpack): Re-create the directory structure of the source directory and copy the files in the right place. (package-dir-info): Try to find package info in files closer to the specified package source root. (Bug#78017)
-rw-r--r--lisp/emacs-lisp/package.el43
1 files changed, 21 insertions, 22 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index ad60afb62da..82fcf439a11 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1013,9 +1013,11 @@ untar into a directory named DIR; otherwise, signal an error."
1013 (dired-get-marked-files)) 1013 (dired-get-marked-files))
1014 (directory-files-recursively default-directory "" nil)))) 1014 (directory-files-recursively default-directory "" nil))))
1015 (dolist (source-file file-list) 1015 (dolist (source-file file-list)
1016 (let ((target-el-file 1016 (let ((target (expand-file-name
1017 (expand-file-name (file-name-nondirectory source-file) pkg-dir))) 1017 (file-relative-name source-file default-directory)
1018 (copy-file source-file target-el-file t))) 1018 pkg-dir)))
1019 (make-directory (file-name-directory target) t)
1020 (copy-file source-file target t)))
1019 ;; Now that the files have been installed, this package is 1021 ;; Now that the files have been installed, this package is
1020 ;; indistinguishable from a `tar' or a `single'. Let's make 1022 ;; indistinguishable from a `tar' or a `single'. Let's make
1021 ;; things simple by ensuring we're one of them. 1023 ;; things simple by ensuring we're one of them.
@@ -1255,27 +1257,24 @@ The return result is a `package-desc'."
1255 (with-temp-buffer 1257 (with-temp-buffer
1256 (insert-file-contents desc-file) 1258 (insert-file-contents desc-file)
1257 (package--read-pkg-desc 'dir)) 1259 (package--read-pkg-desc 'dir))
1258 (let ((files (or (and (derived-mode-p 'dired-mode) 1260 (catch 'found
1259 (dired-get-marked-files)) 1261 (let ((files (or (and (derived-mode-p 'dired-mode)
1260 (directory-files-recursively default-directory "\\.el\\'"))) 1262 (dired-get-marked-files))
1261 info) 1263 (directory-files-recursively default-directory "\\.el\\'"))))
1262 (while files 1264 ;; We sort the file names in lexicographical order, to ensure
1263 (with-temp-buffer 1265 ;; that we check shorter file names first (ie. those further
1264 (let ((file (pop files))) 1266 ;; up in the directory structure).
1265 ;; The file may be a link to a nonexistent file; e.g., a 1267 (dolist (file (sort files))
1266 ;; lock file. 1268 ;; The file may be a link to a nonexistent file; e.g., a
1267 (when (file-exists-p file) 1269 ;; lock file.
1270 (when (file-exists-p file)
1271 (with-temp-buffer
1268 (insert-file-contents file) 1272 (insert-file-contents file)
1269 ;; When we find the file with the data, 1273 ;; When we find the file with the data,
1270 (when (setq info (ignore-errors (package-buffer-info))) 1274 (when-let* ((info (ignore-errors (package-buffer-info))))
1271 ;; stop looping, 1275 (setf (package-desc-kind info) 'dir)
1272 (setq files nil) 1276 (throw 'found info))))))
1273 ;; set the 'dir kind, 1277 (error "No .el files with package headers in `%s'" default-directory)))))
1274 (setf (package-desc-kind info) 'dir))))))
1275 (unless info
1276 (error "No .el files with package headers in `%s'" default-directory))
1277 ;; and return the info.
1278 info))))
1279 1278
1280 1279
1281;;; Communicating with Archives 1280;;; Communicating with Archives