1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-10 16:20:17 -08:00

Fix upgrading, rebuilding, and logging of VC packages

There are a few issues addressed in this patch:

1.  Compilation (including native compilation) should happen in
directory that contains package's Lisp code.

2.  After installing a package with
`package-vc-install-from-checkout' and subsequently upgrading it
with `package-vc-upgrade' the pkg-desc for the package becomes
corrupted.  After the upgrade the pkg-desc's dir (a.k.a
`pkg-dir') points to checkout directory.  This will cause the
subsequent `package-delete' to delete the checkout directory and
leaving incorrect forwarding autoloads file in
`package-user-directory'.

3. The detection of package's Lisp directory has been not
effective for packages installed with `package-vc-install' and
not existent for packages installed with
`package-install-from-checkout'.

4. Deduction of VC backend has been not working when called from
outside of deducing context.

5. Extract maintainers and store them in a package description
file when installing a package from a checkout.

* lisp/emacs-lisp/package-vc.el (package-vc--checkout-dir): New
function to determine the real checkout of a VC
package.
(package-vc--url-scheme): Define scheme for `:url' property.
(package-vc--generate-description-file): Extract maintainers
from main package file and store them in generated description
file.
(package-vc--save-selected-packages): Refactor new helper
function out of 'package-vc--unpack' to modify
'package-vc-selected-packages'.
(package-vc--checkout-dir): Use `pcase' to extract checkout
directory from `pkg-spec'.  Detect standard lisp sub directory
if called with non-nil `lisp-dir'.
(package-vc-commit, package-vc--main-file)
(package-vc--build-documentation, package-vc-prepare-patch): Use
'package-vc--checkout-dir'.
(package-vc--unpack-1): Remove superfluous `pkg-dir' argument.
Remove elc files before compilation.  Use a `package' with
`:dir' pointing to where package code is.  When `checkout-dir'
is different than `pkg-dir' then call `package--add-info-node'
and after calling `package-activate-1' reload source files in
case when `lisp-dir' is a sub directory.  Use the right
directories in the right places.
(package-vc-install-from-checkout): Remove superfluous
`package-vc-selected-packages' binding.  Remove `pkg-dir'
argument from `package-vc--unpack-1' calls.
(package-vc--unpack): Remove `lisp-dir' variable and convert to
`let*'.  Remove superfluous Lisp code sub directory detection -
logic moved to `package-vc--checkout-dir'.  Remove `pkg-dir'
argument from `package-vc--unpack-1' call. Use
'package-vc--save-selected-packages'.
(package-vc-upgrade, package-vc-rebuild): Remove `pkg-dir'
argument from `package-vc--unpack-1' calls. Use
'package-vc--checkout-dir'.
(package-vc-log-incoming): Set `vc-deduce-backend-nonvc-modes'
to t.  Use 'package-vc--checkout-dir'.
* lisp/emacs-lisp/package.el (package--add-info-node): New
function to install info node for package.  Extracted from
`package-activate-1'.
(package-activate-1): Call `package--add-info-node'.

Co-developed-by: Philip Kaludercic <philipk@posteo.net>

(Bug#79188)
This commit is contained in:
Przemysław Kryger 2025-09-26 14:00:54 +01:00 committed by Philip Kaludercic
parent 8a0217ebbc
commit 573acd97e5
No known key found for this signature in database
2 changed files with 225 additions and 119 deletions

View file

@ -905,6 +905,14 @@ sexps)."
(mapc (lambda (c) (load (car c) nil t))
(sort result (lambda (x y) (< (cdr x) (cdr y))))))))
(defun package--add-info-node (pkg-dir)
"Add info node located in PKG-DIR."
(when (file-exists-p (expand-file-name "dir" pkg-dir))
;; FIXME: not the friendliest, but simple.
(require 'info)
(info-initialize)
(add-to-list 'Info-directory-list pkg-dir)))
(defun package-activate-1 (pkg-desc &optional reload deps)
"Activate package given by PKG-DESC, even if it was already active.
If DEPS is non-nil, also activate its dependencies (unless they
@ -936,12 +944,7 @@ correspond to previously loaded files."
The following files have already been loaded: %S")))
(with-demoted-errors "Error loading autoloads: %s"
(load (package--autoloads-file-name pkg-desc) nil t)))
;; Add info node.
(when (file-exists-p (expand-file-name "dir" pkg-dir))
;; FIXME: not the friendliest, but simple.
(require 'info)
(info-initialize)
(add-to-list 'Info-directory-list pkg-dir))
(package--add-info-node pkg-dir)
(push name package-activated-list)
;; Don't return nil.
t)))