Subject: bug#22817: 25.0.91; [PATCH] Include versioned preloaded libraries in `package--builtin-versions'

From: Stefan Monnier <[email-masked]>
Date: Tue, 12 Jul 2016 09:19:50 -0400

> Also, since `package--builtin-versions' is now complete, should we remove the
> version info in `package--builtins'?

Not sure what you mean nor what would be the benefit.

> I forgot to mention that the bug can be reproduced by installing a
> package having a preloaded lib as a dependency, e.g.:
>
>   M-x package-install RET xelb RET
>
> Then cl-generic 0.2 will get installed.

A more direct way is to check (assq 'cl-generic package--builtin-versions)
which should not return nil (but does :-( ).

I haven't looked in detail at your patch, but it'd be good to do
something along these lines.

It's probably too late to use your approach for emacs-25, but I think we
need to install some fix for this problem in emacs-25, since otherwise
Emacs-25.1 will end up insisting on installing cl-generic from GNU ELPA
every occasion it gets.

How 'bout you install your patch into master and we install the patch
below into emacs-25?

        Stefan

diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 37edf45..e5bab8d 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -86,6 +86,11 @@
 
 ;;; Code:
 
+;; The autoloads.el mechanism which adds package--builtin-versions
+;; maintenance to loaddefs.el doesn't work for preloaded packages (such
+;; as this one), so we have to do it by hand!
+(push (purecopy '(cl-generic 1 0)) package--builtin-versions)
+
 ;; Note: For generic functions that dispatch on several arguments (i.e. those
 ;; which use the multiple-dispatch feature), we always use the same "tagcodes"
 ;; and the same set of arguments on which to dispatch.  This works, but is